Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 598468 - www-servers/lighttpd: init file hangs on read-only filesystem
Summary: www-servers/lighttpd: init file hangs on read-only filesystem
Status: RESOLVED FIXED
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: Current packages (show other bugs)
Hardware: All Linux
: Normal normal (vote)
Assignee: Patrice Clement
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2016-10-29 18:47 UTC by Marek Behún
Modified: 2022-01-21 12:17 UTC (History)
2 users (show)

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


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Marek Behún 2016-10-29 18:47:52 UTC
The init file /etc/init.d/lighttpd contains a line

LIGHTTPD_PID="$($(which lighttpd) -pf ${LIGHTTPD_CONF} | grep pid | cut -d '=' -f 2 | tr -d \\\" | tr -d [:space:])"

This line runs the lighttpd program with the -p flag to print parsed configuration.

The problem is that when the filesystem is in read-only state, for example when booting, lighttpd -p hangs (I don't know if it wants to write somewhere or what...). Thus this command hangs.

This file is called from /lib/rc/sh/gendepends.sh to get service dependencies, before setting the filesystem read-write, thus hanging the boot process of the whole system.

As a result the system hangs on booting after writing the lice
Caching service dependencies.

I had to change the line to

LIGHTTPD_PID="$(cat ${LIGHTTPD_CONF} | grep pid | cut -d '=' -f 2 | tr -d \\\" | tr -d [:space:])"

to make it work.
Comment 1 Patrice Clement gentoo-dev 2016-10-29 18:56:31 UTC
Hi. I'm OK that change. We could even remove one shell spawn by avoiding calling cat:
LIGHTTPD_PID="$(grep pid ${LIGHTTPD_CONF} | cut -d '=' -f 2 | tr -d \\\" | tr -d [:space:])"

Could you try and report back? It should work as well. If it does, I'll commit the change straight away.
Comment 2 Marek Behún 2016-10-29 23:46:23 UTC
(In reply to Patrice Clement from comment #1)
> Hi. I'm OK that change. We could even remove one shell spawn by avoiding
> calling cat:
> LIGHTTPD_PID="$(grep pid ${LIGHTTPD_CONF} | cut -d '=' -f 2 | tr -d \\\" |
> tr -d [:space:])"
> 
> Could you try and report back? It should work as well. If it does, I'll
> commit the change straight away.

working
Comment 3 zlg (RETIRED) gentoo-dev 2016-10-31 10:43:22 UTC
Ah, nice catch! The change looks good to me.
Comment 4 zlg (RETIRED) gentoo-dev 2016-11-20 10:20:37 UTC
The improved version of the fix (monsieurp's) was added to the Gentoo repository. Re-sync and re-emerge lighttpd to receive the updated copy.

Commit ID: 258e3475e0eda930f424d3141cb3ba9fc0f87a9a

Thanks for reporting, Marek!
Comment 5 Sergei Trofimovich (RETIRED) gentoo-dev 2016-11-26 15:10:24 UTC
Thank for the fix!

I looked at hangup issue today on virtual server.

It hung for me because 'lighttpd -t' called 'getrandom()'
which blocks unless random pool is initialized in kernel.
As a result boot took 3 minutes.

Openrc calls gendepend (and 'lighttpd -t' at top level)
even before /etc/init.d/urandom is called.
/etc/init.d/urandom is supposed to refill entropy pool
after previous boot.
Comment 6 Sergei Trofimovich (RETIRED) gentoo-dev 2016-11-26 15:21:04 UTC
I also suggest revbumping ebuilds for users to pull init.d change sooner.
Comment 7 gstrauss 2022-01-21 12:06:35 UTC
lighttpd 1.4.44 was released in Dec 2016 (the month following the discussion here) and deferred the call to li_rand_init().  That change in lighttpd 1.4.44 should have addressed the issue raised here.

The change made here to LIGHTTPD_PID in /etc/init.d/lighttpd, should probably be reverted, as it has caused problems.  See https://bugs.gentoo.org/626688, where I have referred back to this issue and suggested the same solution.