I believe /usr/local/cpanel/bin/chroothttpd was an attempt to do chroot but never worked on.
The script at /usr/local/cpanel/bin/chroothttpd will not work on its own... it is broken in many ways.
I do not believe that I can post the modified working file for the public (copyright issues?), so here are some sections that may need to be updated:
Note addition of /etc/vfilters
Code:
@COPIES=("/lib","/usr/lib","/usr/sbin","/usr/share","/usr/bin","/usr/X11R6",
"/usr/kerberos","/usr/man","/var/lib","/dev","/bin","/etc/vfilters");
Note addition of: /usr/share/ssl/
Code:
@FSS =
("/usr/local","/var/log","/var/spool","/var/run","/tmp","/usr/share/ssl/","$homedir");
# Note addition of eximmailtrap
Code:
@FILES=("exim.pl","antivirus.exim","exim.conf","eximmailtrap","services","ld.so.cache","man.config",
"termcap","inputrc","DIR_COLORS","userdomains","domainips","localdomains",
"passwd","group",
"bashrc","profile","host.conf","ld.so.conf","nsswitch.conf","resolv.conf");
And then for good measure at the end but BEFORE "if ($noexec) { exit; }" (note entire block added in the event we have to include more files from /var/cpanel/ later):
Code:
mkdir("/home/virthttpdfs/var/cpanel",0755);
# files to allow access to in cpanel
@FILES=("cpanel.config");
foreach my $file (@FILES) {
next if (! -e "/var/cpanel/$file");
system("cp","-fa","/var/cpanel/$file","/home/virthttpdfs/var/cpanel/$file");
}
So make modifications according to changes above. Other stuff may break depending on your system configuration (you may need to add stuff where needed to allow access to certain config files, etc). I believe this breaks formmail and it may break other CGIs (I do not know).
You can try it once by running it:
Code:
/usr/local/cpanel/bin/chroothttpd
It could take a while for it to build everything. It will build to /home/virthttpdfs/ <-- make sure you do not mess with this folder.
In order to have this script work everytime apache is started do:
... and then restarting apache.
Likewise, you can disable it later by doing:
... and then restarting apache
When you are done making modifications to script
Prevent cPanel from modifying file:
Code:
chattr +i /usr/local/cpanel/bin/chroothttpd
And if you need to modify file in future (don't forget to run above again after):
Code:
chattr -i /usr/local/cpanel/bin/chroothttpd
You may want to copy the modifications to a safe place just to be sure:
Code:
cp /usr/local/cpanel/bin/chroothttpd /root/
Other things that may trip you up that you may not think of:
PHP extensions... are they accessible? Zend? eAccelerator?
These common locations work with modified script:
/usr/lib/php/extensions/.../
/usr/local/lib/Zend/...
Also, some apache modules may need access to places (mod_bandwidth perhaps?).
What are benefits
- More secure.
- No need to run phpsuexec crap or similar (hopefully) and happier customers.
- No need to run safe mode garbage and happier customers.
What are disadvantages
- Higher resource consumption?
- More difficult to track resource usage compared to phpsuexec.
- Not officially support by cPanel
- Possibility of broken CGI scripts.