Exit from os.chroot()

Wolfgang Draxinger wdraxinger at darkstargames.de
Wed Jun 4 11:08:04 EDT 2008


support.intranet wrote:

> Hello! I'm writing a small script and I need to call the
> os.chroot function. The problem is, a few lines below I need to
> call a program in /usr/bin. Is there a way to exit from the
> chroot, or to limit the chroot to a single function or thread?
> Thanks in advance

No, chroot applies to the whole process and once applied it can't
be reverted. Otherwise the whole idea of chroot being a FS jail
would not work.

So you need some programs in your chroot: Then put a directory
usr/bin into the chroot directory and bind the system's /usr/bin
there:

mount --bind /usr/bin $chroot/usr/bin

The same has to be done with all library stuff. Another option
would be to place a statically linked busybox and it's
subprogram links into the chroot

Wolfgang Draxinger
-- 
E-Mail address works, Jabber: hexarith at jabber.org, ICQ: 134682867




More information about the Python-list mailing list