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

Brent Epp brent at pdc.ca
Thu Mar 23 12:04:25 -05 2023


On 2023-03-23 09:39, Michael Stauber wrote:
> 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.
>
Hi Michael,

I would prefer to only enable it for the one vsite, if possible, so I 
just modified the include file.

In any case, changed it through the BX GUI like you described above and 
it works.  I didn't not change the testing code, so it wasn't a syntax 
error or otherwise.

My testing code is just:

     error_log(shell_exec('ls /tmp -1sh'));

Maybe it's not following the config in the include file for some reason?

Thanks
  - Brent



More information about the Blueonyx mailing list