Help: DNS Resolver and Root Shell

Hui Li openlinuxsource at gmail.com
Mon Oct 21 14:45:08 UTC 2013


On Sun, 2013-10-20 at 22:04 +0200, Tito wrote:
> On Sunday 20 October 2013 18:31:26 Hui Li wrote:
> > Hi,
> > 
> > I'm new to busybox and encountered 2 issues currently during building up
> > small rootfs.
> > 
> > 1). DNS resolver is not valid. I googled some and it seems I need to
> > copy libnss_files/libnss_dns/libresolv libs to proper directory(/lib),
> > however it's still failed. The busybox is compiled in shared libraries
> > way. Here's arm ldd output:
> > 
> > $ arm-rpi-linux-gnueabi-ldd
> > --root /opt/arm/arm-rpi-linux-gnueabi/arm-rpi-linux-gnueabi/sysroot
> > busybox 
> >         libm.so.6 => /lib/libm.so.6 (0xdeadbeef)
> >         ld-linux-armhf.so.3 => /lib/ld-linux-armhf.so.3 (0xdeadbeef)
> >         libc.so.6 => /lib/libc.so.6 (0xdeadbeef)
> 
> Hi,
> I think you should copy the relative libs for your architecture to your /lib dir
> libresolv.so.*
> libnss*.so
> and set up a /etc/nsswitch.conf file.
> However if there are no libnss*.so files on your rootfs
> you can eventually opt to use busybox's own  internal password and
> group functions rather than system functions   
> by enabling the relevant options in
> Login/Password Management Utilities.
> Also take a look at http://busybox.net/downloads/BusyBox.html:
> 
> LIBC NSS
> 
> GNU Libc (glibc) uses the Name Service Switch (NSS) to configure the behavior of the C library for the
> local environment, and to configure how it reads system data, such as passwords and group information.
> This is implemented using an /etc/nsswitch.conf configuration file, and using one or more of the /lib/libnss_* libraries.
> BusyBox tries to avoid using any libc calls that make use of NSS. Some applets however, such as login and su,
> will use libc functions that require NSS.
> If you enable CONFIG_USE_BB_PWD_GRP, BusyBox will use internal functions to directly access the /etc/passwd,
> /etc/group, and /etc/shadow files without using NSS. This may allow you to run your system without the need
> for installing any of the NSS configuration files and libraries.
> When used with glibc, the BusyBox 'networking' applets will similarly require that you install at least some of the
> glibc NSS stuff (in particular, /etc/nsswitch.conf, /lib/libnss_dns*, /lib/libnss_files*, and /lib/libresolv*).
> Shameless Plug: As an alternative, one could use a C library such as uClibc. In addition to making your system
> significantly smaller, uClibc does not require the use of any NSS support files or libraries.
> 
> 
> Hope this helps.
> 
Hi mate,

I have copied all necessary libs to /lib already but seems still
invalid. Do I need /etc/nsswitch.conf as well?

[huli at dhcp-193-161 ARM-sysroot]$ ls -l lib/
total 2336
-r-xr-xr-x. 1 huli huli  170872 Oct 19 01:29 ld-2.17.so
lrwxrwxrwx. 1 huli huli      10 Oct 19 01:29 ld-linux-armhf.so.3 ->
ld-2.17.so
-r-xr-xr-x. 1 huli huli 1544998 Oct 19 01:29 libc-2.17.so
lrwxrwxrwx. 1 huli huli      12 Oct 19 01:29 libc.so.6 -> libc-2.17.so
-r-xr-xr-x. 1 huli huli  490243 Oct 19 01:29 libm-2.17.so
lrwxrwxrwx. 1 huli huli      12 Oct 19 01:29 libm.so.6 -> libm-2.17.so
-r-xrwxr-x. 1 huli huli   22392 Oct 20 23:58 libnss_dns-2.17.so
lrwxrwxrwx. 1 huli huli      18 Oct 20 23:59 libnss_dns.so.2 ->
libnss_dns-2.17.so
-r-xrwxr-x. 1 huli huli   58805 Oct 20 23:59 libnss_files-2.17.so
lrwxrwxrwx. 1 huli huli      20 Oct 21 00:00 libnss_files.so.2 ->
libnss_files-2.17.so
-r-xrwxr-x. 1 huli huli   92596 Oct 21 00:00 libresolv-2.17.so
lrwxrwxrwx. 1 huli huli      17 Oct 21 00:00 libresolv.so.2 ->
libresolv-2.17.so

My toolchain has all necessary libs already.

Thanks.
> Ciao,
> Tito
> > And I also took reference to this thread
> > http://lists.busybox.net/pipermail/busybox/2001-November/005103.html to
> > add those LDFLAGS in menuconfig but looks like busybox does not use it
> > when I try to do make:
> > 
> > Trying libraries: crypt m nss_dns nss_files resolv
> >  Library crypt is not needed, excluding it
> >  Library m is needed, can't exclude it (yet)
> >  Library nss_dns is not needed, excluding it
> >  Library nss_files is not needed, excluding it
> >  Library resolv is not needed, excluding it
> >  Library m is needed, can't exclude it (yet)
> > Final link with: m
> > 
> > 2). Root shell does start from /root. After I created the rootfs and
> > booting to login prompt the root user is under '/' not '/root'. I am
> > sure root user's home dir is /root in /etc/passwd and I have defined
> > HOME shell variable is '/root' in /etc/profile. I also found a bug
> > thread which opened to OpenWRT project related to this issue.
> > Unfortunately, this issue was marked as 'wontfix'. Bug URL:
> > https://dev.openwrt.org/ticket/2657
> > 
> > Can anyone show me some tips there?
> > 
> > Thanks.
> > 
> > Hui
> _______________________________________________
> busybox mailing list
> busybox at busybox.net
> http://lists.busybox.net/mailman/listinfo/busybox




More information about the busybox mailing list