I have been trying to overcome the problem of not being able to send mail or running programs from PHP in a chrooted environment.
My set up:
Linux 2.2.14
Apache 1.3.14
php-4.0.3pl1
PHP4 was compiled with the following params:
./configure --disable-debug \
--enable-track-vars \
--with-apache=../apache_1.3.14
safe_mode = off
sendmail_path = /usr/sbin/sendmail -t -i
Apart from the prints and phpinfo(), the following snippet of PHP program produces NOTHING at all.
$status = mail($recipient, $subject, $message, $headers);
print "Mail Status = " . $status;
print $status ? "OK<br>" : "Failed<br>"; // Always show "Failed"
print "Doing chdir and system<br>";
chdir("/usr/local"); system("ls"); // Returns nothing
print "Execing perl<br>";
exec('jhgjgjhgjhgjhg'); // Should generate an error but don't
print exec('/usr/bin/perl -h') . "<br>"; // Returns nothing
phpinfo(); // This is fine
It is obvious that PHP is not executing any programs. Our chroot environment only have the following programs (they all work fine
in chroot otherwise):
perl
gzip
sendmail
Do I need a shell to run sendmail and other programs within PHP? Any help
as to why I couldn't run any program in PHP within a chroot environment is greatly appreciated.
Regards,
Kwong Li
London, UK