在带有fakeroot/fakechroot的ARM Linux rootfs上网络不正常



我使用buildroot创建了一个rootfs,但是使用 crostool -ng工具链与glibc。这向我展示了所需的最小文件集。然后,我用直接从armel的压缩.deb包中提取的库替换了所有库。然后我将fakerootfakechroot添加到混合物中(也来自.deb包)。我还根据自己的喜好修改了resolv.confhostsnsswitch.conf文件。上传这个到我的设备后,很多工作。cd /带我去了正确的地方。whoami返回root。但是,任何与DNS相关的都不能工作。例如,ping google.com返回坏地址。我已经复制了libnss_*libresolv库和我认为必要的其他一切。输入相同的设置,但是在我的主机上使用qemuchroot可以工作,但是我试图找出它在我的目标设备上不起作用的地方。

当我运行strace ping google.com时,我得到以下内容:

open("/data/local/target/bin/ping", O_RDONLY) = 3
read(3, "177ELF1112(1314004"..., 4094) = 4094
close(3)                                = 0
execve("/data/local/target/bin/ping", ["ping", "google.com"], [/* 20 vars */]) = 0
brk(0)                                  = 0xb5000
uname({sys="Linux", node="localhost", ...}) = 0
access("/etc/ld.so.nohwcap", F_OK)      = -1 ENOENT (No such file or directory)
mmap2(NULL, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x4001d000
open("/data/local/target/usr/lib/fakechroot/libfakechroot.so", O_RDONLY) = 3
read(3, "177ELF1113(136432004"..., 512) = 512
fstat64(3, {st_mode=S_IFREG|0666, st_size=45540, ...}) = 0
mmap2(NULL, 77628, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0x40026000
mprotect(0x40031000, 28672, PROT_NONE)  = 0
mmap2(0x40038000, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0xa) = 0x40038000
close(3)                                = 0
open("/data/local/target/usr/lib/libfakeroot/libfakeroot-sysv.so", O_RDONLY) = 3
read(3, "177ELF1113(1340'004"..., 512) = 512
fstat64(3, {st_mode=S_IFREG|0666, st_size=29092, ...}) = 0
mmap2(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x4001f000
mmap2(NULL, 60672, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0x40039000
mprotect(0x40040000, 28672, PROT_NONE)  = 0
mmap2(0x40047000, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x6) = 0x40047000
close(3)                                = 0
access("/etc/ld.so.preload", R_OK)      = -1 ENOENT (No such file or directory)
open("tls/v7l/neon/vfp/libc.so.6", O_RDONLY) = -1 ENOENT (No such file or directory)
...
open("/data/local/target/lib/libc.so.6", O_RDONLY) = 3
read(3, "177ELF1113(1374V1004"..., 512) = 512
fstat64(3, {st_mode=S_IFREG|0777, st_size=1209660, ...}) = 0
mmap2(NULL, 1246468, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0x40048000
mprotect(0x4016b000, 32768, PROT_NONE)  = 0
mmap2(0x40173000, 12288, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x123) = 0x40173000
mmap2(0x40176000, 9476, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_ANONYMOUS, -1, 0) = 0x40176000
close(3)                                = 0
open("tls/v7l/neon/vfp/libdl.so.2", O_RDONLY) = -1 ENOENT (No such file or directory)
...
open("/data/local/target/lib/libdl.so.2", O_RDONLY) = 3
read(3, "177ELF1113(1$t004"..., 512) = 512
fstat64(3, {st_mode=S_IFREG|0777, st_size=9808, ...}) = 0
mmap2(NULL, 41136, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0x40179000
mprotect(0x4017b000, 28672, PROT_NONE)  = 0
mmap2(0x40182000, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x1) = 0x40182000
close(3)                                = 0
mmap2(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x40020000
set_tls(0x40020170, 0x40020847, 0x40020848, 0x40020170, 0x40025000) = 0
mprotect(0x40182000, 4096, PROT_READ)   = 0
mprotect(0x40173000, 8192, PROT_READ)   = 0
mprotect(0xb1000, 4096, PROT_READ)      = 0
mprotect(0x40024000, 4096, PROT_READ)   = 0
brk(0)                                  = 0xb5000
brk(0xd6000)                            = 0xd6000
socket(PF_FILE, SOCK_STREAM|SOCK_CLOEXEC|SOCK_NONBLOCK, 0) = 3
connect(3, {sa_family=AF_FILE, path="/var/run/nscd/socket"}, 110) = -1 ENOENT (No such file or directory)
close(3)                                = 0
socket(PF_FILE, SOCK_STREAM|SOCK_CLOEXEC|SOCK_NONBLOCK, 0) = 3
connect(3, {sa_family=AF_FILE, path="/var/run/nscd/socket"}, 110) = -1 ENOENT (No such file or directory)
close(3)                                = 0
open("/etc/nsswitch.conf", O_RDONLY)    = -1 ENOENT (No such file or directory)
open("tls/v7l/neon/vfp/libnss_compat.so.2", O_RDONLY) = -1 ENOENT (No such file or directory)
...
open("/data/local/target/lib/libnss_compat.so.2", O_RDONLY) = 3
read(3, "177ELF1113(1|r004"..., 512) = 512
fstat64(3, {st_mode=S_IFREG|0777, st_size=26480, ...}) = 0
mmap2(NULL, 57952, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0x40184000
mprotect(0x4018a000, 28672, PROT_NONE)  = 0
mmap2(0x40191000, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x5) = 0x40191000
close(3)                                = 0
open("tls/v7l/neon/vfp/libnsl.so.1", O_RDONLY) = -1 ENOENT (No such file or directory)
...
open("/data/local/target/lib/libnsl.so.1", O_RDONLY) = 3
read(3, "177ELF1113(1x/004"..., 512) = 512
fstat64(3, {st_mode=S_IFREG|0777, st_size=75732, ...}) = 0
mmap2(NULL, 116488, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0x40193000
mprotect(0x401a5000, 28672, PROT_NONE)  = 0
mmap2(0x401ac000, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x11) = 0x401ac000
mmap2(0x401ae000, 5896, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_ANONYMOUS, -1, 0) = 0x401ae000
close(3)                                = 0
mprotect(0x401ac000, 4096, PROT_READ)   = 0
mprotect(0x40191000, 4096, PROT_READ)   = 0
open("/etc/nsswitch.conf", O_RDONLY)    = -1 ENOENT (No such file or directory)
open("tls/v7l/neon/vfp/libnss_nis.so.2", O_RDONLY) = -1 ENOENT (No such file or directory)
...
open("/data/local/target/usr/lib/libnss_nis.so.2", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/data/local/target/lib/libnss_nis.so.2", O_RDONLY) = 3
read(3, "177ELF1113(1X30004"..., 512) = 512
fstat64(3, {st_mode=S_IFREG|0777, st_size=38608, ...}) = 0
mmap2(NULL, 70236, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0x401b0000
mprotect(0x401b9000, 28672, PROT_NONE)  = 0
mmap2(0x401c0000, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x8) = 0x401c0000
close(3)                                = 0
open("tls/v7l/neon/vfp/libnss_files.so.2", O_RDONLY) = -1 ENOENT (No such file or directory)
...
open("/data/local/target/lib/libnss_files.so.2", O_RDONLY) = 3
read(3, "177ELF1113(133031004"..., 512) = 512
fstat64(3, {st_mode=S_IFREG|0777, st_size=42688, ...}) = 0
mmap2(NULL, 74492, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0x401c2000
mprotect(0x401cc000, 28672, PROT_NONE)  = 0
mmap2(0x401d3000, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x9) = 0x401d3000
close(3)                                = 0
mprotect(0x401d3000, 4096, PROT_READ)   = 0
mprotect(0x401c0000, 4096, PROT_READ)   = 0
open("/data/local/target/etc/passwd", O_RDONLY|O_CLOEXEC) = 3
fcntl64(3, F_GETFD)                     = 0x1 (flags FD_CLOEXEC)
_llseek(3, 0, [0], SEEK_CUR)            = 0
fstat64(3, {st_mode=S_IFREG|0666, st_size=596, ...}) = 0
mmap2(NULL, 596, PROT_READ, MAP_SHARED, 3, 0) = 0x40021000
_llseek(3, 596, [596], SEEK_SET)        = 0
munmap(0x40021000, 596)                 = 0
close(3)                                = 0
getpid()                                = 9034
socket(PF_NETLINK, SOCK_RAW, 0)         = 3
bind(3, {sa_family=AF_NETLINK, pid=0, groups=00000000}, 12) = 0
getsockname(3, {sa_family=AF_NETLINK, pid=9034, groups=00000000}, [12]) = 0
gettimeofday({1366748508, 414909}, NULL) = 0
sendto(3, "242613\355vQ", 20, 0, {sa_family=AF_NETLINK,     pid=0, groups=00000000}, 12) = 20
recvmsg(3, {msg_name(12)={sa_family=AF_NETLINK, pid=0, groups=00000000}, msg_iov(1)=[{"0242\355vQJ#21020037611011771"..., 4096}], msg_controllen=0, msg_flags=0}, 0) = 108
recvmsg(3, {msg_name(12)={sa_family=AF_NETLINK, pid=0, groups=00000000}, msg_iov(1)=[{"@242\355vQJ#n2002003761241"..., 4096}], msg_controllen=0, msg_flags=0}, 0) = 128
recvmsg(3, {msg_name(12)={sa_family=AF_NETLINK, pid=0, groups=00000000}, msg_iov(1)=[{"2432\355vQJ#1241"..., 4096}], msg_controllen=0, msg_flags=0}, 0) = 20
close(3)                                = 0
open("/etc/resolv.conf", O_RDONLY)      = -1 ENOENT (No such file or directory)
uname({sys="Linux", node="localhost", ...}) = 0
socket(PF_FILE, SOCK_STREAM|SOCK_CLOEXEC|SOCK_NONBLOCK, 0) = 3
connect(3, {sa_family=AF_FILE, path="/var/run/nscd/socket"}, 110) = -1 ENOENT (No such file or directory)
close(3)                                = 0
socket(PF_FILE, SOCK_STREAM|SOCK_CLOEXEC|SOCK_NONBLOCK, 0) = 3
connect(3, {sa_family=AF_FILE, path="/var/run/nscd/socket"}, 110) = -1 ENOENT (No such file or directory)
close(3)                                = 0
open("/etc/nsswitch.conf", O_RDONLY)    = -1 ENOENT (No such file or directory)
open("tls/v7l/neon/vfp/libnss_dns.so.2", O_RDONLY) = -1 ENOENT (No such file or directory)
...
open("/data/local/target/lib/libnss_dns.so.2", O_RDONLY) = 3
read(3, "177ELF1113(1000v004"..., 512) = 512
fstat64(3, {st_mode=S_IFREG|0777, st_size=18040, ...}) = 0
mmap2(NULL, 49316, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0x401d5000
mprotect(0x401d9000, 28672, PROT_NONE)  = 0
mmap2(0x401e0000, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x3) = 0x401e0000
close(3)                                = 0
open("tls/v7l/neon/vfp/libresolv.so.2", O_RDONLY) = -1 ENOENT (No such file or directory)
...
open("/data/local/target/lib/libresolv.so.2", O_RDONLY) = 3
read(3, "177ELF1113(1H$004"..., 512) = 512
fstat64(3, {st_mode=S_IFREG|0777, st_size=71524, ...}) = 0
mmap2(NULL, 79772, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0x401e2000
mmap2(0x401f2000, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x10) = 0x401f2000
mmap2(0x401f4000, 6044, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_ANONYMOUS, -1, 0) = 0x401f4000
close(3)                                = 0
mprotect(0x401f2000, 4096, PROT_READ)   = 0
mprotect(0x401e0000, 4096, PROT_READ)   = 0
open("/etc/host.conf", O_RDONLY)        = -1 ENOENT (No such file or directory)
stat64("/etc/resolv.conf", 0xbed0eee8)  = -1 ENOENT (No such file or directory)
gettimeofday({1366748508, 437074}, NULL) = 0
socket(PF_INET, SOCK_DGRAM|SOCK_NONBLOCK, IPPROTO_IP) = 3
connect(3, {sa_family=AF_INET, sin_port=htons(53), sin_addr=inet_addr("127.0.0.1")}, 16) = 0
gettimeofday({1366748508, 438028}, NULL) = 0
poll([{fd=3, events=POLLOUT}], 1, 0)    = 1 ([{fd=3, revents=POLLOUT}])
send(3, "23432116google3com11", 28, MSG_NOSIGNAL) = 28
poll([{fd=3, events=POLLIN}], 1, 5000)  = 1 ([{fd=3, revents=POLLERR}])
close(3)                                = 0
socket(PF_INET, SOCK_DGRAM|SOCK_NONBLOCK, IPPROTO_IP) = 3
connect(3, {sa_family=AF_INET, sin_port=htons(53), sin_addr=inet_addr("127.0.0.1")}, 16) = 0
gettimeofday({1366748508, 440124}, NULL) = 0
poll([{fd=3, events=POLLOUT}], 1, 0)    = 1 ([{fd=3, revents=POLLOUT}])
send(3, "23432116google3com11", 28, MSG_NOSIGNAL) = 28
poll([{fd=3, events=POLLIN}], 1, 5000)  = 1 ([{fd=3, revents=POLLERR}])
close(3)                                = 0
gettimeofday({1366748508, 441638}, NULL) = 0
socket(PF_INET, SOCK_DGRAM|SOCK_NONBLOCK, IPPROTO_IP) = 3
connect(3, {sa_family=AF_INET, sin_port=htons(53), sin_addr=inet_addr("127.0.0.1")}, 16) = 0
gettimeofday({1366748508, 442345}, NULL) = 0
poll([{fd=3, events=POLLOUT}], 1, 0)    = 1 ([{fd=3, revents=POLLOUT}])
send(3, "302373116google3com11", 28, MSG_NOSIGNAL) = 28
poll([{fd=3, events=POLLIN}], 1, 5000)  = 1 ([{fd=3, revents=POLLERR}])
close(3)                                = 0
socket(PF_INET, SOCK_DGRAM|SOCK_NONBLOCK, IPPROTO_IP) = 3
connect(3, {sa_family=AF_INET, sin_port=htons(53), sin_addr=inet_addr("127.0.0.1")}, 16) = 0
gettimeofday({1366748508, 444280}, NULL) = 0
poll([{fd=3, events=POLLOUT}], 1, 0)    = 1 ([{fd=3, revents=POLLOUT}])
send(3, "302373116google3com11", 28, MSG_NOSIGNAL) = 28
poll([{fd=3, events=POLLIN}], 1, 5000)  = 1 ([{fd=3, revents=POLLERR}])
close(3)                                = 0
open("/data/local/target/etc/hosts", O_RDONLY|O_CLOEXEC) = 3
fcntl64(3, F_GETFD)                     = 0x1 (flags FD_CLOEXEC)
fstat64(3, {st_mode=S_IFREG|0666, st_size=40, ...}) = 0
mmap2(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x40021000
read(3, "127.0.0.1tlocalhostn127.0.1.1tbu"..., 4096) = 40
read(3, "", 4096)                       = 0
close(3)                                = 0
munmap(0x40021000, 4096)                = 0
write(2, "ping: bad address 'google.com'n", 31) = 31
exit_group(1)                           = ?

很多都是对的。它知道在搜索可执行文件和库时将/data/local/target添加到路径中。您可以看到它找到了各种libnss_*库,并且它发现主机文件不只是在/etc/hosts,但是您认为它为什么没有在nsswitch.confresolv.conf的正确位置查找呢?这似乎是一个fakechroot问题或我如何使用它的问题。

看起来在其他库/可执行文件中使用fopen可以被指向libfakechroot的LD_PRELOAD拦截,但不能从eglibc内部调用fopen。您必须手动编辑eglibc源代码并构建它。看起来他们做得很好,让这件事变得容易。

相关内容

  • 没有找到相关文章

最新更新