Bug 15948 - lighttpd: wrong postrotate clause in /etc/logrotate.d/lighttpd
Summary: lighttpd: wrong postrotate clause in /etc/logrotate.d/lighttpd
Status: RESOLVED FIXED
Alias: None
Product: Mageia
Classification: Unclassified
Component: RPM Packages (show other bugs)
Version: 4
Hardware: All Linux
Priority: Normal normal
Target Milestone: ---
Assignee: Mageia Bug Squad
QA Contact:
URL:
Whiteboard:
Keywords: PATCH
Depends on: 16555
Blocks:
  Show dependency treegraph
 
Reported: 2015-05-15 19:02 CEST by Luca Olivetti
Modified: 2015-09-08 17:26 CEST (History)
1 user (show)

See Also:
Source RPM: lighttpd
CVE:
Status comment:


Attachments

Description Luca Olivetti 2015-05-15 19:02:51 CEST
The postrotate clause in /etc/logrotate.d/lighttpd says

   service lighttpd reload

however:

# service lighttpd reload
Redirecting to /bin/systemctl reload lighttpd.service
Failed to issue method call: Job type reload is not applicable for unit lighttpd.service.


a working postrotate clause is:

   systemctl kill --signal=SIGHUP lighttpd

I see this with mageia 4, but looking at the package in cauldron http://svnweb.mageia.org/packages/cauldron/lighttpd/current/SPECS/lighttpd.spec?revision=744835&view=markup it suffers from the same problem.
The logrotate file is generated in the spec file, line 232.
Changing 

   service %{name} reload

to
    systemctl kill --signal=SIGHUP %{name}

should fix the problem.
Comment 1 Luca Olivetti 2015-05-15 19:09:20 CEST
fedora uses "killall -HUP" instead of "systemctl kill --signal=SIGHUP"

http://pkgs.fedoraproject.org/cgit/lighttpd.git/tree/lighttpd.logrotate
Manuel Hiebel 2015-05-15 21:41:41 CEST

Keywords: (none) => PATCH
Source RPM: (none) => lighttpd

Comment 2 David Walser 2015-05-16 12:45:27 CEST
Thanks.  Since lighttpd does accept the HUP signal, the better fix would be to fix the systemd unit so that it does accept the reload argument.

CC: (none) => luigiwalser

Comment 3 David Walser 2015-05-18 20:25:53 CEST
Try adding this to lighttpd.service and let me know if it works.

(in the [Service] section)
ExecReload=/bin/kill -HUP $MAINPID
Comment 4 Luca Olivetti 2015-05-18 21:21:09 CEST
I don't like it because it isn't actually reloading the configuration[*], it just closes and reopens the log files, but it works (actually I put an override in /etc/systemd/system/lighttpd.service):

.include /lib/systemd/system/lighttpd.service
[Service]
ExecReload=/bin/kill -HUP $MAINPID



Then issuing a "service lighttpd reload" I see this in /var/log/lighttpd/error.log

2015-05-18 21:14:29: (server.c.1242) logfiles cycled UID = 0 PID = 32178

so it works.


BTW this is what debian does, and I prefer either my solution or fedora's one, but whatever works is fine.

[*]from systemctl manpage:

      reload NAME...
           Asks all units listed on the command line to reload their configuration. Note that this will reload the service-specific configuration, not the unit configuration file of systemd. If
           you want systemd to reload the configuration file of a unit, use the daemon-reload command. In other words: for the example case of Apache, this will reload Apache's httpd.conf in the
           web server, not the apache.service systemd unit file.
Comment 5 David Walser 2015-05-18 21:25:28 CEST
If it doesn't reload the config files, that's not good.  I thought it might, having seen this:
http://redmine.lighttpd.net/projects/lighttpd/wiki/ScriptsCentOS

but maybe that init script was no good too.

I did also find this.  It's very old, but maybe it still is valid:
http://blog.lighttpd.net/articles/2005/09/02/graceful-restart/

So maybe that would translate to this?

ExecReload=/bin/kill -INT $MAINPID && /usr/sbin/lighttpd -f /etc/lighttpd/lighttpd.conf
Comment 6 Luca Olivetti 2015-05-18 21:33:02 CEST
The first script probably just abuses reload in order to write a "nice" logrotate conf file (as in debian), the second I don't know if it works or not, for me a stop/start is good enough, but this bug is about logrotate.
Comment 7 Luca Olivetti 2015-05-18 21:41:45 CEST
BTW, it doesn't work:

# systemctl reload lighttpd
Job for lighttpd.service failed. See 'systemctl status lighttpd.service' and 'journalctl -xn' for details.
# systemctl status lighttpd
lighttpd.service - Lightning Fast Webserver With Light System Requirements
   Loaded: loaded (/etc/systemd/system/lighttpd.service; enabled)
   Active: failed (Result: exit-code) since dl 2015-05-18 21:35:59 CEST; 3s ago
  Process: 672 ExecReload=/bin/kill -INT $MAINPID && /usr/sbin/lighttpd -f /etc/lighttpd/lighttpd.conf (code=exited, status=1/FAILURE)
 Main PID: 543 (code=exited, status=0/SUCCESS)

And this is /var/log/lighttpd/error.log

2015-05-18 21:33:32: (server.c.1430) unlink failed for: /run/lighttpd/lighttpd.pid 2 No such file or directory 
2015-05-18 21:33:32: (server.c.1430) unlink failed for: /run/lighttpd/lighttpd.pid 2 No such file or directory 
2015-05-18 21:33:32: (server.c.1442) [note] graceful shutdown started 
2015-05-18 21:33:32: (server.c.1558) server stopped by UID = 0 PID = 31970 



so I wouldn't touch ExecReload
Comment 8 Luca Olivetti 2015-05-18 21:49:09 CEST
lighttpd is not very good at logging errors: running the above on the command line I see that it fails to bind the port because the previous instance is still using it

# kill -INT 1241 && /usr/sbin/lighttpd -f /etc/lighttpd/lighttpd.conf
2015-05-18 21:45:52: (network.c.405) can't bind to port: 192.168.1.62 80 Address already in use 

So, really, don't touch ExecReload
Comment 9 David Walser 2015-05-18 22:21:53 CEST
Bummer.  It would be good to get proper reload support implemented.

I checked into SVN Fedora's killall method in logrotate.  Hopefully this doesn't hurt any child processes.
Comment 10 Luca Olivetti 2015-05-18 22:34:23 CEST
AFAIK there shouldn't be any child process.
FWIW, even if it's not the subject of this bug, I found this:
http://lists.freedesktop.org/archives/systemd-devel/2011-January/001067.html

and it turns out there is a lighttpd-angel binary shipped with the rpm.

Don't know why nobody seems to be using it in their init scripts.
Comment 11 David Walser 2015-05-18 22:41:50 CEST
Yeah, it seems to be an unresolved issue.
Comment 12 Luca Olivetti 2015-05-19 09:45:37 CEST
I opened bug #15980 for a systemd unit file using lighttpd-angel
Samuel Verschelde 2015-05-19 09:56:04 CEST

Version: 4 => Cauldron
Whiteboard: (none) => MGA4TOO

Comment 13 David Walser 2015-05-19 15:15:22 CEST
lighttpd-1.4.35-4.mga5 already fixed this bug for Cauldron yesterday.

Version: Cauldron => 4
Whiteboard: MGA4TOO => (none)

Comment 14 Luca Olivetti 2015-05-19 15:36:12 CEST
Thank you

Status: NEW => RESOLVED
Resolution: (none) => FIXED

Comment 15 Samuel Verschelde 2015-05-19 15:40:56 CEST
It's still present in Mageia 4, Luca.

Status: RESOLVED => REOPENED
Resolution: FIXED => (none)

David Walser 2015-09-02 17:20:38 CEST

Depends on: (none) => 16555

Comment 16 David Walser 2015-09-08 17:26:33 CEST
Fixed in:
http://advisories.mageia.org/MGASA-2015-0338.html

Status: REOPENED => RESOLVED
Resolution: (none) => FIXED


Note You need to log in before you can comment on or make changes to this bug.