Bug 112766 - net-mgmt/net-snmp - snmpd rc script $snmpd_conffile does not handle multiple cfg files
Summary: net-mgmt/net-snmp - snmpd rc script $snmpd_conffile does not handle multiple ...
Status: Closed FIXED
Alias: None
Product: Ports & Packages
Classification: Unclassified
Component: Individual Port(s) (show other bugs)
Version: Latest
Hardware: Any Any
: Normal Affects Only Me
Assignee: Jun Kuriyama
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2007-05-18 19:10 UTC by Royce D. Williams
Modified: 2007-10-27 08:30 UTC (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Royce D. Williams 2007-05-18 19:10:04 UTC
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.

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.



+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--5E5EhR99W6NBBKykC4OQXDLOMMexPK010flAsAtYpQucecj4
Content-Type: text/plain; name="file.diff"
Content-Transfer-Encoding: 7bit
Content-Disposition: attachment; filename="file.diff"

--- snmpd       Wed Apr 18 10:51:57 2007
+++ snmpd.new   Fri May 18 09:48:18 2007
@@ -52,15 +52,26 @@
        ;;
 esac
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
Comment 1 Edwin Groothuis freebsd_committer freebsd_triage 2007-05-18 22:56:58 UTC
Responsible Changed
From-To: freebsd-ports-bugs->kuriyama

Over to maintainer
Comment 2 Royce D. Williams 2007-06-16 00:26:51 UTC
Note that I have now been using this patched rc script on 16 systems
for the past month -- working fine.

Royce
Comment 3 dfilter service freebsd_committer freebsd_triage 2007-10-27 08:20:41 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"
Comment 4 Jun Kuriyama freebsd_committer freebsd_triage 2007-10-27 08:20:43 UTC
State Changed
From-To: open->closed

Committed with minor modification (care about users who does not set 
$snmpd_conffile in rc.conf). 

Thanks!