The idea behind chroot is fairly simple. When you run BIND (or any other process) in a chroot jail, the process is simply unable to see any part of the filesystem outside the jail. For example, in this document, we'll set BIND up to run chrooted to the directory /chroot/named. Well, to BIND, the contents of this directory will appear to be /, the root directory. Nothing outside this directory will be accessible to it. You've probably encounted a chroot jail before, if you've ever ftped into a public system.
ldd is a tool handy for determing what library resources your program will need in order to execute. ldd stands for 'list dynamic dependencies'. Running ldd followed by the path and filename of the daemon you are chrooting will give you a list of libraries you must plan to copy over to the jail.
A note on dynamic libraries: If you have access to the sources for the program you are chrooting, you may wish to compile it with static libraries. This will prevent you from having to copy over libraries. If you use an operating system whose manufacturer updates the libraries frequently, however, you may wish to remain dynamic.
But we're not done yet. Our popper is expecting the mail to be in /var/mail. When it's chrooted, the path / is /var/mail...so when it tries to access /var/mail it will get a file not found! How do we circumvent this problem? We need to symlink /var/mail/var/mail to /var/mail which is, relatively speaking, / ...
Now when our chrooted popper goes to access /var/mail, it'll be pointed to /, which is the real /var/mail!
Our final products should look like:
Sun RPCBIND
<br/><br/>drwxr-xr-x 7 root other 512 Aug 118:31 ./<br/>drwxr-xr-x 34 root sys 512 Aug 118:07 ../<br/>drwxr-xr-x 2 root other 512 Aug 118:16 dev/<br/>drwxr-xr-x 2 root other 512 Aug 118:10 etc/<br/>drwxr-xr-x 2 root other 512 Aug 118:31 tmp/<br/>drwxr-xr-x 6 root other 512 Jul 2815:55 usr/<br/>drwxr-xr-x 3 root other 512 Aug 118:19var/<br/>
Eudora Qpopper
<br/><br/>drwxrwxrwt 7 root mail512 Oct 1819:36 ./<br/>drwxr-xr-x 34 root sys 512 Aug 118:07 ../<br/>drwxr-xr-x 2 root other 512 Jul 2913:33 dev/<br/>drwxr-xr-x 2 root other 512 Jul 2816:18 etc/<br/><br/> - Some mailboxes mixed in here -<br/><br/>drwxr-xr-x 6 root other 512 Jul 2815:55 usr/<br/>drwxr-xr-x 2 root other 512 Aug 118:06var/<br/>
ldd is a tool handy for determing what library resources your program will need in order to execute. ldd stands for 'list dynamic dependencies'. Running ldd followed by the path and filename of the daemon you are chrooting will give you a list of libraries you must plan to copy over to the jail.
A note on dynamic libraries: If you have access to the sources for the program you are chrooting, you may wish to compile it with static libraries. This will prevent you from having to copy over libraries. If you use an operating system whose manufacturer updates the libraries frequently, however, you may wish to remain dynamic.
But we're not done yet. Our popper is expecting the mail to be in /var/mail. When it's chrooted, the path / is /var/mail...so when it tries to access /var/mail it will get a file not found! How do we circumvent this problem? We need to symlink /var/mail/var/mail to /var/mail which is, relatively speaking, / ...
Now when our chrooted popper goes to access /var/mail, it'll be pointed to /, which is the real /var/mail!
Our final products should look like:
Sun RPCBIND
<br/><br/>drwxr-xr-x 7 root other 512 Aug 118:31 ./<br/>drwxr-xr-x 34 root sys 512 Aug 118:07 ../<br/>drwxr-xr-x 2 root other 512 Aug 118:16 dev/<br/>drwxr-xr-x 2 root other 512 Aug 118:10 etc/<br/>drwxr-xr-x 2 root other 512 Aug 118:31 tmp/<br/>drwxr-xr-x 6 root other 512 Jul 2815:55 usr/<br/>drwxr-xr-x 3 root other 512 Aug 118:19var/<br/>
Eudora Qpopper
<br/><br/>drwxrwxrwt 7 root mail512 Oct 1819:36 ./<br/>drwxr-xr-x 34 root sys 512 Aug 118:07 ../<br/>drwxr-xr-x 2 root other 512 Jul 2913:33 dev/<br/>drwxr-xr-x 2 root other 512 Jul 2816:18 etc/<br/><br/> - Some mailboxes mixed in here -<br/><br/>drwxr-xr-x 6 root other 512 Jul 2815:55 usr/<br/>drwxr-xr-x 2 root other 512 Aug 118:06var/<br/>