Programming Perl

Programming PerlSearch this book
Previous: 3.2.16 chrChapter 3
Next: 3.2.18 close

3.2.17 chroot


This function does the same operation as the chroot system call - see chroot(2). If successful, FILENAME becomes the new root directory for the current process - the starting point for pathnames beginning with "/". This directory is inherited across exec calls and by all subprocesses. There is no way to undo a chroot. Only the superuser can use this function. Here's some code that approximates what many FTP servers do:

chroot +(getpwnam('ftp'))[7]
    or die "Can't do anonymous ftp: $!\n";

Previous: 3.2.16 chrProgramming PerlNext: 3.2.18 close
3.2.16 chrBook Index3.2.18 close