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 ?

Desktop: Fedora 31 x86_64 + rpmfusion + remi-test + remi-dev
Laptop:  Fedora 32 x86_64 + rpmfusion + remi (SCL only)
Hosting Server: CentOS 6.10 x86_64 with EPEL, remi, remi-php72 and remi-php72-test

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)

Desktop: Fedora 31 x86_64 + rpmfusion + remi-test + remi-dev
Laptop:  Fedora 32 x86_64 + rpmfusion + remi (SCL only)
Hosting Server: CentOS 6.10 x86_64 with EPEL, remi, remi-php72 and remi-php72-test

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.

Desktop: Fedora 31 x86_64 + rpmfusion + remi-test + remi-dev
Laptop:  Fedora 32 x86_64 + rpmfusion + remi (SCL only)
Hosting Server: CentOS 6.10 x86_64 with EPEL, remi, remi-php72 and remi-php72-test

Re: PHP 7.4 CentOS 8 and exec()

Bingo!!!!

Thank you very very much smile

Re: PHP 7.4 CentOS 8 and exec()

smile

Desktop: Fedora 31 x86_64 + rpmfusion + remi-test + remi-dev
Laptop:  Fedora 32 x86_64 + rpmfusion + remi (SCL only)
Hosting Server: CentOS 6.10 x86_64 with EPEL, remi, remi-php72 and remi-php72-test