PHP Pools: phpinfo blank when fs.protected_regular >= 1
Platform
revision: 8b1048083467416c482fc8ed2b994d712950dc43
ver_maj: 3
ver_min: 2
ver_patch: 49
os: '8.10'
variant: rocky
kernel: 4.18.0-553.187.1.el8_10.x86_64
Seen on Rocky 10, where systemd sets fs.protected_regular = 1 by default. Reproduced on Rocky 8 with sysctl -w fs.protected_regular=1.
Symptom
/apps/php-pools?phpinfo=1&php-pool=example.com returns 200 with a 1-byte body. Pool is up. php:pool-direct-read against a phpinfo file in the docroot works.
Stack
Build::readFromPath('/var/www/html') run from CLI, jailed site:
WARNING: file_put_contents(/home/virtual/site1/shadow/tmp/exrzjRIy): Failed to open stream: Permission denied
[/usr/local/apnscp/apps/php-pools/Build.php:73]
0. file_put_contents("/home/virtual/site1/shadow/tmp/exrzjRIy", "<?php phpinfo();", 8)
[/usr/local/apnscp/apps/php-pools/Build.php:73]
1. apps\php_pools\Build->readFromPath("/var/www/html")
Cause
Build::readFromPath()
|- file:temp() file in docroot, owned by site user
|- file:expose('write') hardlink into site /tmp (1777)
|- file_put_contents() root, O_CREAT|O_APPEND on that link
| fs.protected_regular: O_CREAT on a file not owned by caller,
| in a sticky world-writable dir -> EACCES, even for root
| file stays empty
`- php:pool-direct-read() empty body -> blank page
| fs.protected_regular | 0 | 1 | 2 |
|---|---|---|---|
| phpinfo | O | X | X |