systemd unable to detect running apache if invoked via "apache2ctl graceful"
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
apache2 (Debian) |
New
|
Unknown
|
|||
apache2 (Ubuntu) |
Triaged
|
High
|
Unassigned | ||
Xenial |
Won't Fix
|
High
|
Unassigned | ||
Bionic |
Fix Released
|
High
|
Bryce Harrington | ||
Focal |
Fix Released
|
High
|
Bryce Harrington | ||
Groovy |
Won't Fix
|
High
|
Unassigned | ||
Hirsute |
Won't Fix
|
High
|
Unassigned | ||
Impish |
Won't Fix
|
High
|
Unassigned | ||
Jammy |
Triaged
|
High
|
Unassigned |
Bug Description
[Impact]
Unattended upgrade will attempt to gracefully reload the Apache2 httpd service, but it reloads apache directly, not via systemd, so systemctl will mis-report the true status. This can cause unexpected and unnecessary server outages when e.g. upgrading from one LTS to another.
[Test Case]
root@server:
root@server:
httpd not running, trying to start
root@server:
? apache2.service - The Apache HTTP Server
Loaded: loaded (/lib/systemd/
Drop-In: /lib/systemd/
Active: inactive (dead) since Mon 2019-06-10 01:04:13 MDT; 17s ago
Process: 27370 ExecStop=
Process: 11462 ExecReload=
Main PID: 1849 (code=exited, status=0/SUCCESS)
Jun 08 19:11:24 server apachectl[1408]: AH00112: Warning: DocumentRoot [/srv/apache2/
Jun 08 19:11:24 server apachectl[1408]: AH00112: Warning: DocumentRoot [/srv/apache2/
Jun 08 19:11:24 server apachectl[1408]: AH00112: Warning: DocumentRoot [/srv/apache2/
Jun 08 19:11:24 server apachectl[1408]: AH00112: Warning: DocumentRoot [/srv/apache2/
Jun 08 19:11:24 server apachectl[1408]: AH00112: Warning: DocumentRoot [/srv/apache2/
Jun 08 19:11:24 server apachectl[1408]: AH00112: Warning: DocumentRoot [/srv/apache2/
Jun 08 19:11:24 server systemd[1]: Started The Apache HTTP Server.
Jun 09 06:25:04 server systemd[1]: Reloading The Apache HTTP Server.
Jun 09 06:25:04 server systemd[1]: Reloaded The Apache HTTP Server.
Jun 10 01:04:13 server apachectl[27370]: httpd (no pid file) not running
Output after customizing the apache2ctl script and restarting it:
root@server:
Invoking 'systemctl start apache2'.
Use 'systemctl status apache2' for more info.
root@server:
? apache2.service - The Apache HTTP Server
Loaded: loaded (/lib/systemd/
Drop-In: /lib/systemd/
Active: active (running) since Mon 2019-06-10 01:04:50 MDT; 4s ago
Process: 27370 ExecStop=
Process: 11462 ExecReload=
Process: 27432 ExecStart=
Main PID: 27444 (apache2)
Tasks: 6 (limit: 2318)
CGroup: /system.
+-27444 /usr/sbin/apache2 -k start
+-27448 /usr/sbin/apache2 -k start
+-27449 /usr/sbin/apache2 -k start
+-27451 /usr/sbin/apache2 -k start
+-27454 /usr/sbin/apache2 -k start
+-27455 /usr/sbin/apache2 -k start
Jun 10 01:04:50 server systemd[1]: Starting The Apache HTTP Server...
Jun 10 01:04:50 server systemd[1]: Started The Apache HTTP Server.
[Fix]
The fix is made somewhat obvious due to the fact that the issue was fixed for "apache2ctl start" in 18.04 LTS by replacing the regular call (which resolves to "/usr/sbin/apache2 -k start") with a check for presence of systemd, followed by an invocation of "systemctl start apache2.service" if that check is affirmative, or falling back to the old start command if that check is negative.
Attached to this bug report is a diff of the file before and after I copied the fixed invocation from the "start" subsection to the "graceful" subsection in 18.04 LTS. A fix for 16.04 LTS would require copying that block both into the "start" and "graceful" subsections.
[Regression Potential]
This alters the behavior of Debian's apache2ctl script for managing the service state. No other Apache2 code is modified. Thus things to watch for new regressions would deal with the apache service's state itself, not crashes or behavioral changes.
With a manual sysadmin-supervised service restart, if there are problems the sysadmin can intervene. The real risk of regression here would be for unsupervised or automated service updates.
[Original Report]
When starting or restarting Apache via the /usr/sbin/
Despite this issue, Apache itself generally runs fine, so this is not an absolutely critical issue, however as both "systemctl status apache2.service" and "service apache2 status" become unable to detect its running state, and as some people may be scripting Apache service checks using those commands, they may experience server outages when they migrate from 14.04 LTS to 16.04 LTS or 18.04 LTS, so this could potentially have serious consequences. I suspect this caused or at least contributed to at least one outage of a web server I am responsible for, as the web file backup script was unable to restart the apache process after stopping it.
This issue affects Ubuntu 16.04 LTS when using "apache2ctl start" or "apache2ctl graceful", and Ubuntu 18.04 LTS just when using "apache2ctl graceful".
[Additional information]
lsb_release -rd :
Description: Ubuntu 18.04.2 LTS
Release: 18.04
apt-cache policy apache2:
apache2:
Installed: 2.4.29-1ubuntu4.6
Candidate: 2.4.29-1ubuntu4.6
Related branches
- Canonical Server: Pending requested
-
Diff: 18 lines (+10/-0) (has conflicts)1 file modifieddebian/changelog (+10/-0)
- Christian Ehrhardt (community): Approve
- git-ubuntu developers: Pending requested
- Canonical Server: Pending requested
-
Diff: 98 lines (+40/-18)2 files modifieddebian/apache2ctl (+30/-18)
debian/changelog (+10/-0)
- Christian Ehrhardt (community): Approve
- git-ubuntu developers: Pending requested
- Canonical Server: Pending requested
-
Diff: 98 lines (+40/-18)2 files modifieddebian/apache2ctl (+30/-18)
debian/changelog (+10/-0)
- Christian Ehrhardt (community): Approve
- git-ubuntu developers: Pending requested
- Canonical Server: Pending requested
-
Diff: 80 lines (+43/-3)2 files modifieddebian/apache2ctl (+36/-3)
debian/changelog (+7/-0)
- Christian Ehrhardt (community): Approve
- git-ubuntu developers: Pending requested
- Canonical Server: Pending requested
-
Diff: 98 lines (+40/-18)2 files modifieddebian/apache2ctl (+30/-18)
debian/changelog (+10/-0)
- Bryce Harrington (community): Approve
- Lucas Kanashiro (community): Needs Fixing
- Canonical Server packageset reviewers: Pending requested
- Canonical Server: Pending requested
-
Diff: 98 lines (+40/-18)2 files modifieddebian/apache2ctl (+30/-18)
debian/changelog (+10/-0)
- Christian Ehrhardt (community): Needs Fixing
- Ubuntu Server Developers: Pending requested
- Canonical Server: Pending requested
-
Diff: 98 lines (+40/-18)2 files modifieddebian/apache2ctl (+30/-18)
debian/changelog (+10/-0)
CVE References
Changed in apache2 (Ubuntu): | |
status: | New → Triaged |
tags: | added: server-next |
Changed in apache2 (Ubuntu): | |
importance: | Undecided → Low |
Changed in apache2 (Debian): | |
status: | Unknown → New |
Changed in apache2 (Ubuntu): | |
status: | Triaged → Fix Committed |
Changed in apache2 (Ubuntu): | |
status: | Fix Committed → Fix Released |
affects: | apache2 (Ubuntu) → apache2 (Juju Charms Collection) |
affects: | apache2 (Juju Charms Collection) → apache2 (Ubuntu) |
Changed in apache2 (Debian): | |
importance: | Unknown → High |
Changed in apache2 (Debian): | |
importance: | High → Unknown |
description: | updated |
Changed in apache2 (Ubuntu Focal): | |
status: | New → Triaged |
importance: | Undecided → High |
Changed in apache2 (Ubuntu Bionic): | |
status: | New → Triaged |
Changed in apache2 (Ubuntu Xenial): | |
status: | New → Triaged |
Changed in apache2 (Ubuntu Bionic): | |
importance: | Undecided → High |
Changed in apache2 (Ubuntu Xenial): | |
importance: | Undecided → High |
Changed in apache2 (Ubuntu Groovy): | |
assignee: | nobody → Bryce Harrington (bryce) |
description: | updated |
Changed in apache2 (Ubuntu Xenial): | |
status: | Triaged → Fix Committed |
Changed in apache2 (Ubuntu Bionic): | |
status: | Triaged → Fix Committed |
Changed in apache2 (Ubuntu Focal): | |
status: | Triaged → Fix Committed |
Changed in apache2 (Ubuntu Groovy): | |
status: | Triaged → Fix Committed |
Changed in apache2 (Ubuntu Hirsute): | |
status: | Triaged → Fix Committed |
Changed in apache2 (Ubuntu Focal): | |
assignee: | nobody → Bryce Harrington (bryce) |
Changed in apache2 (Ubuntu Bionic): | |
assignee: | nobody → Bryce Harrington (bryce) |
Changed in apache2 (Ubuntu Xenial): | |
assignee: | nobody → Bryce Harrington (bryce) |
Changed in apache2 (Ubuntu Xenial): | |
status: | Fix Committed → In Progress |
tags: |
added: verification-done removed: regression-proposed verification-failed-xenial verification-needed xenial |
Changed in apache2 (Ubuntu Impish): | |
status: | New → Triaged |
importance: | Undecided → High |
tags: | removed: server-next |
Output showing how to reproduce the issue:
root@server: /usr/local/ sbin# apache2ctl stop /usr/local/ sbin# apache2ctl graceful /usr/local/ sbin# systemctl status apache2.service system/ apache2. service; enabled; vendor preset: enabled) system/ apache2. service. d
+-apache2- systemd. conf /usr/sbin/ apachectl stop (code=exited, status=0/SUCCESS) /usr/sbin/ apachectl graceful (code=exited, status=0/SUCCESS)
root@server:
httpd not running, trying to start
root@server:
? apache2.service - The Apache HTTP Server
Loaded: loaded (/lib/systemd/
Drop-In: /lib/systemd/
Active: inactive (dead) since Mon 2019-06-10 01:04:13 MDT; 17s ago
Process: 27370 ExecStop=
Process: 11462 ExecReload=
Main PID: 1849 (code=exited, status=0/SUCCESS)
Jun 08 19:11:24 server. [redacted2] .com apachectl[1408]: AH00112: Warning: DocumentRoot [/srv/apache2/ www/[redacted0] [redacted2] .com apachectl[1408]: AH00112: Warning: DocumentRoot [/srv/apache2/ www/[redacted0] [redacted2] .com apachectl[1408]: AH00112: Warning: DocumentRoot [/srv/apache2/ www/[redacted1] .c [redacted2] .com apachectl[1408]: AH00112: Warning: DocumentRoot [/srv/apache2/ www/[redacted1] .c [redacted2] .com apachectl[1408]: AH00112: Warning: DocumentRoot [/srv/apache2/ www/[redacted1] [redacted2] .com apachectl[1408]: AH00112: Warning: DocumentRoot [/srv/apache2/ www/[redacted1] [redacted2] .com systemd[1]: Started The Apache HTTP Server. [redacted2] .com systemd[1]: Reloading The Apache HTTP Server. [redacted2] .com systemd[1]: Reloaded The Apache HTTP Server. [redacted2] .com apachectl[27370]: httpd (no pid file) not running
Jun 08 19:11:24 server.
Jun 08 19:11:24 server.
Jun 08 19:11:24 server.
Jun 08 19:11:24 server.
Jun 08 19:11:24 server.
Jun 08 19:11:24 server.
Jun 09 06:25:04 server.
Jun 09 06:25:04 server.
Jun 10 01:04:13 server.
Output after customizing the apache2ctl script and restarting it:
root@server: /usr/local/ sbin# apache2ctl_custom graceful /usr/local/ sbin# systemctl status apache2.service system/ apache2. service; enabled; vendor preset: enabled) system/ apache2. service. d
+-apache2- systemd. conf /usr/sbin/ apachectl stop (code=exited, status=0/SUCCESS) /usr/sbin/ apachectl graceful (code=exited, status=0/SUCCESS) /usr/sbin/ apachectl start (code=exited, status=0/SUCCESS) slice/apache2. service
Invoking 'systemctl start apache2'.
Use 'systemctl status apache2' for more info.
root@server:
? apache2.service - The Apache HTTP Server
Loaded: loaded (/lib/systemd/
Drop-In: /lib/systemd/
Active: active (running) since Mon 2019-06-10 01:04:50 MDT; 4s ago
Process: 27370 ExecStop=
Process: 11462 ExecReload=
Process: 27432 ExecStart=
Main PID: 27444 (apache2)
Tasks: 6 (limit: 2318)
CGroup: /system.
+-27444 /usr/sbin/apache2 -k start
+-27448 /usr/sbin/apache2 -k start
+-27449 /usr/sbin/apache2 -k start
+-27451 /usr/sbin/apache2 -k start
+-27454 /usr/sbin/apache2 -k start
+-27455 /usr/sbin/apache2 -k start
Jun 10 01:04:50 server. [redacted2] .com systemd[1]: Starting The Apache HTTP Server... [redacted2] .com systemd[1]: Started The Apache HTTP Server.
Jun 10 01:04:50 server.