busybox 注意事项

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.

GNU Libc使用NSS来配置C库的行为,比如读取passwords和group。这是通过/etc/nsswitch.conf 和/lib/libnss_* 库来实现的。busybox避免使用libc的NSS,但是一些命令,如login和su还是使用libc的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.

如果启用CONFIG_USE_BB_PWD_GRP,busybox会用内部的函数来访问/etc/passwd, /etc/group, and /etc/shadow 等文件。当程序中使用用户名和密码时要注意!

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.

当使用glib时,busybox的网络相关命令(如ping)需要glibc和 NSS。如果ping 域名不同,可能就是少了这些库。

另外,可以参考我之前的文章:

http://www.cnblogs.com/cute/archive/2011/05/03/2035645.html

libnss_dns

NSS routines for DNS.

Loaded automatically by the glibc NSS

libnss_files

NSS routines for file lookups.

Loaded automatically by the glibc NSS

libnss_hesiod

NSS routines for Hesiod name service.

Loaded automatically by the glibc NSS

libnss_nis

NSS routines for NIS.

Loaded automatically by the glibc NSS

libnss_nisplus

NSS routines for NIS plus.

Loaded automatically by the glibc NSS

 

 

getpwnam失败,cp libnss-files过去就可以了。参考

Library Dependency 的議題要點 http://www.jollen.org/blog/2006/10/library_dependency_1.html

 

还可以通过strace来跟踪:http://www.xxlinux.com/linux/article/accidence/technique/20080221/13957.html

 

----------------------------------------------------------------------------------------------------------------

http://www.jollen.org/blog/2006/10/name_service_switch.html

http://www.jollen.org/blog/2006/10/name_service_switch_1.html#more

root@james-desktop:/opt/qt-everywhere/marvell/SDK/initramfs/lib# arm-mv5sft-linux-gnueabi-readelf -s ./libnss_dns.so.2 | grep gethostbyname
    37: 00001e2c   564 FUNC    GLOBAL DEFAULT   12 _nss_dns_gethostbyname3_r@@GLIBC_PRIVATE
    39: 00002100    56 FUNC    GLOBAL DEFAULT   12 _nss_dns_gethostbyname2_r@@GLIBC_PRIVATE
    40: 00002060   160 FUNC    GLOBAL DEFAULT   12 _nss_dns_gethostbyname_r@@GLIBC_PRIVATE
root@james-desktop:/opt/qt-everywhere/marvell/SDK/initramfs/lib# arm-mv5sft-linux-gnueabi-readelf -s ./libnss_files.so.2 | grep gethostbyname
    68: 00004ea4  1412 FUNC    GLOBAL DEFAULT   12 _nss_files_gethostbyname_@@GLIBC_PRIVATE
    97: 00004928  1404 FUNC    GLOBAL DEFAULT   12 _nss_files_gethostbyname2@@GLIBC_PRIVATE

 

root@james-desktop:/opt/qt-everywhere/marvell/SDK/initramfs/lib# grep -rn "gethostbyname" *
二进制文件 libc-2.8.so 匹配
二进制文件 libc.so.6 匹配
二进制文件 libnss_dns-2.8.so 匹配
二进制文件 libnss_dns.so.2 匹配
二进制文件 libnss_files-2.8.so 匹配
二进制文件 libnss_files.so.2 匹配
二进制文件 libresolv-2.8.so 匹配
二进制文件 libresolv.so.2 匹配

 

root@james-desktop:/opt/qt-everywhere/marvell/SDK/initramfs/lib# arm-mv5sft-linux-gnueabi-readelf -s ./libc.so.6 | grep gethostbyname
   692: 000dbfa8   808 FUNC    GLOBAL DEFAULT   11 gethostbyname_r@@GLIBC_2.4
   769: 000dbc6c   828 FUNC    GLOBAL DEFAULT   11 gethostbyname2_r@@GLIBC_2.4
  1291: 000db7c4   592 FUNC    GLOBAL DEFAULT   11 gethostbyname@@GLIBC_2.4
  1699: 000dba14   600 FUNC    GLOBAL DEFAULT   11 gethostbyname2@@GLIBC_2.4

posted on 2012-02-29 16:38  katago  阅读(1246)  评论(0编辑  收藏  举报