Req #80498 [NEW]: error log file permissions setting
| From: | jordan dot lenuff at gmail dot com | Date: | Wed, 09 Dec 2020 08:47:12 +0000 |
| Subject: | Req #80498 [NEW]: error log file permissions setting | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-230947@lists.php.net to get a copy of this message | ||
From: jordan dot lenuff at gmail dot com
Operating system: CentOS 7
PHP version: 7.4.13
Package: *Configuration Issues
Bug Type: Feature/Change Request
Bug description:error log file permissions setting
Description:
------------
On several PHP versions, I noticed that error log files do not have
correct permissions with PHP-FPM.
I did a fresh compilation of 7.4.13 version of PHP with FPM, integrated
with systemd, and I don't understand why the error log files permissions
are wrong.
The files created by PHP scripts have correct permissions, but files
created by PHP daemon have wrong permissions.
As far as I can search over the net, it's seems PHP does not provide
umask configuration for error log files.
Test script:
---------------
mkdir -p /local/php/php-7.4.13 /local/builds /local/php/sockets
/local/php/sessions
wget https://www.php.net/distributions/php-7.4.13.tar.gz
tar -zxf php-7.4.13.tar.gz -C /local/builds
cd /local/builds/php-7.4.13
./configure \
--prefix=/local/php/php-7.4.13 \
--with-config-file-path=/local/php/php-7.4.13 \
--disable-all \
--enable-fpm \
--with-fpm-user=php-fpm \
--with-fpm-group=php-fpm \
--with-fpm-systemd \
... and whatever you want
&& make && make install
cp /local/php/php-7.4.13/etc/php-fpm.conf.default
/local/php/php-7.4.13/etc/php-fpm.conf
cp /local/builds/php-7.4.13/php.ini-production
/local/php/php-7.4.13/php.ini
echo "[localhost]" >>
/local/php/php-7.4.13/etc/php-fpm.d/localhost.conf
echo "listen = /local/php/sockets/php-7.4.13_\$pool.sock" >>
/local/php/php-7.4.13/etc/php-fpm.d/localhost.conf
echo "listen.owner = php-fpm" >>
/local/php/php-7.4.13/etc/php-fpm.d/localhost.conf
echo "listen.group = www" >>
/local/php/php-7.4.13/etc/php-fpm.d/localhost.conf
echo "listen.mode = 0660" >>
/local/php/php-7.4.13/etc/php-fpm.d/localhost.conf
echo "pm = dynamic" >>
/local/php/php-7.4.13/etc/php-fpm.d/localhost.conf
echo "pm.max_children = 5" >>
/local/php/php-7.4.13/etc/php-fpm.d/localhost.conf
echo "pm.start_servers = 2" >>
/local/php/php-7.4.13/etc/php-fpm.d/localhost.conf
echo "pm.min_spare_servers = 1" >>
/local/php/php-7.4.13/etc/php-fpm.d/localhost.conf
echo "pm.max_spare_servers = 3" >>
/local/php/php-7.4.13/etc/php-fpm.d/localhost.conf
echo "pm.status_path = /php-fpm-status" >>
/local/php/php-7.4.13/etc/php-fpm.d/localhost.conf
echo "ping.path = /php-fpm-ping" >>
/local/php/php-7.4.13/etc/php-fpm.d/localhost.conf
echo "access.log = /data/logs/\$pool/\$pool_php-7.4.13.access.log" >>
/local/php/php-7.4.13/etc/php-fpm.d/localhost.conf
echo "slowlog = /data/logs/\$pool/\$pool_php-7.4.13.log.slow" >>
/local/php/php-7.4.13/etc/php-fpm.d/localhost.conf
echo "php_admin_value[error_log] =
/data/logs/\$pool/\$pool_php-7.4.13.log" >>
/local/php/php-7.4.13/etc/php-fpm.d/localhost.conf
echo "php_admin_flag[log_errors] = on" >>
/local/php/php-7.4.13/etc/php-fpm.d/localhost.conf
echo "php_admin_value[error_reporting] = E_ALL" >>
/local/php/php-7.4.13/etc/php-fpm.d/localhost.conf
echo "php_admin_value[session.save_path] =
\"/local/php/sessions/\$pool/\"" >>
/local/php/php-7.4.13/etc/php-fpm.d/localhost.conf
echo "php_value[session.save_path] = \"/local/php/\$pool/\"" >>
/local/php/php-7.4.13/etc/php-fpm.d/localhost.conf
chown -R php-fpm:www /local/php
cp /local/builds/php-7.4.13/sapi/fpm/php-fpm.service
/usr/lib/systemd/system/php-fpm-7.4.13.service
sed -i -e
's/\[Service\]/\[Service\]\nUMask=0007\nUser=php-fpm\nGroup=www/g'
/usr/lib/systemd/system/php-fpm-7.4.13.service
chmod o+r /usr/lib/systemd/system/php-fpm-7.4.13.service
systemctl daemon-reload
systemctl start php-fpm-7.4.13.service
And then, some Apache configuration to send php files to the PHP
socket.
Here is the php code to create the test.txt file :
<?php
$file = '/data/logs/localhost/test.txt';
$current = file_get_contents($file);
$current .= "Une ligne\n";
file_put_contents($file, $current);
?>
Expected result:
----------------
drwxrwx--- 2 php-fpm www 4096 8 déc. 18:17 .
drwxrwxr-x 22 php-fpm www 4096 8 déc. 16:18 ..
-rw-rw---- 1 php-fpm www 82004 9 déc. 09:23
localhost_php-7.4.13.access.log
-rw-rw---- 1 php-fpm www 312 8 déc. 18:17
localhost_php-7.4.13.log
-rw-rw---- 1 php-fpm www 10 8 déc. 18:17 test.txt
Actual result:
--------------
drwxrwx--- 2 php-fpm www 4096 8 déc. 18:17 .
drwxrwxr-x 22 php-fpm www 4096 8 déc. 16:18 ..
-rw------- 1 php-fpm www 82004 9 déc. 09:23
localhost_php-7.4.13.access.log
-rw-r----- 1 php-fpm www 312 8 déc. 18:17
localhost_php-7.4.13.log
-rw-rw---- 1 php-fpm www 10 8 déc. 18:17 test.txt
--
Edit bug report at https://bugs.php.net/bug.php?id=80498&edit=1
--
Fix committed: https://bugs.php.net/fix.php?id=80498&r=fixed
Fixed in release: https://bugs.php.net/fix.php?id=80498&r=alreadyfixed
Need backtrace: https://bugs.php.net/fix.php?id=80498&r=needtrace
Need Reproduce Script: https://bugs.php.net/fix.php?id=80498&r=needscript
Try newer version: https://bugs.php.net/fix.php?id=80498&r=oldversion
Not developer issue: https://bugs.php.net/fix.php?id=80498&r=support
Expected behavior: https://bugs.php.net/fix.php?id=80498&r=notwrong
Not enough info: https://bugs.php.net/fix.php?id=80498&r=notenoughinfo
Submitted twice: https://bugs.php.net/fix.php?id=80498&r=submittedtwice
register_globals: https://bugs.php.net/fix.php?id=80498&r=globals
PHP version support discontinued: https://bugs.php.net/fix.php?id=80498&r=phptooold
Daylight Savings: https://bugs.php.net/fix.php?id=80498&r=dst
IIS Stability: https://bugs.php.net/fix.php?id=80498&r=isapi
Install GNU Sed: https://bugs.php.net/fix.php?id=80498&r=gnused
Floating point limitations: https://bugs.php.net/fix.php?id=80498&r=float
No Zend Extensions: https://bugs.php.net/fix.php?id=80498&r=nozend
MySQL Configuration Error: https://bugs.php.net/fix.php?id=80498&r=mysqlcfg