Forums Neueste Beiträge
 

chroot: failed to run command `$command': No such file or directory

18/07/2011 - 21:03 von Helmut Schneider | Report spam
Hi,

ich möchte ein Programm (hier freshclam) chroot'en. Ich habe ein
Script, welches per ldd und cpio alles in die chroot Umgebung packt
(das binary und alle .so, von denen das binary abhàngt). Danach starte
ich freshclam:

root@mail:~# chroot --userspec=amavis:amavis /tmp/ /usr/bin/freshclam
chroot: invalid user
root@mail:~# id amavis
uid5(amavis) gid4(amavis) groups4(amavis)
root@mail:~# chroot /tmp/ /usr/bin/freshclam
chroot: failed to run command `/usr/bin/freshclam': No such file or
directory
root@mail:~#

Warum?

root@mail:~# ls -la /tmp/
total 16
drwxrwxrwt 4 root root 4096 Jul 18 20:48 .
drwxr-xr-x 21 root amavis 4096 Jul 18 18:52 ..
drwxr-xr-x 3 root root 4096 Jul 18 20:48 lib
[...]
drwxr-xr-x 4 root root 4096 Jul 18 20:48 usr
root@mail:~# ls -la /tmp/usr/bin/
total 140
drwxr-xr-x 2 root root 4096 Jul 18 20:48 .
drwxr-xr-x 4 root root 4096 Jul 18 20:48 ..
-rwxr-xr-x 1 root root 133032 Jul 18 20:48 freshclam
root@mail:~# for LIB in $(ldd /tmp/usr/bin/freshclam | grep '=> /' |
awk '{print $3}'); do ls /tmp/$LIB; done
/tmp/usr/lib/libclamav.so.6
/tmp/lib/i386-linux-gnu/libz.so.1
/tmp/lib/i386-linux-gnu/libresolv.so.2
/tmp/lib/i386-linux-gnu/libpthread.so.0
/tmp/lib/i386-linux-gnu/libc.so.6
/tmp/usr/lib/libltdl.so.7
/tmp/usr/lib/i386-linux-gnu/libstdc++.so.6
/tmp/lib/libbz2.so.1.0
/tmp/usr/lib/libtommath.so.0
/tmp/lib/i386-linux-gnu/libm.so.6
/tmp/lib/i386-linux-gnu/libdl.so.2
/tmp/lib/i386-linux-gnu/libgcc_s.so.1
root@mail:~#

root@mail:~# strace chroot /tmp /usr/bin/freshclam
execve("/usr/sbin/chroot", ["chroot", "/tmp", "/usr/bin/freshclam"],
[/* 19 vars */]) = 0
brk(0) = 0x969c000
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) = 0xb7871000
access("/etc/ld.so.preload", R_OK) = -1 ENOENT (No such file or
directory)
open("/etc/ld.so.cache", O_RDONLY) = 3
fstat64(3, {st_mode=S_IFREG|0644, st_size699, ...}) = 0
mmap2(NULL, 17699, PROT_READ, MAP_PRIVATE, 3, 0) = 0xb786c000
close(3) = 0
access("/etc/ld.so.nohwcap", F_OK) = -1 ENOENT (No such file or
directory)
open("/lib/i386-linux-gnu/libc.so.6", O_RDONLY) = 3
read(3,
"\177ELF\1\1\1\0\0\0\0\0\0\0\0\0\3\0\3\0\1\0\0\0\220o\1\0004\0\0\0"...,
512) = 512
fstat64(3, {st_mode=S_IFREG|0755, st_size34180, ...}) = 0
mmap2(NULL, 1444360, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3,
0) = 0x7ad000
mprotect(0x907000, 4096, PROT_NONE) = 0
mmap2(0x908000, 12288, PROT_READ|PROT_WRITE,
MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x15a) = 0x9080 00
mmap2(0x90b000, 10760, PROT_READ|PROT_WRITE,
MAP_PRIVATE|MAP_FIXED|MAP_ANONYMOUS, -1, 0) = 0x90b000
close(3) = 0
mmap2(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1,
0) = 0xb786b000
set_thread_area({entry_number:-1 -> 6, base_addr:0xb786b8d0,
limit:1048575, seg_32bit:1, contents:0, read_exec_only:0,
limit_in_pages:1, seg_not_present:0, useable:1}) = 0
mprotect(0x908000, 8192, PROT_READ) = 0
mprotect(0x804e000, 4096, PROT_READ) = 0
mprotect(0xc04000, 4096, PROT_READ) = 0
munmap(0xb786c000, 17699) = 0
brk(0) = 0x969c000
brk(0x96bd000) = 0x96bd000
chroot("/tmp") = 0
chdir("/") = 0
execve("/usr/bin/freshclam", ["/usr/bin/freshclam"], [/* 19 vars */]) -1 ENOENT (No such file or directory)
write(2, "chroot: ", 8chroot: ) = 8
write(2, "failed to run command `/usr/bin/"..., 42failed to run command
`/usr/bin/freshclam') = 42
write(2, ": No such file or directory", 27: No such file or directory)
= 27
write(2, "", 1
) = 1
close(1) = 0
close(2) = 0
exit_group(127) = ?
root@mail:~#

Danke und Gruß, Helmut
 

Lesen sie die antworten

#1 Burkhard Ott
18/07/2011 - 21:11 | Warnen spam
On Mon, 18 Jul 2011 19:03:40 +0000, Helmut Schneider wrote:


:~# chroot --userspec=amavis:amavis /tmp/ /usr/bin/freshclam
chroot: invalid user
:~# id amavis
uid5(amavis) gid4(amavis) groups4(amavis) :~# chroot
/tmp/ /usr/bin/freshclam chroot: failed to run command
`/usr/bin/freshclam': No such file or directory
:~#

Warum?



Sieht so aus als ob Du das binary ncht im chroot hast (/tmp/usr/bin/
freshclam)

:~# ls -la /tmp/
total 16
drwxrwxrwt 4 root root 4096 Jul 18 20:48 . drwxr-xr-x 21 root amavis
4096 Jul 18 18:52 .. drwxr-xr-x 3 root root 4096 Jul 18 20:48 lib
[...]
drwxr-xr-x 4 root root 4096 Jul 18 20:48 usr :~# ls -la
/tmp/usr/bin/
total 140
drwxr-xr-x 2 root root 4096 Jul 18 20:48 . drwxr-xr-x 4 root root
4096 Jul 18 20:48 .. -rwxr-xr-x 1 root root 133032 Jul 18 20:48
freshclam :~# for LIB in $(ldd /tmp/usr/bin/freshclam | grep
'=> /' | awk '{print $3}'); do ls /tmp/$LIB; done
/tmp/usr/lib/libclamav.so.6
/tmp/lib/i386-linux-gnu/libz.so.1
/tmp/lib/i386-linux-gnu/libresolv.so.2
/tmp/lib/i386-linux-gnu/libpthread.so.0
/tmp/lib/i386-linux-gnu/libc.so.6
/tmp/usr/lib/libltdl.so.7
/tmp/usr/lib/i386-linux-gnu/libstdc++.so.6 /tmp/lib/libbz2.so.1.0
/tmp/usr/lib/libtommath.so.0
/tmp/lib/i386-linux-gnu/libm.so.6
/tmp/lib/i386-linux-gnu/libdl.so.2
/tmp/lib/i386-linux-gnu/libgcc_s.so.1 :~#




Du wirst sicher auch /etc/password bzw. den Usereintrag als auch root
von /etc/password nach /tmp/etc/passwd kopieren wollen.

cheers

Ähnliche fragen