Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 673530 - www-servers/apache: apache2ctl broken on systemd installations
Summary: www-servers/apache: apache2ctl broken on systemd installations
Status: RESOLVED FIXED
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: Current packages (show other bugs)
Hardware: All Linux
: Normal normal (vote)
Assignee: Lars Wendler (Polynomial-C) (RETIRED)
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2018-12-21 14:26 UTC by Manuel Nickschas
Modified: 2019-04-11 14:26 UTC (History)
1 user (show)

See Also:
Package list:
Runtime testing required: ---


Attachments
Proposed patch for apache2ctl that supports systemd (0001-apache2ctl-Add-suport-for-systemd.patch,6.17 KB, patch)
2019-03-26 23:02 UTC, Michael Strache
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Manuel Nickschas 2018-12-21 14:26:43 UTC
apache2ctl is supposed to be a wrapper/forwarding script that allows controlling apache in a more-or-less distro-unspecific way. On Gentoo, this script sources the openrc init file, and thus fails on systemd installations:

sirius ~ # apache2ctl configtest
/usr/sbin/apache2ctl: /etc/init.d/apache2: /sbin/openrc-run: bad interpreter: No such file or directory
/usr/sbin/apache2ctl: line 21: /etc/init.d/apache2: Success

I guess one could just disable the list of supported verbs to be forwarded to the init script in case systemd is used as the init system, thus running the commands directly on the apache binary after sourcing the configuration.
Comment 1 Nico Baggus 2019-02-18 20:52:27 UTC
This is mentioned here:

https://github.com/certbot/certbot/issues/3411#issuecomment-464845143
Comment 2 Lars Wendler (Polynomial-C) (RETIRED) gentoo-dev 2019-02-26 15:53:09 UTC
Patches are highly welcome especially as I don't use systemd anywhere.

If you wanna create a patch against latest apache2ctl, please use the following git repo and attach a git-formatted patch to this bug:

https://gitweb.gentoo.org/proj/apache.git/
Comment 3 Michael Strache 2019-03-26 23:02:50 UTC
Created attachment 570900 [details, diff]
Proposed patch for apache2ctl that supports systemd

Being annoyed by this bug for quite a while now I finally rewrote the apache2ctl script to add systemd support.

My suggested fix basically has two modes of operation:

If systemd is NOT detected, it behaves exactly like it used to (using the original code). I intentionally decided to use a negative test to ensure that the new code only is used if systemd is detected.

If systemd IS detected, it does not call "/etc/init.d/apache2" anymore but maps every item in RC_VERBS to the corresponding systemd service command. For items without a matching service command, actually the majority, it calls a function with the original code from "/etc/init.d/apache2", slightly modified to run without open-rc (mostly replacing "eerror" with a simple "echo").

In my tests this worked fine, so I hope it does the trick. In any case, I am open for suggestions.
Comment 4 Larry the Git Cow gentoo-dev 2019-04-02 08:39:46 UTC
The bug has been referenced in the following commit(s):

https://gitweb.gentoo.org/proj/apache.git/commit/?id=fcc7da95dd75910085a8c688b8ec5d25ba11bd1e

commit fcc7da95dd75910085a8c688b8ec5d25ba11bd1e
Author:     Lars Wendler <polynomial-c@gentoo.org>
AuthorDate: 2019-04-02 08:31:45 +0000
Commit:     Lars Wendler <polynomial-c@gentoo.org>
CommitDate: 2019-04-02 08:39:12 +0000

    Several fixes to previous apache2ctl systemd enhancement
    
    - Attempt to keep the script POSIX sh compliant
    - Don't use "function" prefix
    - Use curly braces for variables
    - Fixed indentation
    - Put code for systemd into an "else" part
    - Renamed "ERROR" variable to "retval"
    - Made some variables local
    - Put the systemd apache2 service file reference into a variable
    
    Bug: https://bugs.gentoo.org/673530
    Signed-off-by: Lars Wendler <polynomial-c@gentoo.org>

 2.4/scripts/apache2ctl | 198 ++++++++++++++++++++++++-------------------------
 1 file changed, 97 insertions(+), 101 deletions(-)
Comment 5 Larry the Git Cow gentoo-dev 2019-04-02 08:54:24 UTC
The bug has been referenced in the following commit(s):

https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=9ba34aa34c25d07f495ae56fc56a2bbaab5d4dd6

commit 9ba34aa34c25d07f495ae56fc56a2bbaab5d4dd6
Author:     Lars Wendler <polynomial-c@gentoo.org>
AuthorDate: 2019-04-02 08:50:44 +0000
Commit:     Lars Wendler <polynomial-c@gentoo.org>
CommitDate: 2019-04-02 08:54:13 +0000

    www-servers/apache: Security bump to version 2.4.39
    
    Attempt to make apache2ctl systemd compatible
    
    Bug: https://bugs.gentoo.org/673530
    Bug: https://bugs.gentoo.org/682306
    Package-Manager: Portage-2.3.62, Repoman-2.3.12
    Signed-off-by: Lars Wendler <polynomial-c@gentoo.org>

 www-servers/apache/Manifest             |   2 +
 www-servers/apache/apache-2.4.39.ebuild | 257 ++++++++++++++++++++++++++++++++
 2 files changed, 259 insertions(+)
Comment 6 Lars Wendler (Polynomial-C) (RETIRED) gentoo-dev 2019-04-02 09:02:55 UTC
Please test apache2ctl from >=www-servers/apache-2.4.39 and report back success/failure to this bug.
Comment 7 Michael Strache 2019-04-02 21:51:48 UTC
Thanks for the additional QA. I tested www-servers/apache-2.4.39 and the script worked as intended.

I also was able to run Certbot on my systemd host for the very first time without any hacks, thanks a lot for that too :D