Command Line PHP with shell_exec works for root but not others
Posted
by Kristopher Ives
on Stack Overflow
See other posts from Stack Overflow
or by Kristopher Ives
Published on 2010-06-13T00:23:54Z
Indexed on
2010/06/13
0:32 UTC
Read the original article
Hit count: 504
I have a very simple script that is to test if running a shell_exec (or backtick operator) basically works:
#!/usr/bin/php5-cli
<?php
echo "This is a PHP script\n";
echo `ls -l /home/stoysnet/`;
Unless I run this as root, it always gives me:
$ ./foo.php
This is a PHP script
Warning: _shell_exec(): Permission Denied in /home/stoysnet/foo.php on line 5
I've tried running this via PHP in a few different ways, but I always get the same error. However, when I put the script into a subdirectory of /etc/
owned by root:root
and executed as root
it works.
What gives?
© Stack Overflow or respective owner