This is the mail archive of the libc-help@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]