Package: sysvinit-utils
Version: 2.93-8

I started testing the upgrade from Debian Stretch to Buster, and I've encountered a problem that affects the snmpd package's init.d script. It looks like it has been changed to utilize /lib/init/init-d-script for its core functionality. However, by doing so, the SNMPDOPTS value is ignored from the init config file at /etc/default/snmpd. This is because of the following lines in /etc/init.d/snmpd:

==============================
DEFAULT_SNMPDOPTS="-Lsd -Lf /dev/null -u Debian-snmp -g Debian-snmp -I -smux,mteTrigger,mteTriggerConf"
[ -z "$SNMPDOPTS" ] && SNMPDOPTS=$DEFAULT_SNMPDOPTS
==============================

Because the /lib/init/init-d-script script sources /etc/init.d/snmpd BEFORE it sources /etc/default/snmpd, none of the values in /etc/default/snmpd are visible to /etc/init.d/snmpd. This results in SNMPDOPTS always being set to the default arguments.

One could view this as a bug in either snmpd or sysvinit-utils, depending on your viewpoint. However, it seems more appropriate for a fix to be applied to /lib/init/init-d-script within sysvinit-utils, as other scripts may try (or even be trying already) to use this method within the init.d script to set defaults. The /etc/init.d/snmpd script could manually force an inclusion of /etc/defaults/snmpd, but it seems a little redundant when /lib/init/init-d-script is supposed to do that work.

The line in question in /lib/init/init-d-script is below:

==============================
# Read configuration variable file if it is present
[ -r /etc/default/$NAME ] && . /etc/default/$NAME
==============================

Moving it above the following block would ensure it's sourced first:

==============================
SCRIPTNAME="$__init_d_script_name"
scriptbasename="$(basename "$__init_d_script_name")"
if [ "$scriptbasename" != "init-d-script" ] ; then
    . "$__init_d_script_name"
else
    exit 0
fi
==============================

I checked the latest experimental version (2.95) and it doesn't have any changes like this (although it does fix the snmpd package install bug as referenced in #926390). Without knowing all the ins and outs of how /lib/init/init-d-script is used throughout Debian, I can't say if this change would be considered safe or not. Perhaps there are instances where the /etc/default/* config file tries to do more than just set some shell variables and it would cause some bizarre side effects.

Thanks.

--
Justin Pasher

Reply via email to