[BlueOnyx:26045] Re: php shell_exec() or exec() always returns null

Michael Stauber mstauber at blueonyx.it
Thu Mar 23 09:39:53 -05 2023


Hi Brent,

>      php_admin_value disable_functions 
> system,passthru,popen,escapeshellcmd,proc_open,proc_nice,ini_restore
> 
> phpinfo() shows it's loading the local value for disable_functions as 
> seen in the above line (note the lack of 'exec' and 'shell_exec' listed 
> in the value)
> 
> I set PHP with mod_ruid and set it to execute as the vsite owner.
> 
> shell_exec() and exec() always return null, even executing a simple 
> command where permissions shouldn't be an issue, like `ls /tmp`
> 
> What am I missing?

I'm not sure, Brent. To test it I just went to "Server Settings" / 
"Security" / "PHP" and removed "shell_exec" from the list of disabled 
functions and saved. That allowed it then globally for all Vsites.

Your approach to edit the include file is also fine and if phpinfo() no 
longer lists shell_exec() under disabled functions in your PHP, then you 
should be good.

Maybe your PHP syntax is incorrect? It's hard to say without seeing the 
whole code.

I just tried this snippet and it worked for me once shell_exec() was no 
longer forbidden:

$output = shell_exec('ls -als /tmp');
echo "<pre>$output</pre>";

Please note I'm using 'straight' single-quotation marks and not 
backticks like you did in your `ls /tmp` example.

-- 
With best regards

Michael Stauber



More information about the Blueonyx mailing list