Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Heads up: This fails to work as of Rocky Linux 9.2 (In FastCGI.php line 114: Access Denied) #230

Closed
jamieburchell opened this issue May 17, 2023 · 22 comments

Comments

@jamieburchell
Copy link

jamieburchell commented May 17, 2023

After a recent upgrade from Rocky Linux 9.1 to Rocky Linux 9.2 on a SELinux enabled system, cachetool now fails with:

In FastCGI.php line 114: Error: Access denied.

I've managed to track this back to PHP now being unable to run scripts from /dev/shm:

type=AVC msg=audit(1684332900.327:36001): avc: denied { open } for pid=279921 comm="php-fpm" path="/dev/shm/cachetool-6464e1644f7e67.25692862.php" dev="tmpfs" ino=61 scontext=system_u:system_r:httpd_t:s0 tcontext=unconfined_u:object_r:user_tmp_t:s0 tclass=file permissive=0

I know that you can manually set the --tmp-dir, but so far this has not been necessary for me until now.

Incidentally, if the tmp dir is set to /tmp or /var/run cachetool fails with:

In FastCGI.php line 114: Error: File not found.

@sideshowcoder
Copy link
Contributor

How was cachetool installed? I guess to access /dev/shm this requires some authorization in SELinux (https://serverfault.com/questions/81787/mysql-tmpdir-on-dev-shm-with-selinux for reference), if installed via a package I guess the correct way would be to configure the access for SELinux in it.
In general so I am not sure if /dev/shm is a good default here to use the shared memory FS for this, as it could really just life on any drive no need for it to be in memory I would say personally.

For the In FastCGI.php line 114: Error: File not found. are you able to turn on info log level? I would be interested if the file is writen successfully and where as of https://github.com/gordalina/cachetool/blob/main/src/Adapte/FastCGI.php#L123

@jamieburchell
Copy link
Author

jamieburchell commented May 22, 2023

How was cachetool installed?

I use the cachetool part of PHP Deployer and this downloads the phar directly for use.

I guess to access /dev/shm this requires some authorization in SELinux (https://serverfault.com/questions/81787/mysql-tmpdir-on-dev-shm-with-selinux for reference)

Up until Rocky Linux 9.2, this did work, but no longer unless the SELinux boolean httpd_read_user_content is set to true

I can get around the issue by setting a specific directory using --temp-dir but it's just annoying because I didn't need to go to the trouble of setting up a directory specifically for this purpose before.

For the In FastCGI.php line 114: Error: File not found. are you able to turn on info log level? I would be interested if the file is writen successfully and where as of https://github.com/gordalina/cachetool/blob/main/src/Adapte/FastCGI.php#L123

Here's what I get with -vvvv (not sure if this is the level you need, but)

[2023-05-22T14:00:09.877740+01:00] cachetool.DEBUG: Config: {"adapter":"fastcgi","extensions":["apcu","opcache"],"fastcgi":"\/run\/php-fpm\/www.sock","temp_dir":"\/tmp","fastcgiChroot":false} [] []
[2023-05-22T14:00:09.879743+01:00] cachetool.INFO: Adding Proxy: CacheTool\Proxy\ApcuProxy [] []
[2023-05-22T14:00:09.880124+01:00] cachetool.INFO: Adding Proxy: CacheTool\Proxy\PhpProxy [] []
[2023-05-22T14:00:09.880420+01:00] cachetool.INFO: Adding Proxy: CacheTool\Proxy\OpcacheProxy [] []
[2023-05-22T14:00:09.880530+01:00] cachetool.INFO: Setting adapter: CacheTool\Adapter\FastCGI [] []
[2023-05-22T14:00:09.882360+01:00] cachetool.NOTICE: Executing: extension_loaded("Zend OPcache") [] []
[2023-05-22T14:00:09.882506+01:00] cachetool.INFO: Loading Proxy: CacheTool\Proxy\ApcuProxy [] []
[2023-05-22T14:00:09.882605+01:00] cachetool.DEBUG: Loading Function: apcu_add [] []
[2023-05-22T14:00:09.882685+01:00] cachetool.DEBUG: Loading Function: apcu_cache_info [] []
[2023-05-22T14:00:09.882739+01:00] cachetool.DEBUG: Loading Function: apcu_regexp_get_keys [] []
[2023-05-22T14:00:09.882791+01:00] cachetool.DEBUG: Loading Function: apcu_cas [] []
[2023-05-22T14:00:09.882864+01:00] cachetool.DEBUG: Loading Function: apcu_clear_cache [] []
[2023-05-22T14:00:09.882917+01:00] cachetool.DEBUG: Loading Function: apcu_dec [] []
[2023-05-22T14:00:09.882966+01:00] cachetool.DEBUG: Loading Function: apcu_delete [] []
[2023-05-22T14:00:09.883015+01:00] cachetool.DEBUG: Loading Function: apcu_regexp_delete [] []
[2023-05-22T14:00:09.883063+01:00] cachetool.DEBUG: Loading Function: apcu_exists [] []
[2023-05-22T14:00:09.883110+01:00] cachetool.DEBUG: Loading Function: apcu_fetch [] []
[2023-05-22T14:00:09.883158+01:00] cachetool.DEBUG: Loading Function: apcu_inc [] []
[2023-05-22T14:00:09.883205+01:00] cachetool.DEBUG: Loading Function: apcu_sma_info [] []
[2023-05-22T14:00:09.883282+01:00] cachetool.DEBUG: Loading Function: apcu_store [] []
[2023-05-22T14:00:09.883330+01:00] cachetool.DEBUG: Loading Function: apcu_version [] []
[2023-05-22T14:00:09.883379+01:00] cachetool.INFO: Loading Proxy: CacheTool\Proxy\PhpProxy [] []
[2023-05-22T14:00:09.883442+01:00] cachetool.DEBUG: Loading Function: extension_loaded [] []
[2023-05-22T14:00:09.883495+01:00] cachetool.DEBUG: Loading Function: ini_get [] []
[2023-05-22T14:00:09.883544+01:00] cachetool.DEBUG: Loading Function: ini_set [] []
[2023-05-22T14:00:09.883593+01:00] cachetool.DEBUG: Loading Function: phpversion [] []
[2023-05-22T14:00:09.883640+01:00] cachetool.DEBUG: Loading Function: stat_realpath_get [] []
[2023-05-22T14:00:09.883689+01:00] cachetool.DEBUG: Loading Function: stat_realpath_size [] []
[2023-05-22T14:00:09.883737+01:00] cachetool.DEBUG: Loading Function: stat_cache_clear [] []
[2023-05-22T14:00:09.883784+01:00] cachetool.DEBUG: Loading Function: _eval [] []
[2023-05-22T14:00:09.883831+01:00] cachetool.INFO: Loading Proxy: CacheTool\Proxy\OpcacheProxy [] []
[2023-05-22T14:00:09.883891+01:00] cachetool.DEBUG: Loading Function: opcache_compile_file [] []
[2023-05-22T14:00:09.883958+01:00] cachetool.DEBUG: Loading Function: opcache_compile_files [] []
[2023-05-22T14:00:09.884014+01:00] cachetool.DEBUG: Loading Function: opcache_get_configuration [] []
[2023-05-22T14:00:09.884067+01:00] cachetool.DEBUG: Loading Function: opcache_get_status [] []
[2023-05-22T14:00:09.884115+01:00] cachetool.DEBUG: Loading Function: opcache_invalidate [] []
[2023-05-22T14:00:09.884162+01:00] cachetool.DEBUG: Loading Function: opcache_invalidate_many [] []
[2023-05-22T14:00:09.884406+01:00] cachetool.DEBUG: Loading Function: opcache_reset [] []
[2023-05-22T14:00:09.884482+01:00] cachetool.DEBUG: Loading Function: opcache_version [] []
[2023-05-22T14:00:09.884749+01:00] cachetool.DEBUG: Executing code: return extension_loaded('Zend OPcache'); [] []
[2023-05-22T14:00:09.885189+01:00] cachetool.INFO: FastCGI: Dumped code to file: /tmp/cachetool-646b6759d80774.55557353.php [] []
[2023-05-22T14:00:09.885408+01:00] cachetool.INFO: FastCGI: Requesting FPM using socket: /run/php-fpm/www.sock [] []
[2023-05-22T14:00:09.894414+01:00] cachetool.DEBUG: FastCGI: Response: {} [] []

In FastCGI.php line 114:

  [RuntimeException]
  Error: File not found.


Exception trace:
  at phar:///var/www/releases/18/cachetool.phar/src/Adapter/FastCGI.php:114
 CacheTool\Adapter\FastCGI->doRun() at phar:///var/www/releases/18/cachetool.phar/src/Adapter/AbstractAdapter.php:43
 CacheTool\Adapter\AbstractAdapter->run() at phar:///var/www/releases/18/cachetool.phar/src/Proxy/PhpProxy.php:64
 CacheTool\Proxy\PhpProxy->extension_loaded() at phar:///var/www/releases/18/cachetool.phar/src/CacheTool.php:197
 CacheTool\CacheTool->__call() at phar:///var/www/releases/18/cachetool.phar/src/Command/AbstractCommand.php:38
 CacheTool\Command\AbstractCommand->ensureExtensionLoaded() at phar:///var/www/releases/18/cachetool.phar/src/Command/OpcacheStatusCommand.php:38
 CacheTool\Command\OpcacheStatusCommand->execute() at phar:///var/www/releases/18/cachetool.phar/vendor/symfony/console/Command/Command.php:299
 Symfony\Component\Console\Command\Command->run() at phar:///var/www/releases/18/cachetool.phar/vendor/symfony/console/Application.php:978
 Symfony\Component\Console\Application->doRunCommand() at phar:///var/www/releases/18/cachetool.phar/src/Console/Application.php:148
 CacheTool\Console\Application->doRunCommand() at phar:///var/www/releases/18/cachetool.phar/vendor/symfony/console/Application.php:295
 Symfony\Component\Console\Application->doRun() at phar:///var/www/releases/18/cachetool.phar/src/Console/Application.php:131
 CacheTool\Console\Application->doRun() at phar:///var/www/releases/18/cachetool.phar/vendor/symfony/console/Application.php:167
 Symfony\Component\Console\Application->run() at phar:///var/www/releases/18/cachetool.phar/bin/cachetool:29
 require() at /var/www/releases/18/cachetool.phar:14

opcache:status

@gordalina
Copy link
Owner

Fixed in 9.1.0, can you test it?

@jamieburchell
Copy link
Author

I can take a look next week @gordalina but I don't think that commit solves the issue of SELinux denying a script from running from /dev/shm?

@gordalina
Copy link
Owner

If it doesn't solve it, I'll remove /dev/shm as a default.

@jamieburchell
Copy link
Author

Hi @gordalina unfortunately I can't test it in 9.1.0 as the affected installations need to be PHP 8.0 for now.

@rbocquet
Copy link

rbocquet commented Nov 27, 2023

Hi,
I have the same problem.
I tried php 8.1 and php 8.2.
I tried root user and limited user.

I used Rocky Linux 8.9.

php81 cachetool.phar opcache:reset -vvvv --fcgi=/run/php-fpm/test-93babf.socket

[2023-11-27T15:26:22.750045+00:00] cachetool.INFO: CacheTool 9.1.0 [] []
[2023-11-27T15:26:22.750866+00:00] cachetool.DEBUG: Config: {"adapter":"fastcgi","extensions":["apcu","opcache"],"temp_dir":null,"fastcgi":"\/run\/php-fpm\/test-93babf.socket","fastcgiChroot":null,"webClient":null,"webPath":null,"webUrl":null,"webAllowInsecure":null,"webBasicAuth":null,"webHost":null,"http":null} [] []
[2023-11-27T15:26:22.752049+00:00] cachetool.INFO: Adding Proxy: CacheTool\Proxy\ApcuProxy [] []
[2023-11-27T15:26:22.752178+00:00] cachetool.INFO: Adding Proxy: CacheTool\Proxy\PhpProxy [] []
[2023-11-27T15:26:22.752311+00:00] cachetool.INFO: Adding Proxy: CacheTool\Proxy\OpcacheProxy [] []
[2023-11-27T15:26:22.752348+00:00] cachetool.INFO: Setting adapter: CacheTool\Adapter\FastCGI [] []
[2023-11-27T15:26:22.753563+00:00] cachetool.NOTICE: Executing: extension_loaded("Zend OPcache") [] []
[2023-11-27T15:26:22.753613+00:00] cachetool.INFO: Loading Proxy: CacheTool\Proxy\ApcuProxy [] []
[2023-11-27T15:26:22.753645+00:00] cachetool.DEBUG: Loading Function: apcu_add [] []
[2023-11-27T15:26:22.753667+00:00] cachetool.DEBUG: Loading Function: apcu_cache_info [] []
[2023-11-27T15:26:22.753686+00:00] cachetool.DEBUG: Loading Function: apcu_regexp_get_keys [] []
[2023-11-27T15:26:22.753704+00:00] cachetool.DEBUG: Loading Function: apcu_cas [] []
[2023-11-27T15:26:22.753721+00:00] cachetool.DEBUG: Loading Function: apcu_clear_cache [] []
[2023-11-27T15:26:22.753738+00:00] cachetool.DEBUG: Loading Function: apcu_dec [] []
[2023-11-27T15:26:22.753755+00:00] cachetool.DEBUG: Loading Function: apcu_delete [] []
[2023-11-27T15:26:22.753772+00:00] cachetool.DEBUG: Loading Function: apcu_regexp_delete [] []
[2023-11-27T15:26:22.753789+00:00] cachetool.DEBUG: Loading Function: apcu_exists [] []
[2023-11-27T15:26:22.753805+00:00] cachetool.DEBUG: Loading Function: apcu_fetch [] []
[2023-11-27T15:26:22.753822+00:00] cachetool.DEBUG: Loading Function: apcu_inc [] []
[2023-11-27T15:26:22.753839+00:00] cachetool.DEBUG: Loading Function: apcu_sma_info [] []
[2023-11-27T15:26:22.753856+00:00] cachetool.DEBUG: Loading Function: apcu_store [] []
[2023-11-27T15:26:22.753873+00:00] cachetool.DEBUG: Loading Function: apcu_version [] []
[2023-11-27T15:26:22.753890+00:00] cachetool.INFO: Loading Proxy: CacheTool\Proxy\PhpProxy [] []
[2023-11-27T15:26:22.753917+00:00] cachetool.DEBUG: Loading Function: extension_loaded [] []
[2023-11-27T15:26:22.753936+00:00] cachetool.DEBUG: Loading Function: ini_get [] []
[2023-11-27T15:26:22.753954+00:00] cachetool.DEBUG: Loading Function: ini_set [] []
[2023-11-27T15:26:22.753971+00:00] cachetool.DEBUG: Loading Function: phpversion [] []
[2023-11-27T15:26:22.753988+00:00] cachetool.DEBUG: Loading Function: stat_realpath_get [] []
[2023-11-27T15:26:22.754005+00:00] cachetool.DEBUG: Loading Function: stat_realpath_size [] []
[2023-11-27T15:26:22.754022+00:00] cachetool.DEBUG: Loading Function: stat_cache_clear [] []
[2023-11-27T15:26:22.754039+00:00] cachetool.DEBUG: Loading Function: _eval [] []
[2023-11-27T15:26:22.754056+00:00] cachetool.INFO: Loading Proxy: CacheTool\Proxy\OpcacheProxy [] []
[2023-11-27T15:26:22.754083+00:00] cachetool.DEBUG: Loading Function: opcache_compile_file [] []
[2023-11-27T15:26:22.754101+00:00] cachetool.DEBUG: Loading Function: opcache_compile_files [] []
[2023-11-27T15:26:22.754120+00:00] cachetool.DEBUG: Loading Function: opcache_get_configuration [] []
[2023-11-27T15:26:22.754137+00:00] cachetool.DEBUG: Loading Function: opcache_get_status [] []
[2023-11-27T15:26:22.754155+00:00] cachetool.DEBUG: Loading Function: opcache_invalidate [] []
[2023-11-27T15:26:22.754172+00:00] cachetool.DEBUG: Loading Function: opcache_invalidate_many [] []
[2023-11-27T15:26:22.754188+00:00] cachetool.DEBUG: Loading Function: opcache_reset [] []
[2023-11-27T15:26:22.754205+00:00] cachetool.DEBUG: Loading Function: opcache_version [] []
[2023-11-27T15:26:22.754303+00:00] cachetool.DEBUG: Executing code: return extension_loaded('Zend OPcache'); [] []
[2023-11-27T15:26:22.754357+00:00] cachetool.INFO: FastCGI: Dumped code to file: /dev/shm/cachetool-6564b51eb82998.26705763.php [] []
[2023-11-27T15:26:22.754419+00:00] cachetool.INFO: FastCGI: Requesting FPM using socket: /run/php-fpm/test-93babf.socket [] []
[2023-11-27T15:26:22.758098+00:00] cachetool.DEBUG: FastCGI: Response: {} [] []

In FastCGI.php line 114:

  [RuntimeException]
  Error: No input file specified.


Exception trace:
  at phar:///root/cachetool.phar/src/Adapter/FastCGI.php:114
 CacheTool\Adapter\FastCGI->doRun() at phar:///root/cachetool.phar/src/Adapter/AbstractAdapter.php:43
 CacheTool\Adapter\AbstractAdapter->run() at phar:///root/cachetool.phar/src/Proxy/PhpProxy.php:64
 CacheTool\Proxy\PhpProxy->extension_loaded() at phar:///root/cachetool.phar/src/CacheTool.php:197
 CacheTool\CacheTool->__call() at phar:///root/cachetool.phar/src/Command/AbstractCommand.php:38
 CacheTool\Command\AbstractCommand->ensureExtensionLoaded() at phar:///root/cachetool.phar/src/Command/OpcacheResetCommand.php:35
 CacheTool\Command\OpcacheResetCommand->execute() at phar:///root/cachetool.phar/vendor/symfony/console/Command/Command.php:308
 Symfony\Component\Console\Command\Command->run() at phar:///root/cachetool.phar/vendor/symfony/console/Application.php:1002
 Symfony\Component\Console\Application->doRunCommand() at phar:///root/cachetool.phar/src/Console/Application.php:148
 CacheTool\Console\Application->doRunCommand() at phar:///root/cachetool.phar/vendor/symfony/console/Application.php:299
 Symfony\Component\Console\Application->doRun() at phar:///root/cachetool.phar/src/Console/Application.php:131
 CacheTool\Console\Application->doRun() at phar:///root/cachetool.phar/vendor/symfony/console/Application.php:171
 Symfony\Component\Console\Application->run() at phar:///root/cachetool.phar/bin/cachetool:29
 require() at /root/cachetool.phar:14

opcache:reset

Can you help me ?

Thanks

@jamieburchell
Copy link
Author

jamieburchell commented Nov 27, 2023

@rbocquet @gordalina I just tested this with cachetool 9.1.0 on PHP 8.1 and get:

[production]  error  in cachetool.php on line 89:
[production] run cd /var/www && /usr/bin/php /var/www/cachetool.phar opcache:reset --fcgi=/run/php-fpm/www.sock
[production] err In FastCGI.php line 114:
[production] err Error: Access denied.
[production] err opcache:reset
[production] exit code 1 (General error)
ERROR: Task cachetool:clear:opcache failed!

The only way I can "fix" it is by enabling httpd_read_user_content:

sudo setsebool -P httpd_read_user_content 1

@rbocquet
Copy link

Hi @jamieburchell

I tried you're fixed but same problem

setsebool -P httpd_read_user_content 1

php81 cachetool.phar opcache:reset -vvvv --fcgi=/run/php-fpm/test-93babf.socket

[2023-11-27T15:46:39.745514+00:00] cachetool.INFO: CacheTool 9.1.0 [] []
[2023-11-27T15:46:39.746425+00:00] cachetool.DEBUG: Config: {"adapter":"fastcgi","extensions":["apcu","opcache"],"temp_dir":null,"fastcgi":"\/run\/php-fpm\/test-93babf.socket","fastcgiChroot":null,"webClient":null,"webPath":null,"webUrl":null,"webAllowInsecure":null,"webBasicAuth":null,"webHost":null,"http":null} [] []
[2023-11-27T15:46:39.747829+00:00] cachetool.INFO: Adding Proxy: CacheTool\Proxy\ApcuProxy [] []
[2023-11-27T15:46:39.747970+00:00] cachetool.INFO: Adding Proxy: CacheTool\Proxy\PhpProxy [] []
[2023-11-27T15:46:39.748111+00:00] cachetool.INFO: Adding Proxy: CacheTool\Proxy\OpcacheProxy [] []
[2023-11-27T15:46:39.748155+00:00] cachetool.INFO: Setting adapter: CacheTool\Adapter\FastCGI [] []
[2023-11-27T15:46:39.749671+00:00] cachetool.NOTICE: Executing: extension_loaded("Zend OPcache") [] []
[2023-11-27T15:46:39.749733+00:00] cachetool.INFO: Loading Proxy: CacheTool\Proxy\ApcuProxy [] []
[2023-11-27T15:46:39.749768+00:00] cachetool.DEBUG: Loading Function: apcu_add [] []
[2023-11-27T15:46:39.749793+00:00] cachetool.DEBUG: Loading Function: apcu_cache_info [] []
[2023-11-27T15:46:39.749816+00:00] cachetool.DEBUG: Loading Function: apcu_regexp_get_keys [] []
[2023-11-27T15:46:39.749837+00:00] cachetool.DEBUG: Loading Function: apcu_cas [] []
[2023-11-27T15:46:39.749856+00:00] cachetool.DEBUG: Loading Function: apcu_clear_cache [] []
[2023-11-27T15:46:39.749874+00:00] cachetool.DEBUG: Loading Function: apcu_dec [] []
[2023-11-27T15:46:39.749892+00:00] cachetool.DEBUG: Loading Function: apcu_delete [] []
[2023-11-27T15:46:39.749910+00:00] cachetool.DEBUG: Loading Function: apcu_regexp_delete [] []
[2023-11-27T15:46:39.749927+00:00] cachetool.DEBUG: Loading Function: apcu_exists [] []
[2023-11-27T15:46:39.749950+00:00] cachetool.DEBUG: Loading Function: apcu_fetch [] []
[2023-11-27T15:46:39.749969+00:00] cachetool.DEBUG: Loading Function: apcu_inc [] []
[2023-11-27T15:46:39.749987+00:00] cachetool.DEBUG: Loading Function: apcu_sma_info [] []
[2023-11-27T15:46:39.750004+00:00] cachetool.DEBUG: Loading Function: apcu_store [] []
[2023-11-27T15:46:39.750022+00:00] cachetool.DEBUG: Loading Function: apcu_version [] []
[2023-11-27T15:46:39.750040+00:00] cachetool.INFO: Loading Proxy: CacheTool\Proxy\PhpProxy [] []
[2023-11-27T15:46:39.750069+00:00] cachetool.DEBUG: Loading Function: extension_loaded [] []
[2023-11-27T15:46:39.750091+00:00] cachetool.DEBUG: Loading Function: ini_get [] []
[2023-11-27T15:46:39.750116+00:00] cachetool.DEBUG: Loading Function: ini_set [] []
[2023-11-27T15:46:39.750135+00:00] cachetool.DEBUG: Loading Function: phpversion [] []
[2023-11-27T15:46:39.750153+00:00] cachetool.DEBUG: Loading Function: stat_realpath_get [] []
[2023-11-27T15:46:39.750172+00:00] cachetool.DEBUG: Loading Function: stat_realpath_size [] []
[2023-11-27T15:46:39.750190+00:00] cachetool.DEBUG: Loading Function: stat_cache_clear [] []
[2023-11-27T15:46:39.750208+00:00] cachetool.DEBUG: Loading Function: _eval [] []
[2023-11-27T15:46:39.750226+00:00] cachetool.INFO: Loading Proxy: CacheTool\Proxy\OpcacheProxy [] []
[2023-11-27T15:46:39.750254+00:00] cachetool.DEBUG: Loading Function: opcache_compile_file [] []
[2023-11-27T15:46:39.750274+00:00] cachetool.DEBUG: Loading Function: opcache_compile_files [] []
[2023-11-27T15:46:39.750293+00:00] cachetool.DEBUG: Loading Function: opcache_get_configuration [] []
[2023-11-27T15:46:39.750311+00:00] cachetool.DEBUG: Loading Function: opcache_get_status [] []
[2023-11-27T15:46:39.750329+00:00] cachetool.DEBUG: Loading Function: opcache_invalidate [] []
[2023-11-27T15:46:39.750347+00:00] cachetool.DEBUG: Loading Function: opcache_invalidate_many [] []
[2023-11-27T15:46:39.750364+00:00] cachetool.DEBUG: Loading Function: opcache_reset [] []
[2023-11-27T15:46:39.750381+00:00] cachetool.DEBUG: Loading Function: opcache_version [] []
[2023-11-27T15:46:39.750488+00:00] cachetool.DEBUG: Executing code: return extension_loaded('Zend OPcache'); [] []
[2023-11-27T15:46:39.750600+00:00] cachetool.INFO: FastCGI: Dumped code to file: /dev/shm/cachetool-6564b9dfb73d76.32795503.php [] []
[2023-11-27T15:46:39.750709+00:00] cachetool.INFO: FastCGI: Requesting FPM using socket: /run/php-fpm/test-93babf.socket [] []
[2023-11-27T15:46:39.753883+00:00] cachetool.DEBUG: FastCGI: Response: {} [] []

In FastCGI.php line 114:

  [RuntimeException]
  Error: No input file specified.


Exception trace:
  at phar:///root/cachetool.phar/src/Adapter/FastCGI.php:114
 CacheTool\Adapter\FastCGI->doRun() at phar:///root/cachetool.phar/src/Adapter/AbstractAdapter.php:43
 CacheTool\Adapter\AbstractAdapter->run() at phar:///root/cachetool.phar/src/Proxy/PhpProxy.php:64
 CacheTool\Proxy\PhpProxy->extension_loaded() at phar:///root/cachetool.phar/src/CacheTool.php:197
 CacheTool\CacheTool->__call() at phar:///root/cachetool.phar/src/Command/AbstractCommand.php:38
 CacheTool\Command\AbstractCommand->ensureExtensionLoaded() at phar:///root/cachetool.phar/src/Command/OpcacheResetCommand.php:35
 CacheTool\Command\OpcacheResetCommand->execute() at phar:///root/cachetool.phar/vendor/symfony/console/Command/Command.php:308
 Symfony\Component\Console\Command\Command->run() at phar:///root/cachetool.phar/vendor/symfony/console/Application.php:1002
 Symfony\Component\Console\Application->doRunCommand() at phar:///root/cachetool.phar/src/Console/Application.php:148
 CacheTool\Console\Application->doRunCommand() at phar:///root/cachetool.phar/vendor/symfony/console/Application.php:299
 Symfony\Component\Console\Application->doRun() at phar:///root/cachetool.phar/src/Console/Application.php:131
 CacheTool\Console\Application->doRun() at phar:///root/cachetool.phar/vendor/symfony/console/Application.php:171
 Symfony\Component\Console\Application->run() at phar:///root/cachetool.phar/bin/cachetool:29
 require() at /root/cachetool.phar:14

opcache:reset

@jamieburchell
Copy link
Author

@rbocquet Not sure. Try making sure that the user running the command has permission on the socket file. In my case the apache user has rw access on the socket file, so I would run the command as the apache user as well as making sure the SELinux bool is true:

sudo -uapache php ./cachetool.phar opcache:reset -vvvv --fcgi=/run/php-fpm/www.sock

@gordalina
Copy link
Owner

As pointed out by @jamieburchell the user running the php-fpm process needs to be able to read the file created by cachetool, if you use the same user when calling cachetool that shouldn't be an issue.

Try also using a different path with --tmp-dir=/var/run/cachetool

@rbocquet
Copy link

For test, I tried chmod 777 /run/php-fpm/test-93babf.socket to have no limits
Same problem

ls -la /run/php-fpm/test-93babf.socket
srwxrwxrwx. 1 root root 0 Nov 27 16:26 /run/php-fpm/test-93babf.socket

php81 cachetool.phar opcache:reset -vvvv --fcgi=/run/php-fpm/test-93babf.socket --tmp-dir=/var/run/cachetool

[2023-11-28T08:55:31.941831+00:00] cachetool.INFO: CacheTool 9.1.0 [] []
[2023-11-28T08:55:31.942633+00:00] cachetool.DEBUG: Config: {"adapter":"fastcgi","extensions":["apcu","opcache"],"temp_dir":"\/var\/run\/cachetool","fastcgi":"\/run\/php-fpm\/test-93babf.socket","fastcgiChroot":null,"webClient":null,"webPath":null,"webUrl":null,"webAllowInsecure":null,"webBasicAuth":null,"webHost":null,"http":null} [] []
[2023-11-28T08:55:31.943724+00:00] cachetool.INFO: Adding Proxy: CacheTool\Proxy\ApcuProxy [] []
[2023-11-28T08:55:31.943849+00:00] cachetool.INFO: Adding Proxy: CacheTool\Proxy\PhpProxy [] []
[2023-11-28T08:55:31.943977+00:00] cachetool.INFO: Adding Proxy: CacheTool\Proxy\OpcacheProxy [] []
[2023-11-28T08:55:31.944012+00:00] cachetool.INFO: Setting adapter: CacheTool\Adapter\FastCGI [] []
[2023-11-28T08:55:31.945198+00:00] cachetool.NOTICE: Executing: extension_loaded("Zend OPcache") [] []
[2023-11-28T08:55:31.945247+00:00] cachetool.INFO: Loading Proxy: CacheTool\Proxy\ApcuProxy [] []
[2023-11-28T08:55:31.945278+00:00] cachetool.DEBUG: Loading Function: apcu_add [] []
[2023-11-28T08:55:31.945300+00:00] cachetool.DEBUG: Loading Function: apcu_cache_info [] []
[2023-11-28T08:55:31.945318+00:00] cachetool.DEBUG: Loading Function: apcu_regexp_get_keys [] []
[2023-11-28T08:55:31.945335+00:00] cachetool.DEBUG: Loading Function: apcu_cas [] []
[2023-11-28T08:55:31.945351+00:00] cachetool.DEBUG: Loading Function: apcu_clear_cache [] []
[2023-11-28T08:55:31.945368+00:00] cachetool.DEBUG: Loading Function: apcu_dec [] []
[2023-11-28T08:55:31.945383+00:00] cachetool.DEBUG: Loading Function: apcu_delete [] []
[2023-11-28T08:55:31.945400+00:00] cachetool.DEBUG: Loading Function: apcu_regexp_delete [] []
[2023-11-28T08:55:31.945416+00:00] cachetool.DEBUG: Loading Function: apcu_exists [] []
[2023-11-28T08:55:31.945432+00:00] cachetool.DEBUG: Loading Function: apcu_fetch [] []
[2023-11-28T08:55:31.945448+00:00] cachetool.DEBUG: Loading Function: apcu_inc [] []
[2023-11-28T08:55:31.945465+00:00] cachetool.DEBUG: Loading Function: apcu_sma_info [] []
[2023-11-28T08:55:31.945481+00:00] cachetool.DEBUG: Loading Function: apcu_store [] []
[2023-11-28T08:55:31.945850+00:00] cachetool.DEBUG: Loading Function: apcu_version [] []
[2023-11-28T08:55:31.945876+00:00] cachetool.INFO: Loading Proxy: CacheTool\Proxy\PhpProxy [] []
[2023-11-28T08:55:31.945906+00:00] cachetool.DEBUG: Loading Function: extension_loaded [] []
[2023-11-28T08:55:31.945926+00:00] cachetool.DEBUG: Loading Function: ini_get [] []
[2023-11-28T08:55:31.945944+00:00] cachetool.DEBUG: Loading Function: ini_set [] []
[2023-11-28T08:55:31.945961+00:00] cachetool.DEBUG: Loading Function: phpversion [] []
[2023-11-28T08:55:31.945977+00:00] cachetool.DEBUG: Loading Function: stat_realpath_get [] []
[2023-11-28T08:55:31.945994+00:00] cachetool.DEBUG: Loading Function: stat_realpath_size [] []
[2023-11-28T08:55:31.946010+00:00] cachetool.DEBUG: Loading Function: stat_cache_clear [] []
[2023-11-28T08:55:31.946026+00:00] cachetool.DEBUG: Loading Function: _eval [] []
[2023-11-28T08:55:31.946042+00:00] cachetool.INFO: Loading Proxy: CacheTool\Proxy\OpcacheProxy [] []
[2023-11-28T08:55:31.946068+00:00] cachetool.DEBUG: Loading Function: opcache_compile_file [] []
[2023-11-28T08:55:31.946086+00:00] cachetool.DEBUG: Loading Function: opcache_compile_files [] []
[2023-11-28T08:55:31.946103+00:00] cachetool.DEBUG: Loading Function: opcache_get_configuration [] []
[2023-11-28T08:55:31.946120+00:00] cachetool.DEBUG: Loading Function: opcache_get_status [] []
[2023-11-28T08:55:31.946136+00:00] cachetool.DEBUG: Loading Function: opcache_invalidate [] []
[2023-11-28T08:55:31.946153+00:00] cachetool.DEBUG: Loading Function: opcache_invalidate_many [] []
[2023-11-28T08:55:31.946169+00:00] cachetool.DEBUG: Loading Function: opcache_reset [] []
[2023-11-28T08:55:31.946185+00:00] cachetool.DEBUG: Loading Function: opcache_version [] []
[2023-11-28T08:55:31.946290+00:00] cachetool.DEBUG: Executing code: return extension_loaded('Zend OPcache'); [] []
[2023-11-28T08:55:31.946457+00:00] cachetool.INFO: FastCGI: Dumped code to file: /var/run/cachetool/cachetool-6565ab03e708b5.50931369.php [] []
[2023-11-28T08:55:31.946554+00:00] cachetool.INFO: FastCGI: Requesting FPM using socket: /run/php-fpm/test-93babf.socket [] []
[2023-11-28T08:55:31.948064+00:00] cachetool.DEBUG: FastCGI: Response: {} [] []

In FastCGI.php line 114:

  [RuntimeException]
  Error: File not found.


Exception trace:
  at phar:///root/cachetool.phar/src/Adapter/FastCGI.php:114
 CacheTool\Adapter\FastCGI->doRun() at phar:///root/cachetool.phar/src/Adapter/AbstractAdapter.php:43
 CacheTool\Adapter\AbstractAdapter->run() at phar:///root/cachetool.phar/src/Proxy/PhpProxy.php:64
 CacheTool\Proxy\PhpProxy->extension_loaded() at phar:///root/cachetool.phar/src/CacheTool.php:197
 CacheTool\CacheTool->__call() at phar:///root/cachetool.phar/src/Command/AbstractCommand.php:38
 CacheTool\Command\AbstractCommand->ensureExtensionLoaded() at phar:///root/cachetool.phar/src/Command/OpcacheResetCommand.php:35
 CacheTool\Command\OpcacheResetCommand->execute() at phar:///root/cachetool.phar/vendor/symfony/console/Command/Command.php:308
 Symfony\Component\Console\Command\Command->run() at phar:///root/cachetool.phar/vendor/symfony/console/Application.php:1002
 Symfony\Component\Console\Application->doRunCommand() at phar:///root/cachetool.phar/src/Console/Application.php:148
 CacheTool\Console\Application->doRunCommand() at phar:///root/cachetool.phar/vendor/symfony/console/Application.php:299
 Symfony\Component\Console\Application->doRun() at phar:///root/cachetool.phar/src/Console/Application.php:131
 CacheTool\Console\Application->doRun() at phar:///root/cachetool.phar/vendor/symfony/console/Application.php:171
 Symfony\Component\Console\Application->run() at phar:///root/cachetool.phar/bin/cachetool:29
 require() at /root/cachetool.phar:14

opcache:reset

@jamieburchell
Copy link
Author

Do you have SELinux enabled?

$ sestatus

@rbocquet
Copy link

Yes

sestatus
SELinux status:                 enabled
SELinuxfs mount:                /sys/fs/selinux
SELinux root directory:         /etc/selinux
Loaded policy name:             targeted
Current mode:                   permissive
Mode from config file:          permissive
Policy MLS status:              enabled
Policy deny_unknown status:     allowed
Memory protection checking:     actual (secure)
Max kernel policy version:      33

@jamieburchell
Copy link
Author

It's in permissive mode, so that won't be the cause of the issue.

@rbocquet
Copy link

Do you have any idea to solve this problem ?

Thanks

@jamieburchell
Copy link
Author

Do you have any idea to solve this problem ?

Thanks

It seems like some sort of permission issue. Does the command work with sudo?

@rbocquet
Copy link

No, I use this command as root 😞

@jamieburchell
Copy link
Author

Anything in PHP error logs? open_basedir restrictions in effect?

@rbocquet
Copy link

@jamieburchell It works !!! I deleted open_basedir

Thanks a lot

@jamieburchell
Copy link
Author

@jamieburchell It works !!! I deleted open_basedir

Thanks a lot

Instead of deleting it, you can add the path to the temp cachetool directory.

@rbocquet
Copy link

Yes I fixed it

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants