Skip to contentSkip to conversation

chroot bug if arg not absolute path?

DISCUSSION Dan Kegel 1 participant 2 messages Jul 4, 2003

lore
Share & tools
lore

Dan Kegel

author
#0 lore raw

On my Debian 3.0 system running the 2.4.18 kernel, I ran into a funny problem: /usr/sbin/chroot, or the chroot() system call followed by the chdir() system call, seem to work if their argument is not an absolute path; that is, scandir("/bin") can see the files in the jail, but execlp("/bin/sh", "/bin/sh", 0) fails to find the /bin/sh in the jail, and sets errno to ENOENT.

Is this a bug, or do I have a screw loose behind the wheel?
- Dan

Signature · 3 lines
Dan Kegel
http://www.kegel.com
http://counter.li.org/cgi-bin/runscript/display-person.cgi?user=78045
author
#1 lore raw
Quoted 9 lines · Dan Kegel

On my Debian 3.0 system running the 2.4.18 kernel, I ran into a funny problem: /usr/sbin/chroot, or the chroot() system call followed by the chdir() system call, seem to work if their argument is not an absolute path; that is, scandir("/bin") can see the files in the jail, but execlp("/bin/sh", "/bin/sh", 0) fails to find the /bin/sh in the jail, and sets errno to ENOENT.

Is this a bug, or do I have a screw loose behind the wheel?

The latter. Ignore me.
- Dan

Signature · 3 lines
Dan Kegel
http://www.kegel.com
http://counter.li.org/cgi-bin/runscript/display-person.cgi?user=78045