[BusyBox] [sgunderson at bigfoot.com: Bug#211675: busybox-cvs-udeb: fails to use internal libpwdgrp; breaks 'id' and others]

Bastian Blank waldi at debian.org
Fri Sep 19 19:51:12 UTC 2003


----- Forwarded message from "Steinar H. Gunderson" <sgunderson at bigfoot.com> -----

Subject: Bug#211675: busybox-cvs-udeb: fails to use internal libpwdgrp;
    breaks 'id' and others
From: "Steinar H. Gunderson" <sgunderson at bigfoot.com>
To: Debian Bug Tracking System <submit at bugs.debian.org>
Date: Fri, 19 Sep 2003 14:13:22 +0200

Package: busybox-cvs-udeb
Version: 0.60.99.cvs20030819
Severity: normal
Tags: patch upstream d-i

busybox has its own internal libpwdgrp, providing standard functions
like getgrnam() etc. without having to resort to external libc (which
uses NSS, which does not work during a d-i install since the NSS
libraries would be too big to include). However, when building busybox,
the last line reads

  gcc -s -Wl,-warn-common -o busybox ./applets/applets.a (other .a files
  here) ./libpwdgrp/libpwdgrp.a ./coreutils/libcoreutils/libcoreutils.a
  ./libbb/libbb.a

coreutils/id.c (among others) uses a function called "my_getgrnam" from
libbb.a, which in turn calls getgrnam() which it expects to find in
libpwdgrp.a.  However, since GNU ld only searches .a files coming
_later_ on the command line compared to the file it searches in, it
never searches libpwdgrp.a and thus searches for it in libc.so.6 instead
(where it finds it). Thus, it breaks at runtime since NSS is not
available, and glibc can only do a small amount of /etc/{passwd,group}
reading without libnss_files.so.2.

To make things worse, libpwdgrp.a depends on some variables from libbb.a
again, so it's not possible to solve this by simple rearranging. The
only way I can see how this could be made to work (without going through
all such dependencies and resolve them, which could be quite a task), is
to use the --start-group and --end-group flags from GNU ld. With them,
the linker searches all .a files every time instead of just those coming
later. This results in a performance penalty at link time (although on
my machine, busybox linking is so fast I can't notice any delay at all
:-) ), but it solves the problem and makes busybox use libpwdgrp
correctly at all times.

The included patch adds -Wl,--start-group and -Wl,--end-group to the
Makefile, causing all the .a files to be treated as a group. One could
of course make smaller groups (for instance, a group from libpwdgrp.a up
to and including libbb.a), but I don't know if this breaks other places,
and the link is fast enough anyhow, IMO. It makes busybox depend on GNU
ld for building, but I don't know any target systems for busybox where
GNU ld is not already standard :-)

-- System Information
Debian Release: 3.0
Architecture: i386
Kernel: Linux cassarossa 2.4.20 #4 SMP Tue Mar 18 18:01:22 CET 2003 i686
Locale: LANG=en_US, LC_CTYPE=en_US.ISO8859-1




----- End forwarded message -----

bastian

-- 
The heart is not a logical organ.
		-- Dr. Janet Wallace, "The Deadly Years", stardate 3479.4
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 197 bytes
Desc: Digital signature
Url : http://lists.busybox.net/pipermail/busybox/attachments/20030919/28fc1cfc/attachment-0002.pgp 


More information about the busybox mailing list