1

buildrootを使用してrootfsを作成しましたが、 glibcでcrosstool-ngツール チェーンを使用しています。これにより、必要な最小限のファイル セットが表示されました。次に、すべてのライブラリを、squeeze の.debパッケージから直接取得したものに置き換えました。次に、ミックスにandを追加しました(これも.debパッケージから)。、、およびファイルも好みに合わせて変更しました。これを私のデバイスにアップロードした後、多くのことが機能しています。 正しい場所に連れて行ってくれます。 ルートを返します。しかし、DNS に関連するものは何も機能していません。たとえば、不正なアドレスを返します。私はコピーしましたarmelfakerootfakechrootresolv.confhostsnsswitch.confcd /whoamiping google.comlibnss_*libresolv のライブラリ、その他すべて必要だと思います。同じセットアップに入りますが、ホスト マシンでqemuchrootを使用すると機能しますが、ターゲット デバイスで何が機能していないのかを把握しようとしています。

実行するstrace ping google.comと、次のようになります。

open("/data/local/target/bin/ping", O_RDONLY) = 3
read(3, "\177ELF\1\1\1\0\0\0\0\0\0\0\0\0\2\0(\0\1\0\0\0\0\314\0\0004\0\0\0"..., 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, "\177ELF\1\1\1\0\0\0\0\0\0\0\0\0\3\0(\0\1\0\0\0\364\32\0\0004\0\0\0"..., 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, "\177ELF\1\1\1\0\0\0\0\0\0\0\0\0\3\0(\0\1\0\0\0\340'\0\0004\0\0\0"..., 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, "\177ELF\1\1\1\0\0\0\0\0\0\0\0\0\3\0(\0\1\0\0\0\374V\1\0004\0\0\0"..., 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, "\177ELF\1\1\1\0\0\0\0\0\0\0\0\0\3\0(\0\1\0\0\0$\t\0\0004\0\0\0"..., 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, "\177ELF\1\1\1\0\0\0\0\0\0\0\0\0\3\0(\0\1\0\0\0|\r\0\0004\0\0\0"..., 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, "\177ELF\1\1\1\0\0\0\0\0\0\0\0\0\3\0(\0\1\0\0\0x/\0\0004\0\0\0"..., 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, "\177ELF\1\1\1\0\0\0\0\0\0\0\0\0\3\0(\0\1\0\0\0X\30\0\0004\0\0\0"..., 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, "\177ELF\1\1\1\0\0\0\0\0\0\0\0\0\3\0(\0\1\0\0\0\330\31\0\0004\0\0\0"..., 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, "\24\0\0\0\26\0\1\3\\\355vQ\0\0\0\0\0\0\0\0", 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)=[{"0\0\0\0\24\0\2\0\\\355vQJ#\0\0\2\10\200\376\1\0\0\0\10\0\1\0\177\0\0\1"..., 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)=[{"@\0\0\0\24\0\2\0\\\355vQJ#\0\0\n\200\200\376\1\0\0\0\24\0\1\0\0\0\0\0"..., 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)=[{"\24\0\0\0\3\0\2\0\\\355vQJ#\0\0\0\0\0\0\1\0\0\0\24\0\1\0\0\0\0\0"..., 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, "\177ELF\1\1\1\0\0\0\0\0\0\0\0\0\3\0(\0\1\0\0\0000\v\0\0004\0\0\0"..., 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, "\177ELF\1\1\1\0\0\0\0\0\0\0\0\0\3\0(\0\1\0\0\0H$\0\0004\0\0\0"..., 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, "\234\32\1\0\0\1\0\0\0\0\0\0\6google\3com\0\0\1\0\1", 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, "\234\32\1\0\0\1\0\0\0\0\0\0\6google\3com\0\0\1\0\1", 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, "\302\373\1\0\0\1\0\0\0\0\0\0\6google\3com\0\0\1\0\1", 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, "\302\373\1\0\0\1\0\0\0\0\0\0\6google\3com\0\0\1\0\1", 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.1\tlocalhost\n127.0.1.1\tbu"..., 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私がそれをどのように使用しているかの問題または問題のようです。

4

1 に答える 1

0

他のライブラリ/実行可能ファイルでの fopen の使用は、libfakechroot を指す LD_PRELOAD の使用によって傍受できるように見えますが、eglibc 自体から呼び出された fopen ではありません。eglibc ソースを手動で編集してビルドする必要があります。彼らはこれを簡単にするために良い仕事をしたようです.

これはテスト済みで動作します。

于 2013-05-14T16:53:19.800 に答える