Four issues, patch to fix them is attached: 1. Apparently BB is relying on header pollution to get the definitions of major() and minor() macros used by tar, cpio, etc. The "correct" header for them is sys/sysmacros.h. The attached patch includes sysmacros.h, but only if major was not already defined by another header (usually sys/types.h). 2. COMMON_BUFSIZE is insufficient for inetd unless libc BUFSIZ is >= ~2k. Patch fixes it, but some tweaking may be desired to find the minimal value that will work. 3. BB is using the nonstandard "fdprintf" name by default for a function that was standardized by POSIX 2008 as "dprintf". Attached patch checks _POSIX_VERSION and uses the standard name when POSIX 2008 is detected, but a better solution would be to always use dprintf except on a finite known-bad set of systems that lack it. Unfortunately I don't know which systems these are. 4. networking/interface.c tries to include a kernel header by default instead of using the userspace net/ethernet.h, unless it detects glibc or newlib. The correct behavior would be to use the correct userspace header except on a finite known set of systems that lack it, but I don't know what these systems are, so I used a dummy "WTF_SOME_WEIRD_LIBC" as the test instead. This should obviously be fixed before committing.
Created attachment 2851 [details] Patch
> 2. COMMON_BUFSIZE is insufficient for inetd unless libc BUFSIZ is >= ~2k. Patch > fixes it, but some tweaking may be desired to find the minimal value that will > work. Please attach the .config where it happens.
I can if you like, but it happens whenever inetd is enabled (even with no internal services) and BUFSIZ==1024.
Created attachment 2857 [details] config file for which COMMON_BUFSIZE is too small.
(In reply to comment #4) > Created attachment 2857 [details] > config file for which COMMON_BUFSIZE is too small. I added this test printouts to networking/inetd.c: int inetd_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE; int inetd_main(int argc UNUSED_PARAM, char **argv) { struct sigaction sa, saved_pipe_handler; servtab_t *sep, *sep2; struct passwd *pwd; struct group *grp = grp; /* for compiler */ int opt; pid_t pid; sigset_t omask; INIT_G(); bb_error_msg("sizeof(G):%ld", (long)sizeof(G)); bb_error_msg("COMMON_BUFSIZE:%ld", (long)COMMON_BUFSIZE); exit(0); With your .config, building against 64-bit glibc I see: $ ./busybox inetd inetd: sizeof(G):464 inetd: COMMON_BUFSIZE:8193 when I additionally enable all inetd options, I see: inetd: sizeof(G):608 inetd: COMMON_BUFSIZE:8193 And finally, building this .config against 32-bit uclibc configured for BUFSIZ=1024, I see: inetd: sizeof(G):584 inetd: COMMON_BUFSIZE:1025 I don't see the problem. Please explain where is it.
Indeed, after further investigation, the COMMON_BUFSIZE issue was coming from a bug in my build environment which was bloating the size of inetd's globals, and not from BB. The other issues in this bug report still stand.
I incorporated sys/sysmacros.h and fdprintf fixes. Thanks!