If php.ini is incorrect, php-frm starts without warning with default values

Bug #1623540 reported by selivan
8
This bug affects 1 person
Affects Status Importance Assigned to Milestone
php7.0 (Ubuntu)
Triaged
Medium
Nish Aravamudan
Xenial
Triaged
Medium
Nish Aravamudan

Bug Description

OS: Ubuntu 16.04 Xenial
PHP: php7.0-fpm 7.0.8-0ubuntu0.16.04.2

If /etc/php/7.0/fpm/php.ini has syntax error, php7.0-fpm starts silently (!! no error messages even in logs), but uses default values.

To make php.ini incorrect, just add this line:

# Wrong comment (

Systemd servive unit for php7.0-fpm has config check:

ExecStartPre=/usr/lib/php/php7.0-fpm-checkconf

But is does not work:

root@xenial:~# /usr/sbin/php-fpm7.0 --fpm-config /etc/php/7.0/fpm/php-fpm.conf --test
PHP: syntax error, unexpected '(' in /etc/php/7.0/fpm/php.ini on line 6
[14-Sep-2016 14:24:46] NOTICE: configuration file /etc/php/7.0/fpm/php-fpm.conf test is successful

root@xenial:~# /usr/lib/php/php7.0-fpm-checkconf; echo $?
0

So, if php.ini is incorrect, php-fpm silently starts with default values: post_max_size=8m, expose_php is enabled, disable_functions is empty and so on.

selivan (selivan5)
description: updated
Revision history for this message
Nish Aravamudan (nacc) wrote :

Hello and thank you for reporting this bug.

With 16.10, the helper script has been removed, so the problem is not exactly reproducible. With 16.04, it looks to be a simple typo with the grep ([ERROR] rather than ERROR) in the script. Modifying it in that way leads to a successful prevention of php-fpm starting on parse errors. I will work on fixing 16.10 (if possible) and then SRU'ing the fix for 16.04.

Thanks,
Nish

Changed in php7.0 (Ubuntu):
status: New → Triaged
importance: Undecided → High
Changed in php7.0 (Ubuntu Xenial):
status: New → Triaged
importance: Undecided → High
Changed in php7.0 (Ubuntu):
assignee: nobody → Nish Aravamudan (nacc)
Changed in php7.0 (Ubuntu Xenial):
assignee: nobody → Nish Aravamudan (nacc)
Revision history for this message
Nish Aravamudan (nacc) wrote :

16.10's dropping of the helper script, I believe, perhaps in coordination with other changes, means that if you make a similar modification there and try to restart the service you get:

# service php7.0-fpm restart
Job for php7.0-fpm.service failed because the control process exited with error code.
See "systemctl status php7.0-fpm.service" and "journalctl -xe" for details.

So it's already fixed in 16.10. I'll look at what's needed to make the same occur in 16.04.

Changed in php7.0 (Ubuntu):
status: Triaged → Invalid
assignee: Nish Aravamudan (nacc) → nobody
Revision history for this message
Nish Aravamudan (nacc) wrote :

While the helper script can/should be fixed, I'm actually unable to reproduce this on 16.04:

# vi /etc/php/7.0/fpm/php-fpm.conf
[insert: "# wrong comment (" at the top of the file]
# service php7.0-fpm restart
Job for php7.0-fpm.service failed because the control process exited with error code. See "systemctl status php7.0-fpm.service" and "journalctl -xe" for details.

Can you give more details on how you installed php-fpm? Was this an upgrade from 14.04? Or did you install 16.04 at release and follow the normal upgrade paths to 16.04.1?

Changed in php7.0 (Ubuntu):
importance: High → Undecided
Changed in php7.0 (Ubuntu Xenial):
importance: High → Low
status: Triaged → Incomplete
assignee: Nish Aravamudan (nacc) → nobody
Revision history for this message
selivan (selivan5) wrote :

> # vi /etc/php/7.0/fpm/php-fpm.conf

no, you should do

# vi /etc/php/7.0/fpm/php.ini

It handles errors in php-fpm.conf, but silently ignores in php.ini

Revision history for this message
selivan (selivan5) wrote :

First I saw this bug on trusty with php7 ppa, where I upgraded from 5.5 by copying php.ini. It had inside comment like "# blablabla (see foobar)".

I created bug report for ppa owner: https://github.com/oerdnj/deb.sury.org/issues/456

Then I reproduced it out on newly created xenial instance in AWS and reported it here.

Revision history for this message
Nish Aravamudan (nacc) wrote :

Sorry for my mistake! I have corrected the tasks states -- and reproduce the issue on 16.10.

Changed in php7.0 (Ubuntu Xenial):
status: Incomplete → Triaged
importance: Low → Medium
Changed in php7.0 (Ubuntu):
status: Invalid → Triaged
importance: Undecided → Medium
assignee: nobody → Nish Aravamudan (nacc)
Changed in php7.0 (Ubuntu Xenial):
assignee: nobody → Nish Aravamudan (nacc)
Revision history for this message
selivan (selivan5) wrote :

Also reported it directly to php guys: https://bugs.php.net/bug.php?id=73099

Revision history for this message
Nish Aravamudan (nacc) wrote : Re: [Bug 1623540] Re: If php.ini is incorrect, php-frm starts without warning with default values

Thank you for doing that, I do believe it is an upstream issue
(possibly for all SAPIs) that php.ini parse failure doesn't
immediately lead to exit.

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.