I'm using Debian 7.8 (wheezy), and lighttpd 1.4.31 with nagios 3.4.1.
when I start lighttpd normally (as root), everything works as expected:
/etc/init.d/lighttpd start
However, when nagios starts lighttpd, everything issues a 404 error, and nothing is logged to /var/log/lighttpd/access.log
or /var/log/lighttpd/error.log
. I can mimic the same behavior manually by issuing the following command as root:
su - nagios -s /usr/bin/sudo /etc/init.d/lighttpd start
The nagios daemon has sudo access, as defined in /etc/sudoers.d/nagios
:
nagios ALL=(root) NOPASSWD: /etc/init.d/lighttpd *
What am I missing? What's the difference between starting lighttpd directly as root, and doing it as the nagios user via sudo?
Is nagios _actually_using_ sudo when it's starting lighttpd ?
So, is it running 'sudo /etc/init.d/lighttpd start', or is it running '/etc/init.d/lighttpd start'.
When not running from sudo... it won't run as root, and therefor won't work.
If in doubt... edit the /etc/init.d/lighttpd script, and let it print it's user in the beginning with something like:
id > /tmp/ligghtpd.start.$$
And then inspect the /tmp/ligghtpd.start.* files.