Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 810431 - supervise-daemon keeps reporting service as stopped wrongly
Summary: supervise-daemon keeps reporting service as stopped wrongly
Status: CONFIRMED
Alias: None
Product: Gentoo Hosted Projects
Classification: Unclassified
Component: OpenRC (show other bugs)
Hardware: All Linux
: Normal normal (vote)
Assignee: OpenRC Team
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2021-08-25 21:46 UTC by Robin Johnson
Modified: 2024-03-03 22:05 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 Robin Johnson archtester Gentoo Infrastructure gentoo-dev Security 2021-08-25 21:46:46 UTC
# qlist -Iv |grep openrc
sys-apps/openrc-0.43.5

# grep -e . /var/run/snmpd-supervise.pid /var/run/snmpd.pid


/var/run/snmpd-supervise.pid:30047
/var/run/snmpd.pid:17242

# ps faux |grep [s]nmpd
root     30047  0.0  0.0   2900  1288 ?        S    Aug21   0:00 supervise-daemon snmpd --start --pidfile /var/run/snmpd-supervise.pid /usr/sbin/snmpd -- -p /var/run/snmpd.pid -Lsd -Lf /dev/null -x /var/agentx/master -f
root     17242  0.1  0.0  24012 12236 ?        Ss   Aug24   1:42  \_ /usr/sbin/snmpd -p /var/run/snmpd.pid -Lsd -Lf /dev/null -x /var/agentx/master -f

# rc-status -a |grep snmpd
 snmpd                                                             [  stopped  ]

# grep -v -e '^#' -e '^$' /etc/conf.d/snmpd
SNMPD_FLAGS="-Lsd -Lf /dev/null -x /var/agentx/master -f"
supervisor="supervise-daemon"

# diff /usr/portage/net-analyzer/net-snmp/files/snmpd.init.2 /etc/init.d/snmpd  -Nuar
--- /usr/portage/net-analyzer/net-snmp/files/snmpd.init.2       2017-02-28 20:43:13.000000000 +0000
+++ /etc/init.d/snmpd   2021-08-05 22:47:51.110642303 +0000
@@ -8,7 +8,7 @@
 
 command="/usr/sbin/snmpd"
 command_args="-p ${SNMPD_PIDFILE} ${SNMPD_FLAGS}"
-pidfile="${SNMPD_PIDFILE}"
+pidfile="/var/run/snmpd-supervise.pid"
 
 depend() {
        use logger
Comment 1 Alec Warner (RETIRED) archtester gentoo-dev Security 2021-08-25 22:59:31 UTC
/run/openrc/failed/snmpd exists so openrc thinks the service is failed.

service_started => looks for /run/openrc/started/snmpd; which is absent which is why we think the service is not in state running (and e.g. /etc/init.d/snmpd status returns 'stopped'.) Failed is a subset of stopped ;)

We then arrive at the open question of "why did openrc mark the service as failed when it is not failed." We need a PoC for that.

-A
Comment 2 Robin Johnson archtester Gentoo Infrastructure gentoo-dev Security 2021-08-25 23:03:52 UTC
infra /etc/snmp/snmpd.conf:

disk  / 10%
load 12 12 12
syslocation  Gentoo Infrastructure
syscontact  "root@gentoo.org"
sysservices 72
Comment 3 Alec Warner (RETIRED) archtester gentoo-dev Security 2021-08-25 23:23:09 UTC
(In reply to Alec Warner from comment #1)
> /run/openrc/failed/snmpd exists so openrc thinks the service is failed.
> 
> service_started => looks for /run/openrc/started/snmpd; which is absent
> which is why we think the service is not in state running (and e.g.
> /etc/init.d/snmpd status returns 'stopped'.) Failed is a subset of stopped ;)
> 
> We then arrive at the open question of "why did openrc mark the service as
> failed when it is not failed." We need a PoC for that.
> 
> -A

My guess on this is that in May we changed the pidfile for supervise-daemon.

This would cause openrc to potentially 'lose track' of the existing supervisor.
Then for some unrelated reason we tried to restart snmpd.
This caused openrc to spawn supervise-daemon (a second one) to start (a second) snmpd. This fails (since it binds to a port, etc.)
This failure will cause supervise-daemon to mark the service as state=failure.
This will cause openrc ot report the service as stopped.
This will cause puppet to start the service every run; however /etc/init.d/snmpd start will not work as the daemon is already technically running.

-A