Topic: PHP 7.4 CentOS 8 and exec()

Hi

I've recently updated a copy of mailwatch on one of my servers. I ran into a problem where some info is not getting displayed. Tracing the problem, the info that is retreived is generated in part by the exec() function. However, nothing is being returned when the code is being run.

The snippet of code in question is:

exec("which clamscan", $clamscan);

I am running php 7.4.7 from Remi's repo on CentOS 8. I have no idea where to begin diagnosing the issue other than to say nothing in php.ini nor php-fpm.conf or their included files have any line disabling exec.

Please help

Thanks

Re: PHP 7.4 CentOS 8 and exec()

Sorry, not enough information

1/ what is "which clamscam" expected output ?

Laptop:  Fedora 38 + rpmfusion + remi (SCL only)
x86_64 builder: Fedora 39 + rpmfusion + remi-test
aarch64 builder: RHEL 9 with EPEL
Hosting Server: CentOS 8 Stream with EPEL, rpmfusion, remi

Re: PHP 7.4 CentOS 8 and exec()

Thanks for responding Remi. Here is the output requested

runuser -s /bin/bash apache
which clamscan
/usr/bin/clamscan

Of course I get the same result when running as any other user

Re: PHP 7.4 CentOS 8 and exec()

How is php installed ?
(base packages or SCl packages ? php-fpm or php74-php-fpm)

Strangely I can reproduce locally with php74-php-fpm, not with php-fpm... and this only affects "which" (no other commands)

Laptop:  Fedora 38 + rpmfusion + remi (SCL only)
x86_64 builder: Fedora 39 + rpmfusion + remi-test
aarch64 builder: RHEL 9 with EPEL
Hosting Server: CentOS 8 Stream with EPEL, rpmfusion, remi

Re: PHP 7.4 CentOS 8 and exec()

Forget previous... pool configuration were different in my testing box,


Try to set "clear_env = no" (security improvment option) in used pool configuration.

Laptop:  Fedora 38 + rpmfusion + remi (SCL only)
x86_64 builder: Fedora 39 + rpmfusion + remi-test
aarch64 builder: RHEL 9 with EPEL
Hosting Server: CentOS 8 Stream with EPEL, rpmfusion, remi

Re: PHP 7.4 CentOS 8 and exec()

Bingo!!!!

Thank you very very much smile

Re: PHP 7.4 CentOS 8 and exec()

smile

Laptop:  Fedora 38 + rpmfusion + remi (SCL only)
x86_64 builder: Fedora 39 + rpmfusion + remi-test
aarch64 builder: RHEL 9 with EPEL
Hosting Server: CentOS 8 Stream with EPEL, rpmfusion, remi