I actually wanted to call php's mail function which I could not get to work, I
think I have tracked to problem down to exec not working
the details follow using a test web page datetest.php



newweb:/var/www/htdocs/web # cat datetest.php
cat datetest.php
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">

<HTML>
<HEAD>
<title>Date Test</title>
</HEAD>
<p>
  <?php
     ini_set('display_errors', 'On');
     error_reporting(E_ALL | E_STRICT);
     if(function_exists('exec')) {
          echo "exec is enabled";
     } else {
          echo "exec is disabled";
     }
     echo '<br>Date Test<br>';
     exec('/bin/date',$output);
     print_r($output);
     echo '<br>End Date test';
?>
</p>
</HTML>
newweb:/var/www/htdocs/web # php-7.0 -f datetest.php
php-7.0 -f datetest.php
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">

<HTML>
<HEAD>
<title>Date Test</title>
</HEAD>
<p>
  exec is enabled<br>Date Test<br>Array
(
    [0] => Fri Nov  4 13:16:35 EDT 2016
)
<br>End Date test</p>
</HTML>
newweb:/var/www/htdocs/web # # date has been copied under /var/www/bin for
testing
# date has been copied under /var/www/bin
newweb:/var/www/htdocs/web # ls -l /var/www/bin
ls -l /var/www/bin
total 4216
----------  1 root  bin     249392 Jul 26 14:48 bgpctl
-rwxr-xr-x  1 root  daemon  119216 Nov  3 13:18 cat
-r-xr-xr-x  1 root  daemon  140112 Nov  4 12:52 date
-rwxr-xr-x  1 root  bin     271856 Jul 25 20:37 femail
-rwxr-xr-x  1 root  daemon  470096 Nov  3 12:49 ksh
-rwxr-xr-x  1 root  daemon    9816 Nov  3 12:51 logger
-rwxrwxrwx  1 root  daemon      27 Nov  3 15:56 mailtest
-rwxr-xr-x  1 root  bin     204240 Jul 26 14:48 ping
----------  1 root  bin     207920 Jul 26 14:48 ping6
----------  2 root  bin     179760 Jul 26 14:48 traceroute
----------  2 root  bin     179760 Jul 26 14:48 traceroute6
newweb:/var/www/htdocs/web # chroot -u www /var/www /bin/date
chroot -u www /var/www /bin/date
Fri Nov  4 17:18:34 GMT 2016

I believe this shows that the php web page is correct and that 'date' does
exist in the chroot,

but when I invoke web page from a browser I get.

exec is enabled
Date Test
Array ( )
End Date test

What am I doing wrong.

Reply via email to