Bonjour,

J'ai un petit probl�me avec chroot :
par exemple :

$ chroot /var/cvs/ /bin/bash
chroot: cannot execute /bin/bash: No such file or directory

donc j'ai fait du google : probl�me d�j� vu mais j'ai pas trouv� de
solutions...

donc, sans me d�filer, j'ai fait un strace :

___
execve("/usr/sbin/chroot", ["chroot", "/var/cvs", "/bin/bash"], [/* 17 vars 
*/]) = 0
uname({sys="Linux", node="pascalou", ...}) = 0
brk(0)                                  = 0x804b444
old_mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 
0x40015000open("/etc/ld.so.preload", O_RDONLY)    = 3
fstat64(0x3, 0xbffff7b4)                = -1 ENOSYS (Function not implemented)
fstat(3, {st_mode=S_IFREG|0644, st_size=0, ...}) = 0
close(3)                                = 0
open("/etc/ld.so.cache", O_RDONLY)      = 3
fstat(3, {st_mode=S_IFREG|0644, st_size=43267, ...}) = 0
old_mmap(NULL, 43267, PROT_READ, MAP_PRIVATE, 3, 0) = 0x40016000
close(3)                                = 0
open("/lib/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\250\323"..., 1024) = 
1024
fstat(3, {st_mode=S_IFREG|0755, st_size=1104456, ...}) = 0
old_mmap(NULL, 1120932, PROT_READ|PROT_EXEC, MAP_PRIVATE, 3, 0) = 0x40021000
mprotect(0x40129000, 39588, PROT_NONE)  = 0
old_mmap(0x40129000, 24576, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED, 3, 
0x107000) = 0x40129000
old_mmap(0x4012f000, 15012, PROT_READ|PROT_WRITE, 
MAP_PRIVATE|MAP_FIXED|MAP_ANONYMOUS, -1, 0) = 0x4012f000
close(3)                                = 0
munmap(0x40016000, 43267)               = 0
getpid()                                = 8556
brk(0)                                  = 0x804b444
brk(0x804b46c)                          = 0x804b46c
brk(0x804c000)                          = 0x804c000
chroot("./")                            = 0
chdir("/")                              = 0
execve("/bin/bash", ["/bin/bash", "-i"], [/* 17 vars */]) = -1 ENOENT (No such 
file or directory)
write(2, "chroot: ", 8chroot: )                 = 8
write(2, "cannot execute /bin/bash", 24cannot execute /bin/bash) = 24
write(2, ": No such file or directory", 27: No such file or directory) = 27
write(2, "\n", 1
)                       = 1
_exit(1)                                = ?
___

(mon /bin/bash existe).

je tourne en testing avec un noyau 2.2.17.
(libc6 du paquet debian). (je pense pas que chroot soit buggu�). 

Pour tout vous dire, je voudrais faire du cvs-ssh-chroot�:

et pour ce faire je lance un petit fichier C :

___
        uid = getuid();

        res = chdir(BASE);
        if ( res ) exit(1);
        printf("\nchdir ok\n");

        res = chroot(BASE);
        if ( res ) exit(2);
        printf("\nchroot ok\n");

        res = setuid(uid);
        if ( res ) exit(4);
        printf("\nuid ok\n");

        execl("/bin/cvs", "cvs",
        "server",
        NULL);
___

Bien s�r, /bin/cvs existe, meme dans le nouveau chroot.
Et si je fait un strace de ce fichier compil� :

___
execve("./cvs", ["./cvs"], [/* 17 vars */]) = 0
uname({sys="Linux", node="pascalou", ...}) = 0
brk(0)                                  = 0x804998c
old_mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 
0x40015000open("/etc/ld.so.preload", O_RDONLY)    = 3
fstat64(0x3, 0xbffff7c4)                = -1 ENOSYS (Function not implemented)
fstat(3, {st_mode=S_IFREG|0644, st_size=0, ...}) = 0
close(3)                                = 0
open("/etc/ld.so.cache", O_RDONLY)      = 3
fstat(3, {st_mode=S_IFREG|0644, st_size=43267, ...}) = 0
old_mmap(NULL, 43267, PROT_READ, MAP_PRIVATE, 3, 0) = 0x40016000
close(3)                                = 0
open("/lib/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\250\323"..., 1024) = 
1024
fstat(3, {st_mode=S_IFREG|0755, st_size=1104456, ...}) = 0
old_mmap(NULL, 1120932, PROT_READ|PROT_EXEC, MAP_PRIVATE, 3, 0) = 0x40021000
mprotect(0x40129000, 39588, PROT_NONE)  = 0
old_mmap(0x40129000, 24576, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED, 3, 
0x107000) = 0x40129000
old_mmap(0x4012f000, 15012, PROT_READ|PROT_WRITE, 
MAP_PRIVATE|MAP_FIXED|MAP_ANONYMOUS, -1, 0) = 0x4012f000
close(3)                                = 0
munmap(0x40016000, 43267)               = 0
getpid()                                = 8581
open("/run-cvs.debug", O_RDONLY)        = 3
close(3)                                = 0
SYS_199(0x4012db4c, 0, 0x4012e860, 0x4012c2d0, 0xbffffda4) = -1 ENOSYS 
(Function not implemented)
getuid()                                = 0
chdir("/var/cvs/yyyy/chrooted-cvs")     = 0
fstat64(0x1, 0xbffff5bc)                = -1 ENOSYS (Function not implemented)
fstat(1, {st_mode=S_IFCHR|0620, st_rdev=makedev(136, 2), ...}) = 0
old_mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 
0x40016000ioctl(1, TCGETS, {B38400 opost isig icanon echo ...}) = 0
write(1, "\n", 1
)                       = 1
chroot("/var/cvs/yyyy/chrooted-cvs")    = 0
setuid(0)                               = 0
execve("/bin/strace", ["-tc", "-f", "/tmp/strace.out", "/bin/cvs", "cvs", 
"server"], [/* 17 vars */]) = -1 ENOENT (No such file or directory)
munmap(0x40016000, 4096)                = 0
_exit(3)                                = ?
___

Le chroot a l'air d'avoir march�, mail il ne me lance pas ma la derni�re
commande.  Le chemin est encore bon ! 

Si le fstat64 qui bugue me d�range, il faut peut-etre que je recompile la
glibc, du moins la librairie io avec l'option  -D_FILE_OFFSET_BITS=64 comme le
dit son auteur :

"i've written stat64, lstat64, fstat64, getdents64, mmap2 and fcntl64
syscalls.  With a rebuilt glibc, these calls work fine with userspace
compiled with -D_FILE_OFFSET_BITS=64, as per the LFS standard."
[EMAIL PROTECTED] (Matthew Wilcox)

mais avant de faire ce genre de connerie, j'aimerais avoir un avis plus �clair�
sur ce bug qui m'a d�j� bouff� 3 jours.

merci.

A+

ps: j'ai le pr�sentiment que c'est juste un petit truc.
ps2: ca ne marche pas sur toutes mes stations h�t�rog�nes tournant sur testing.
-- 
Pascal Pucci : [EMAIL PROTECTED]
Recommander un site � ses amis : http://www.BeeTell.com
Participer � la promotion du logiciel libre : http://www.linuxpien.org
http://www.pascalou.org, sur le mobil : [EMAIL PROTECTED]


Répondre à