From nobody@FreeBSD.org  Fri May 18 18:01:26 2007
Return-Path: <nobody@FreeBSD.org>
Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52])
	by hub.freebsd.org (Postfix) with ESMTP id E4E3616A404
	for <freebsd-gnats-submit@FreeBSD.org>; Fri, 18 May 2007 18:01:26 +0000 (UTC)
	(envelope-from nobody@FreeBSD.org)
Received: from www.freebsd.org (www.freebsd.org [69.147.83.33])
	by mx1.freebsd.org (Postfix) with ESMTP id C959C13C45B
	for <freebsd-gnats-submit@FreeBSD.org>; Fri, 18 May 2007 18:01:26 +0000 (UTC)
	(envelope-from nobody@FreeBSD.org)
Received: from www.freebsd.org (localhost [127.0.0.1])
	by www.freebsd.org (8.13.1/8.13.1) with ESMTP id l4II1QOP086582
	for <freebsd-gnats-submit@FreeBSD.org>; Fri, 18 May 2007 18:01:26 GMT
	(envelope-from nobody@www.freebsd.org)
Received: (from nobody@localhost)
	by www.freebsd.org (8.13.1/8.13.1/Submit) id l4IHuPqY086036;
	Fri, 18 May 2007 17:56:25 GMT
	(envelope-from nobody)
Message-Id: <200705181756.l4IHuPqY086036@www.freebsd.org>
Date: Fri, 18 May 2007 17:56:25 GMT
From: Royce Williams<royce@alaska.net>
To: freebsd-gnats-submit@FreeBSD.org
Subject: snmpd rc script $snmpd_conffile does not handle multiple cfg files
X-Send-Pr-Version: www-3.0

>Number:         112766
>Category:       ports
>Synopsis:       net-mgmt/net-snmp - snmpd rc script $snmpd_conffile does not handle multiple cfg files
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    kuriyama
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Fri May 18 18:10:04 GMT 2007
>Closed-Date:    Sat Oct 27 07:21:32 UTC 2007
>Last-Modified:  Sat Oct 27 07:30:00 UTC 2007
>Originator:     Royce Williams
>Release:        6.2-RELEASE-p4
>Organization:
>Environment:
FreeBSD beaver.prv.nwc.acsalaska.net 6.2-RELEASE-p4 FreeBSD 6.2-RELEASE-p4 #0: Thu Apr 26 17:55:55 UTC 2007   root@i386-builder.daemonology.net:/usr/obj/usr/src/sys/SMP  i386
>Description:
After the change on 2006-09-23 adding support for snmpd_conffile:

http://www.freshports.org/commit.php?category=net-mgmt&port=net-snmp&files=yes&message_id=200609231131.k8NBV94x051193@repoman.freebsd.org

.. handling of multiple snmpd.conf files is not possible using the 
$snmpd_conffile variable.

The rc script assumes that there is only one file specified by -c:

        if [ ! -z "${snmpd_conffile}" -a -f ${snmpd_conffile} ]; then

.. but snmpd supports specifying multiple configuration files:

From the snmpd man page:

 -c FILE Read FILE as a configuration file (or a comma-separated list of
         configuration  files).   Note  that  the  loaded file will only
         understand snmpd.conf tokens, unless the configuration type  is
         specified  in the file as described in the snmp_config man page
         under SWITCHING CONFIGURATION TYPES IN MID-FILE.


>How-To-Repeat:
1. In /etc/rc.conf, add this line:

snmpd_conffile='/usr/local/etc/snmp/snmpd.conf,/usr/local/etc/snmp/snmpd.conf.local'

2. Stop and start snmpd:

/usr/local/etc/rc.d/snmpd stop
/usr/local/etc/rc.d/snmpd start

3. Check the log:

[root@beaver /usr/local/etc/snmp]# tail /var/log/snmpd.log
Warning: no access control information configured.
  It's unlikely this agent can serve any useful purpose in this state.
  Run "snmpconf -g basic_setup" to help you configure the snmpd.conf file for this agent.
NET-SNMP version 5.3.1

>Fix:

1) Revert to handling -c in $snmpd_flags, or

2) Parse $snmp_conffile to verify the existence of all included files.  

#2 is preferable, but it's tricky.  '-c' expects the files to be separated by commas, but most rc parsing appears to expect tokens to be separated by spaces.  

A good compromise: separate them by spaces in /etc/rc.conf:

snmpd_conffile='/usr/local/etc/snmp/snmpd.conf /usr/local/etc/snmp/snmpd.conf.local'

and then assembling the -c parameter in the rc script.  This patch has been tested with a single snmpd.conf value and two values.

--- snmpd       Wed Apr 18 10:51:57 2007
+++ snmpd.new   Fri May 18 09:48:18 2007
@@ -52,15 +52,26 @@
        ;;
 esac

+for conffile in ${snmpd_conffile}; do
+       if [ ! -z ${conffile} -a -f ${conffile} ]; then
+               if [ -z ${snmpd_conffile_set} ]; then
+                       snmpd_conffile_set="${conffile}"
+               else
+                       snmpd_conffile_set="${snmpd_conffile_set},${conffile}"
+               fi
+       else
+               echo "snmpd configuration file $conffile not set or not found."
+               exit 1
+       fi
+done
+
 case "${snmpd_flags}" in
 *-c\ *)
        echo "Warning: \$snmpd_flags includes -c option." \
                "Please use \$snmpd_conffile instead."
        ;;
 *)
-       if [ ! -z "${snmpd_conffile}" -a -f ${snmpd_conffile} ]; then
-               snmpd_flags="-c ${snmpd_conffile} ${snmpd_flags}"
-       fi
+       snmpd_flags="-c ${snmpd_conffile_set} ${snmpd_flags}"
        ;;
 esac




>Release-Note:
>Audit-Trail:
Responsible-Changed-From-To: freebsd-ports-bugs->kuriyama 
Responsible-Changed-By: edwin 
Responsible-Changed-When: Fri May 18 21:56:58 UTC 2007 
Responsible-Changed-Why:  
Over to maintainer 

http://www.freebsd.org/cgi/query-pr.cgi?pr=112766 

From: Royce Williams <royce@alaska.net>
To: bug-followup@FreeBSD.org
Cc:  
Subject: Re: ports/112766: net-mgmt/net-snmp - snmpd rc script $snmpd_conffile
 does not handle multiple cfg files
Date: Fri, 15 Jun 2007 15:26:51 -0800

 Note that I have now been using this patched rc script on 16 systems
 for the past month -- working fine.
 
 Royce
 
State-Changed-From-To: open->closed 
State-Changed-By: kuriyama 
State-Changed-When: Sat Oct 27 07:20:43 UTC 2007 
State-Changed-Why:  
Committed with minor modification (care about users who does not set 
$snmpd_conffile in rc.conf). 

Thanks! 

http://www.freebsd.org/cgi/query-pr.cgi?pr=112766 

From: dfilter@FreeBSD.ORG (dfilter service)
To: bug-followup@FreeBSD.org
Cc:  
Subject: Re: ports/112766: commit references a PR
Date: Sat, 27 Oct 2007 07:20:41 +0000 (UTC)

 kuriyama    2007-10-27 07:20:34 UTC
 
   FreeBSD ports repository
 
   Modified files:
     net-mgmt/net-snmp    Makefile pkg-message 
     net-mgmt/net-snmp/files snmpd.sh.in 
   Log:
   - Support multiple files in ${snmp_conffile} variable (1).
   - Update pkg-message to reflect recent rc.conf variable usage.
   
   PR:             ports/112766 (1)
   Submitted by:   Royce Williams<royce@alaska.net> (1)
   
   Revision  Changes    Path
   1.146     +1 -1      ports/net-mgmt/net-snmp/Makefile
   1.7       +16 -3     ports/net-mgmt/net-snmp/files/snmpd.sh.in
   1.5       +2 -1      ports/net-mgmt/net-snmp/pkg-message
 _______________________________________________
 cvs-all@freebsd.org mailing list
 http://lists.freebsd.org/mailman/listinfo/cvs-all
 To unsubscribe, send any mail to "cvs-all-unsubscribe@freebsd.org"
 
>Unformatted:
