This is the mail archive of the
libc-help@sourceware.org
mailing list for the glibc project.
can I use chroot() multiple times in one program
- From: Wu Zhou <woodzltc at gmail dot com>
- To: libc-help at sourceware dot org
- Date: Tue, 12 Jan 2010 10:51:14 -0500
- Subject: can I use chroot() multiple times in one program
Hello all,
I have a question about the usage of chroot(). Could I do something like this:
chroot("/chroot");
do_something();
chroot("/"); // want the root directory back to "/"
do_something();
chroot("/chroot");
do_something();
I had a try, after the second chroot("/"), I use system() to call a
python script in the original root directoy, it reports that
sh: /tmp/python-script: not found
But in fact, I can see this script in the original root directory:
# ls -l -l /tmp/python-script
-rwxr-xr-x 1 root root 4419 Jan 12 10:51 /tmp/python-script
The second chroot session is like this:
chroot("/");
system("/tmp/python-script");
Anyone can hint me what is the problem?
Thanks and Best Regards
Wu Zhou