Subject: pkg/12043: fixes and updates to make net/ucd-snmp more useful (add host MIB, rc.d/snmptrapd, etc.)
To: None <gnats-bugs@gnats.netbsd.org>
From: Greg A. Woods <woods@weird.com>
List: netbsd-bugs
Date: 01/25/2001 11:49:21
>Number:         12043
>Category:       pkg
>Synopsis:       fixes and updates to make net/ucd-snmp more useful (add host MIB, rc.d/snmptrapd, etc.)
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    pkg-manager
>State:          open
>Class:          change-request
>Submitter-Id:   net
>Arrival-Date:   Thu Jan 25 11:52:00 PST 2001
>Closed-Date:
>Last-Modified:
>Originator:     Greg A. Woods
>Release:        pkgsrc-2000/01/23
>Organization:
Planix, Inc.; Toronto, Ontario; Canada
>Environment:

System: NetBSD proven 1.5F NetBSD 1.5F (PROVEN) #2: Fri Nov 24 19:18:42 EST 2000 woods@proven:/work/woods/NetBSD-src/sys/arch/i386/compile/PROVEN i386


>Description:

	The net/ucd-snmp package is in need of some updating.

	The most important problem is that the rc.d scripts are
	installed with their .sh extensions -- this causes havoc with
	the new rc system.

	The second most important problem is that the installed daemon
	does not support the HOST-RESOURCES MIB.

	There's also no default rc.d script for starting snmptrapd.

    Things not yet fixed:

	Note that this package should be renamed to net-snmp, the new
	official name of the package.

	Note that this package still won't build if any predecessor is
	still installed -- this is a royal pain.  I think the problem
	has to do with the order of '-L' parameters in LDFLAGS.

	There's also no default way to disable the use of shared
	libraries, or indeed any way to build these daemons statically.
	In some environments both of these options would be highly
	useful for this package (and perhaps for other packages in
	general too, I guess).

>How-To-Repeat:

>Fix:

	Apply the following diff to pkgsrc/net/ucd-snmp:

cvs diff: Diffing .
Index: Makefile
===================================================================
RCS file: /most/spare/cvs.NetBSD.ORG/pkgsrc/net/ucd-snmp/Makefile,v
retrieving revision 1.25
diff -u -r1.25 Makefile
--- Makefile	2000/12/16 09:04:40	1.25
+++ Makefile	2001/01/25 08:30:53
@@ -27,6 +27,13 @@
 
 GNU_CONFIGURE=	yes
 CONFIGURE_ARGS+=--with-defaults --with-libwrap --with-logfile="/var/log/snmpd"
+CONFIGURE_ARGS+=--with-mib-modules="smux host"
+# NOTE: if you do not allow dummy values some tools such as
+# scotty/tkined may ignore results when they shouldn't.
+CONFIGURE_ARGS+=--with-dummy-values
+# NOTE: without this the default is USER@DOMAINNAME of the package builder
+CONFIGURE_ARGS+=--with-sys-contact="default_user@contact.domain"
+CONFIGURE_ARGS+=--with-sys-location="defaultlocation"
 CONFIGURE_ARGS+=--enable-shared
 .if defined(USE_INET6) && ${USE_INET6} == "YES"
 CONFIGURE_ARGS+=--enable-ipv6
@@ -35,7 +42,7 @@
 .endif
 
 # this might make it easier to use scotty's mibs, and local ones too
-CONFIGURE_ARGS+=--with-mibdirs="${PREFIX}/share/snmp/mibs:${PREFIX}/lib/tcl/tnm2.1.10/mibs:/usr/local/share/snmp/mibs"
+CONFIGURE_ARGS+=--with-mibdirs="${PREFIX}/share/snmp/mibs:${PREFIX}/lib/tcl/tnm2.1.10/mibs:${PREFIX}/lib/tnm2.1.8/mibs:/usr/local/share/snmp/mibs"
 
 # deal with libwrap bogosity by providing these variables to programs which
 # do not supply them:
@@ -45,13 +52,16 @@
 pre-configure:
 	@(cd ${WRKSRC} && autoreconf)
 
+post-build:
+	${SED} 's,@PREFIX@,${PREFIX},g' < ${FILESDIR}/snmpd.sh > ${WRKDIR}/snmpd
+	${SED} 's,@PREFIX@,${PREFIX},g' < ${FILESDIR}/snmptrapd.sh > ${WRKDIR}/snmptrapd
+
 post-install:
 	${MKDIR} ${PREFIX}/share/examples/ucd-snmp
 	${INSTALL_DATA} ${WRKSRC}/EXAMPLE.conf ${PREFIX}/share/examples/ucd-snmp
 	${INSTALL_DATA_DIR} ${PREFIX}/lib/snmp/dlmod
-	${SED} -e 's,@PREFIX@,${PREFIX},' \
-	    < ${FILESDIR}/snmpd.sh > ${WRKDIR}/snmpd.sh
-	${INSTALL_SCRIPT} ${WRKDIR}/snmpd.sh ${PREFIX}/etc/rc.d
+	${INSTALL_SCRIPT} ${WRKDIR}/snmpd ${PREFIX}/etc/rc.d
+	${INSTALL_SCRIPT} ${WRKDIR}/snmptrapd ${PREFIX}/etc/rc.d
 
 .if (${OPSYS} == "NetBSD")
 CFLAGS+=	-Dnetbsd1
cvs diff: Diffing files
Index: files/snmpd.sh
===================================================================
RCS file: /most/spare/cvs.NetBSD.ORG/pkgsrc/net/ucd-snmp/files/snmpd.sh,v
retrieving revision 1.2
diff -u -r1.2 snmpd.sh
--- files/snmpd.sh	2000/12/16 09:04:41	1.2
+++ files/snmpd.sh	2001/01/25 08:29:39
@@ -15,13 +15,15 @@
 	if [ -x @PREFIX@/sbin/snmpd ]
 	then
 	    echo -n ' snmpd'
-	    @PREFIX@/sbin/snmpd -s -P ${PF} -A -l /dev/null ${SNMPD_CFG}
+	    @PREFIX@/sbin/snmpd -s -P ${PF} -A ${SNMPD_CFG}
 	fi
 	;;
 stop)
 	if [ -f ${PF} ]; then
 		kill `cat ${PF}`
 		rm -f ${PF}
+	else
+		echo "$0: snmpd not running or PID not recorded!" 1>&2
 	fi
 	;;
 restart)
Index: files/snmptrapd.sh
===================================================================
RCS file: snmptrapd.sh
diff -N snmptrapd.sh
--- /dev/null	Thu Jan 25 13:46:16 2001
+++ snmptrapd.sh	Thu Jan 25 11:47:32 2001
@@ -0,0 +1,32 @@
+#! /bin/sh
+#
+# $NetBSD$
+
+# PID file:
+PF=/var/run/snmptrapd.pid
+
+
+case $1 in
+start)
+	if [ -x @PREFIX@/sbin/snmptrapd ]
+	then
+		echo -n ' snmptrapd'
+		@PREFIX@/sbin/snmptrapd -s -l 1 -u ${PF}
+	fi
+	;;
+stop)
+	if [ -f ${PF} ]; then
+		kill `cat ${PF}`
+		rm -f ${PF}
+	else
+		echo "$0: snmptrapd not running or PID not recorded!" 1>&2
+	fi
+	;;
+restart)
+	sh $0 stop
+	sh $0 start
+	;;
+*)
+	echo "Usage: $0 {start|stop|restart}"
+	exit 1
+esac
cvs diff: Diffing patches
Index: patches/patch-aa
===================================================================
RCS file: /most/spare/cvs.NetBSD.ORG/pkgsrc/net/ucd-snmp/patches/patch-aa,v
retrieving revision 1.11
diff -u -r1.11 patch-aa
--- patches/patch-aa	2000/10/13 17:55:36	1.11
+++ patches/patch-aa	2001/01/25 16:40:25
@@ -1,24 +1,57 @@
 $NetBSD: patch-aa,v 1.11 2000/10/13 17:55:36 kim Exp $
 
---- configure.in.orig	Sat May  6 01:46:26 2000
-+++ configure.in	Wed Oct 11 19:15:06 2000
-@@ -461,3 +461,4 @@
+--- configure.in.orig	Fri May  5 12:46:26 2000
++++ configure.in	Thu Jan 25 11:34:44 2001
+@@ -459,7 +459,8 @@
+     else
+       SHLIB_CFLAGS="-KPIC"
      fi
 -    SHLIB_EXTENSION="so"
 +#   SHLIB_EXTENSION="so"
 +    SHLIB_EXTENSION="la"
      SHLIB_VERSION=
-@@ -1069,3 +1070,3 @@
+     SHLIB_LD_CMD="ld -r -o"
+     SHLIB_LDCONFIG_CMD=
+@@ -1045,12 +1046,12 @@
+ dnl
+ dnl now check for rpm using the appropriate db library
+ dnl
+-AC_CHECK_LIB(rpm, rpmdbOpen,[
+-  AC_DEFINE(HAVE_LIBRPM)
+-  LIBS="-lrpm $LIBS"
+-  CFLAGS="$CFLAGS -I/usr/include/rpm"
+-],,-lz)
+-
++AC_CHECK_HEADERS(rpm/rpmlib.h rpm/header.h,
++  AC_CHECK_LIB(rpm, rpmdbOpen,[
++    AC_DEFINE(HAVE_LIBRPM)
++    LIBS="-lrpm $LIBS"
++], CPPFLAGS=${_cppflags} LDFLAGS=${_ldflags}),
++CPPFLAGS=${_cppflags} LDFLAGS=${_ldflags})
+ 
+ dnl Replace `main' with a function in -lkstat:
+ AC_CHECK_LIB(kstat, kstat_lookup)
+@@ -1067,7 +1068,7 @@
+ AC_HEADER_STDC
+ AC_HEADER_DIRENT
  AC_HEADER_SYS_WAIT
 -AC_CHECK_HEADERS(stdarg.h string.h fcntl.h limits.h sys/file.h sys/ioctl.h syslog.h unistd.h netinet/tcpip.h netinet/in.h netinet/ip.h net/if.h netdb.h sys/dmap.h machine/pte.h xti.h sys/sockio.h sys/socket.h sys/un.h fstab.h sys/fs.h mtab.h ufs/fs.h ufs/ffs/fs.h sys/fixpoint.h machine/param.h sys/vm.h vm/vm.h sys/vmmeter.h sys/vmparam.h sys/vmmac.h sys/vmsystm.h sys/mbuf.h sys/time.h sys/swap.h inet/mib2.h sys/statvfs.h sys/vfs.h sys/mnttab.h sys/user.h sys/proc.h sys/select.h mntent.h sys/mntent.h kstat.h utsname.h sys/utsname.h sys/cdefs.h getopt.h locale.h pthread.h sys/loadavg.h regex.h)
 +AC_CHECK_HEADERS(stdarg.h string.h fcntl.h limits.h sys/file.h sys/ioctl.h syslog.h unistd.h netinet/tcpip.h netinet/in.h netinet/ip.h net/if.h netdb.h sys/dmap.h machine/pte.h xti.h sys/sockio.h sys/socket.h sys/un.h fstab.h sys/fs.h mtab.h ufs/fs.h ufs/ffs/fs.h sys/fixpoint.h machine/param.h sys/vm.h sys/vmmeter.h sys/vmparam.h sys/vmmac.h sys/vmsystm.h sys/mbuf.h sys/time.h sys/swap.h inet/mib2.h sys/statvfs.h sys/vfs.h sys/mnttab.h sys/user.h sys/proc.h sys/select.h mntent.h sys/mntent.h kstat.h utsname.h sys/utsname.h sys/cdefs.h getopt.h locale.h pthread.h sys/loadavg.h regex.h)
  dnl FreeBSD required headers
-@@ -1077,3 +1078,3 @@
+ AC_CHECK_HEADERS(malloc.h sys/param.h net/if_dl.h sys/sysctl.h stdlib.h net/if_mib.h net/if_types.h net/if_var.h sys/queue.h osreldate.h sys/disklabel.h machine/types.h sys/socketvar.h)
+ dnl Linux
+@@ -1075,7 +1076,7 @@
+ dnl NetBSD required headers
+ AC_CHECK_HEADERS(arpa/inet.h kvm.h sys/pool.h)
  dnl BSDi2 headers
 -AC_CHECK_HEADERS(sys/mount.h vm/swap_pager.h ufs/ufs/dinode.h)
 +AC_CHECK_HEADERS(sys/mount.h ufs/ufs/dinode.h)
  dnl BSDi3 headers
-@@ -1276,7 +1277,3 @@
+ AC_CHECK_HEADERS(sys/stat.h sys/vnode.h ufs/ufs/quota.h ufs/ufs/inode.h)
+ dnl irix headers
+@@ -1274,11 +1275,7 @@
+ 
+ AC_CHECK_STRUCT_FOR([
  #include <sys/types.h>
 -#define KERNEL
 -#define _KERNEL
@@ -26,7 +59,11 @@
 -#undef KERNEL
 -#undef _KERNEL
  #include <net/route.h>
-@@ -1291,7 +1288,3 @@
+ ], rtentry, rt_dst, no)
+ 
+@@ -1289,11 +1286,7 @@
+ dnl 4.4 compat
+ AC_TRY_COMPILE([
  #include <sys/types.h>
 -#define KERNEL
 -#define _KERNEL
@@ -34,7 +71,11 @@
 -#undef KERNEL
 -#undef _KERNEL
  #include <net/route.h>
-@@ -1312,7 +1305,3 @@
+ ],[
+ 
+@@ -1310,11 +1303,7 @@
+ if test "x$ac_cv_RTENTRY_TYPE" = "x"; then
+ AC_TRY_COMPILE([
  #include <sys/types.h>
 -#define KERNEL
 -#define _KERNEL
@@ -42,7 +83,11 @@
 -#undef KERNEL
 -#undef _KERNEL
  #include <net/route.h>
-@@ -1366,7 +1355,3 @@
+ ],[
+ struct rtentry rt; 
+@@ -1364,11 +1353,7 @@
+ [
+ AC_TRY_COMPILE([
  #include <sys/types.h>
 -#define KERNEL
 -#define _KERNEL
@@ -50,7 +95,11 @@
 -#undef KERNEL
 -#undef _KERNEL
  #include <net/route.h>
-@@ -1387,7 +1372,3 @@
+ ],[
+ struct rtentry rt; 
+@@ -1385,41 +1370,25 @@
+ dnl Check struct rtentry for various things.
+ AC_CHECK_STRUCT_FOR([
  #include <sys/types.h>
 -#define KERNEL
 -#define _KERNEL
@@ -58,7 +107,9 @@
 -#undef KERNEL
 -#undef _KERNEL
  #include <net/route.h>
-@@ -1397,7 +1378,3 @@
+ ], rtentry, rt_unit)
+ 
+ AC_CHECK_STRUCT_FOR([
  #include <sys/types.h>
 -#define KERNEL
 -#define _KERNEL
@@ -66,7 +117,9 @@
 -#undef KERNEL
 -#undef _KERNEL
  #include <net/route.h>
-@@ -1407,7 +1384,3 @@
+ ], rtentry, rt_refcnt)
+ 
+ AC_CHECK_STRUCT_FOR([
  #include <sys/types.h>
 -#define KERNEL
 -#define _KERNEL
@@ -74,7 +127,9 @@
 -#undef KERNEL
 -#undef _KERNEL
  #include <net/route.h>
-@@ -1417,7 +1390,3 @@
+ ], rtentry, rt_hash)
+ 
+ AC_CHECK_STRUCT_FOR([
  #include <sys/types.h>
 -#define KERNEL
 -#define _KERNEL
@@ -82,3 +137,5 @@
 -#undef KERNEL
 -#undef _KERNEL
  #include <net/route.h>
+ ], rtentry, rt_use)
+ 
cvs diff: Diffing pkg
Index: pkg/PLIST
===================================================================
RCS file: /most/spare/cvs.NetBSD.ORG/pkgsrc/net/ucd-snmp/pkg/PLIST,v
retrieving revision 1.10
diff -u -r1.10 PLIST
--- pkg/PLIST	2001/01/04 15:10:52	1.10
+++ pkg/PLIST	2001/01/25 19:03:46
@@ -17,7 +17,8 @@
 bin/snmpusm
 bin/snmpwalk
 bin/tkmib
-etc/rc.d/snmpd.sh
+etc/rc.d/snmpd
+etc/rc.d/snmptrapd
 include/ucd-snmp/agent_read_config.h
 include/ucd-snmp/agent_registry.h
 include/ucd-snmp/agent_trap.h
>Release-Note:
>Audit-Trail:
>Unformatted: