lighttpd reload executes restart (bad on logrotate!)

Bug #393792 reported by stiV
262
This bug affects 1 person
Affects Status Importance Assigned to Milestone
apache2 (Debian)
Fix Released
Unknown
apache2 (Ubuntu)
Invalid
Undecided
Unassigned
lighttpd (Ubuntu)
Fix Released
Medium
Unassigned

Bug Description

The logrotate script of lighttpd does a lighttpd reload, which is what it should do, but if I stop the lighttpd daemon manually I certainly do NOT want it to be started again by the log rotation. reload should NOT start a daemon if it is not running IMO.

restart -> stop and start
reload -> reload config (for some this is also stop/start, but it should only be executed if the daemon was running before.)

This is a security issue, because if someone does not know that and intentionally stops the server for some reason and wants to leave it that way eg. for testing or so, the server gets started and may run with faulty software. (happened to me)

Related branches

stiV (stefan-wehinger)
visibility: private → public
summary: - lighttpd reload executes restart logrotate
+ lighttpd reload executes restart (bad on logrotate!)
Revision history for this message
stiV (stefan-wehinger) wrote :
Revision history for this message
stiV (stefan-wehinger) wrote :

I think the right thing to do is changing the init script to actually perform a "reload" when reload is called. restart or force-reload stay the same, reload checks if lighttpd is running, and only performs the restart if it is

  reload)
        log_daemon_msg "Reloading $DESC configuration" $NAME
        if [ ! -e $PIDFILE ]; then
                log_daemon_msg "$DESC not running, not doing anything" $NAME
                log_end_msg 0
        else
                if $SSD --stop --signal 2 --oknodo --retry 30\
                --quiet --pidfile $PIDFILE --exec $DAEMON; then
                        if $ENV $SSD --start --quiet \
                        --pidfile $PIDFILE --exec $DAEMON -- $DAEMON_OPTS ; then
                        log_end_msg 0
                        else
                        log_end_msg 1
                        fi
                else
                        log_end_msg 1
                fi
        fi

Changed in lighttpd (Ubuntu):
importance: Undecided → Low
status: New → Confirmed
Revision history for this message
stiV (stefan-wehinger) wrote :

I'm sorry, but starting potentially harmful software like a webserver with a buggy webpage without the administrator knowing it (who would expect that a service that got shutdown manually just appears again?) should really not be a "low" priority, especially since it's easy to fix...

imho this is an absolut no-go for server software and should be fixed in all release asap (even if up until now nobody noticed or cared to report about it)

This is a packaging issue and an issue of how standards are met. I can be wrong, but "reload" isn't supposed to start a service, is it?

Daniel Hahler (blueyed)
Changed in lighttpd (Ubuntu):
importance: Low → Medium
status: Confirmed → Triaged
Revision history for this message
stiV (stefan-wehinger) wrote :

Thanks for upping the priority ...

I just tried it, and this also happens if lighty is not automatically started in a runlevel. It just starts (or at least tries to start) at 22 minutes after the full hour (logrotate) - this may even be an upstream bug, i guess it's the same in debian (don't have any debian installed right now to test)

Revision history for this message
stiV (stefan-wehinger) wrote :

sorry - it tries that once a day (daily logrotate), i just changed my logrotating to be hourly because of logfile size restrictions.

Revision history for this message
Daniel Hahler (blueyed) wrote :

I could not find any documentation, if "reload" should start a not already running service.
("9.3.2 Writing the scripts" in the Debian Policy Manual (http://www.debian.org/doc/debian-policy/ch-opersys.html) talks about this)

However, Apache does the same (via "apache2ctl graceful"):
$ sudo apache2ctl graceful
httpd not running, trying to start

But, apache2's logrotate script checks if it is running:
        postrotate
                if [ -f "`. /etc/apache2/envvars ; echo ${APACHE_PID_FILE:-/var/run/apache2.pid}`" ]; then
                        /etc/init.d/apache2 reload > /dev/null
                fi
        endscript

I think the same should get done for lighttpd's logrotate script, too.
I'm adding an apache2 task.

Revision history for this message
Daniel Hahler (blueyed) wrote :

Apache appears to remove its pidfile on shutdown, and therefore the "pidfile exists" test works for checking if it is running.

For lighttpd, we could manually remove the pidfile in the init script's "stop" action!?

Changed in apache2 (Ubuntu):
status: New → Invalid
Revision history for this message
Launchpad Janitor (janitor) wrote :

This bug was fixed in the package lighttpd - 1.4.22-1ubuntu3

---------------
lighttpd (1.4.22-1ubuntu3) karmic; urgency=low

  * debian/lighttpd.logrotate: check if lighttpd is running, before
    calling reload, which would start the daemon if it is not running
    currently (LP: #393792)

 -- Daniel Hahler <email address hidden> Fri, 03 Jul 2009 01:05:29 +0200

Changed in lighttpd (Ubuntu):
status: Triaged → Fix Released
Revision history for this message
Daniel Hahler (blueyed) wrote :

To get this fix into released branches (e.g. "Hardy"), please refer to https://wiki.ubuntu.com/SRU

Changed in apache2 (Debian):
status: Unknown → Fix Released
To post a comment you must log in.
This report contains Public Security information  
Everyone can see this security related information.

Other bug subscribers

Remote bug watches

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