1
0
mirror of https://git.FreeBSD.org/ports.git synced 2024-12-27 05:10:36 +00:00

net-mgmt/net-snmp: Avoid changing to the snmpd user for now

Switching the user might break existing configurations, for reasons that
are not fully clear yet.  Avoid surprises by letting users opt-in to
that change, for now.

Also provide an rc.conf variable to make it easy to configure snmpd to
drop privileges if they so choose.

Reported by:	dvl
Approved by:	zi
Sponsored by:	Klara, Inc.
Sponsored by:	Stormshield
Differential Revision:	https://reviews.freebsd.org/D45199
This commit is contained in:
Mark Johnston 2024-05-14 10:43:03 -04:00
parent 9ba210177e
commit 52fe0689ea
2 changed files with 13 additions and 2 deletions

View File

@ -1,7 +1,7 @@
PORTNAME= snmp
PORTVERSION= 5.9.4
PORTEPOCH= 1
PORTREVISION= 1
PORTREVISION= 2
CATEGORIES= net-mgmt
MASTER_SITES= SF/net-${PORTNAME}/net-${PORTNAME}/${PORTVERSION} \
ZI

View File

@ -8,6 +8,12 @@
# snmpd_enable="YES"
# snmpd_flags="<set as needed>"
# snmpd_conffile="<set as needed>"
#
# Add the following line to make snmpd drop privileges after initialization.
# This might invalidate existing SNMPv3 users.
#
# snmpd_sugid="YES"
#
. /etc/rc.subr
@ -18,6 +24,7 @@ load_rc_config snmpd
snmpd_enable=${snmpd_enable:-"NO"}
snmpd_flush_cache=${snmpd_flush_cache-"NO"}
snmpd_sugid=${snmpd_sugid:-"NO"}
pidfile=${snmpd_pidfile:-"/var/run/net_snmpd.pid"}
@ -57,7 +64,11 @@ net_snmpd_precmd () {
if [ -n "${snmpd_conffile_set}" ]; then
rc_flags="-c ${snmpd_conffile_set#,} ${rc_flags}"
fi
rc_flags="-u snmpd -g snmpd -p ${pidfile} ${rc_flags}"
if checkyesno snmpd_sugid; then
rc_flags="-u snmpd -g snmpd ${rc_flags}"
fi
rc_flags="-p ${pidfile} ${rc_flags}"
}
run_rc_command "$1"