ports/114952: net-mgmt/net-snmp4 rc script starts snmpd without being enabled
Chris Cowart
ccowart at rescomp.berkeley.edu
Fri Jul 27 03:00:03 UTC 2007
>Number: 114952
>Category: ports
>Synopsis: net-mgmt/net-snmp4 rc script starts snmpd without being enabled
>Confidential: no
>Severity: serious
>Priority: low
>Responsible: freebsd-ports-bugs
>State: open
>Quarter:
>Keywords:
>Date-Required:
>Class: sw-bug
>Submitter-Id: current-users
>Arrival-Date: Fri Jul 27 03:00:02 GMT 2007
>Closed-Date:
>Last-Modified:
>Originator: Chris Cowart
>Release: 6.2_REL
>Organization:
RSSP-IT, UC Berkeley
>Environment:
FreeBSD stingray.rescomp.berkeley.edu 6.2-RELEASE-p4 FreeBSD 6.2-RELEASE-p4 #0: Mon May 21 21:36:00 PDT 2007 root at stingray.rescomp.berkeley.edu:/usr/obj/usr/src/sys/RCBSD_1 i386
>Description:
I'm referring to the port Makefile with FreeBSD Id:
$FreeBSD: ports/net-mgmt/net-snmp4/Makefile,v 1.105 2007/06/21 06:59:36 rafan Exp $
Line 139 of the Makefile installs files/snmpd.sh.sample into /usr/local/etc/rc.d/snmpd.sh.
This is *not* a FreeBSD-style rc script. It simply switches on "$1" for the word start or stop and performs that action. It does *not* use /etc/rc.subr to determine whether snmpd has been enabled.
As a result, snmpd will be started during boot on any machine where the port net-mgmt/net-snmp4 is installed. Some would consider this to be a security problem.
>How-To-Repeat:
>Fix:
I've included a patch that creates a FreeBSD-style rc script in files and updates the port to install it.
Patch attached with submission follows:
diff -Nrub net-snmp4-orig/Makefile net-snmp4-mine/Makefile
--- net-snmp4-orig/Makefile 2007-07-26 18:02:09.000000000 -0700
+++ net-snmp4-mine/Makefile 2007-07-26 17:59:24.000000000 -0700
@@ -82,7 +82,7 @@
snmpstatus snmptest snmptranslate snmptrap snmpwalk
SBIN= snmpd snmptrapd
-STARTUP_FILE= ${PREFIX}/etc/rc.d/snmpd.sh
+STARTUP_FILE= ${PREFIX}/etc/rc.d/snmpd
CONFLICTS= net-snmp-5.*
@@ -135,8 +135,8 @@
@for F in ${WRKSRC}/EXAMPLE.conf ${WRKSRC}/agent/mibgroup/examples/ucdDemoPublic.conf; do \
${INSTALL_DATA} $$F ${PREFIX}/share/examples/ucd-snmp ; done
@if [ ! -f ${STARTUP_FILE} ]; then \
- ${ECHO} "Creating ${PREFIX}/etc/rc.d/snmpd.sh startup file."; \
- ${INSTALL_SCRIPT} -m 751 ${FILESDIR}/snmpd.sh.sample ${STARTUP_FILE}; \
+ ${ECHO} "Creating ${STARTUP_FILE} startup file."; \
+ ${INSTALL_SCRIPT} -m 755 ${FILESDIR}/snmpd ${STARTUP_FILE}; \
fi
.include <bsd.port.post.mk>
diff -Nrub net-snmp4-orig/files/snmpd net-snmp4-mine/files/snmpd
--- net-snmp4-orig/files/snmpd 1969-12-31 16:00:00.000000000 -0800
+++ net-snmp4-mine/files/snmpd 2007-07-26 18:00:37.000000000 -0700
@@ -0,0 +1,25 @@
+#!/bin/sh
+#
+# $FreeBSD$
+#
+# PROVIDE: snmpd
+# REQUIRE: DAEMON
+#
+# Add the following line to /etc/rc.conf to enable snmpd:
+#
+# snmpd_enable="YES"
+#
+
+snmpd_enable=${snmpd_enable:-"NO"}
+snmpd_flags=${snmpd_flags:-"-p /var/run/snmpd.pid"}
+
+. /etc/rc.subr
+
+name=snmpd
+rcvar=`set_rcvar`
+
+command=/usr/local/sbin/${name}
+pidfile=/var/run/${name}.pid
+
+load_rc_config ${name}
+run_rc_command "$1"
diff -Nrub net-snmp4-orig/pkg-plist net-snmp4-mine/pkg-plist
--- net-snmp4-orig/pkg-plist 2007-07-26 17:48:02.000000000 -0700
+++ net-snmp4-mine/pkg-plist 2007-07-26 18:02:23.000000000 -0700
@@ -19,7 +19,7 @@
bin/snmpusm
bin/snmpvacm
bin/snmpwalk
-etc/rc.d/snmpd.sh
+etc/rc.d/snmpd
include/ucd-snmp/agent_index.h
include/ucd-snmp/agent_read_config.h
include/ucd-snmp/agent_registry.h
>Release-Note:
>Audit-Trail:
>Unformatted:
More information about the freebsd-ports-bugs
mailing list