From 415856bdd4f48ab4f2732996f0bae58595092bbe Mon Sep 17 00:00:00 2001 From: Parabola Date: Tue, 5 Apr 2011 14:26:38 +0000 Subject: Tue Apr 5 14:26:38 UTC 2011 --- extra/net-snmp/PKGBUILD | 42 +++++++++++++++++++++++++++ extra/net-snmp/libnl-2.patch | 67 ++++++++++++++++++++++++++++++++++++++++++++ extra/net-snmp/snmpd.rc | 38 +++++++++++++++++++++++++ 3 files changed, 147 insertions(+) create mode 100644 extra/net-snmp/PKGBUILD create mode 100644 extra/net-snmp/libnl-2.patch create mode 100644 extra/net-snmp/snmpd.rc (limited to 'extra/net-snmp') diff --git a/extra/net-snmp/PKGBUILD b/extra/net-snmp/PKGBUILD new file mode 100644 index 000000000..5506932b1 --- /dev/null +++ b/extra/net-snmp/PKGBUILD @@ -0,0 +1,42 @@ +# $Id: PKGBUILD 112465 2011-03-05 03:33:40Z eric $ +# Maintainer: Eric Belanger +# Contributor: Dale Blount + +pkgname=net-snmp +pkgver=5.6.1 +pkgrel=1 +pkgdesc="A suite of applications used to implement SNMP v1, SNMP v2c and SNMP v3 using both IPv4 and IPv6" +arch=('i686' 'x86_64') +url="http://www.net-snmp.org/" +license=('custom') +depends=('openssl' 'tcp_wrappers' 'libnl') +makedepends=('setuptools') +optdepends=('perl-term-readkey: for snmpcheck application' + 'perl-tk: for snmpcheck and tkmib applications' + 'python2: for the python modules') +provides=('ucd-snmp') +options=('!libtool' '!makeflags' '!emptydirs') +source=("http://downloads.sourceforge.net/sourceforge/${pkgname}/${pkgname}-${pkgver}.tar.gz" + 'snmpd.rc') +md5sums=('b4e30ead5783b0bb1d280172c6095ea4' '9f0d13676ba1fae1eb7eb178edd85b43') +sha1sums=('45bbf1295253d5379a5d1efd918593160387fd00' '2c679b564a2c319d9ce2714a9776aa0e6d89c60a') + +build() { + cd "${srcdir}/${pkgname}-${pkgver}" + sed -i -e "s:\(install --basedir=\$\$dir\):\1 --root='${pkgdir}':" Makefile.in + ./configure --prefix=/usr --sysconfdir=/etc --mandir=/usr/share/man \ + --enable-ucd-snmp-compatibility --enable-ipv6 --with-libwrap --with-python-modules \ + --with-default-snmp-version="3" --with-sys-contact="root@localhost" \ + --with-sys-location="Unknown" --with-logfile="/var/log/snmpd.log" \ + --with-mib-modules="host misc/ipfwacc ucd-snmp/diskio tunnel ucd-snmp/dlmod" \ + --with-persistent-directory="/var/net-snmp" \ + PYTHONPROG=/usr/bin/python2 + make NETSNMP_DONT_CHECK_VERSION=1 LDFLAGS+="-Wl,-rpath -Wl,/usr/lib/perl5/core_perl/CORE" +} + +package() { + cd "${srcdir}/${pkgname}-${pkgver}" + make DESTDIR="${pkgdir}" INSTALL_PREFIX="${pkgdir}" INSTALLDIRS=vendor install + install -D -m755 "${srcdir}/snmpd.rc" "${pkgdir}/etc/rc.d/snmpd" + install -D -m644 COPYING "${pkgdir}/usr/share/licenses/${pkgname}/COPYING" +} diff --git a/extra/net-snmp/libnl-2.patch b/extra/net-snmp/libnl-2.patch new file mode 100644 index 000000000..7c140fe83 --- /dev/null +++ b/extra/net-snmp/libnl-2.patch @@ -0,0 +1,67 @@ +diff -Nur net-snmp-5.5.orig//agent/mibgroup/mibII/tcpTable.c net-snmp-5.5//agent/mibgroup/mibII/tcpTable.c +--- net-snmp-5.5.orig//agent/mibgroup/mibII/tcpTable.c 2009-06-13 04:02:02.000000000 +0200 ++++ net-snmp-5.5//agent/mibgroup/mibII/tcpTable.c 2011-01-15 10:31:03.579735957 +0100 +@@ -555,8 +555,10 @@ + static int + tcpTable_load_netlink() + { ++ int err; ++ + /* TODO: perhaps use permanent nl handle? */ +- struct nl_handle *nl = nl_handle_alloc(); ++ struct nl_sock *nl = nl_socket_alloc(); + + if (nl == NULL) { + DEBUGMSGTL(("mibII/tcpTable", "Failed to allocate netlink handle\n")); +@@ -564,10 +566,10 @@ + return -1; + } + +- if (nl_connect(nl, NETLINK_INET_DIAG) < 0) { +- DEBUGMSGTL(("mibII/tcpTable", "Failed to connect to netlink: %s\n", nl_geterror())); +- snmp_log(LOG_ERR, "snmpd: Couldn't connect to netlink: %s\n", nl_geterror()); +- nl_handle_destroy(nl); ++ if ((err = nl_connect(nl, NETLINK_INET_DIAG)) < 0) { ++ DEBUGMSGTL(("mibII/tcpTable", "Failed to connect to netlink: %s\n", nl_geterror(err))); ++ snmp_log(LOG_ERR, "snmpd: Couldn't connect to netlink: %s\n", nl_geterror(err)); ++ nl_socket_free(nl); + return -1; + } + +@@ -579,10 +581,10 @@ + struct nl_msg *nm = nlmsg_alloc_simple(TCPDIAG_GETSOCK, NLM_F_ROOT|NLM_F_MATCH|NLM_F_REQUEST); + nlmsg_append(nm, &req, sizeof(struct inet_diag_req), 0); + +- if (nl_send_auto_complete(nl, nm) < 0) { +- DEBUGMSGTL(("mibII/tcpTable", "nl_send_autocomplete(): %s\n", nl_geterror())); +- snmp_log(LOG_ERR, "snmpd: nl_send_autocomplete(): %s\n", nl_geterror()); +- nl_handle_destroy(nl); ++ if ((err = nl_send_auto_complete(nl, nm)) < 0) { ++ DEBUGMSGTL(("mibII/tcpTable", "nl_send_autocomplete(): %s\n", nl_geterror(err))); ++ snmp_log(LOG_ERR, "snmpd: nl_send_autocomplete(): %s\n", nl_geterror(err)); ++ nl_socket_free(nl); + return -1; + } + nlmsg_free(nm); +@@ -593,9 +595,9 @@ + + while (running) { + if ((len = nl_recv(nl, &peer, &buf, NULL)) <= 0) { +- DEBUGMSGTL(("mibII/tcpTable", "nl_recv(): %s\n", nl_geterror())); +- snmp_log(LOG_ERR, "snmpd: nl_recv(): %s\n", nl_geterror()); +- nl_handle_destroy(nl); ++ DEBUGMSGTL(("mibII/tcpTable", "nl_recv(): %s\n", nl_geterror(len))); ++ snmp_log(LOG_ERR, "snmpd: nl_recv(): %s\n", nl_geterror(len)); ++ nl_socket_free(nl); + return -1; + } + +@@ -644,7 +646,7 @@ + free(buf); + } + +- nl_handle_destroy(nl); ++ nl_socket_free(nl); + + if (tcp_head) { + DEBUGMSGTL(("mibII/tcpTable", "Loaded TCP Table using netlink\n")); diff --git a/extra/net-snmp/snmpd.rc b/extra/net-snmp/snmpd.rc new file mode 100644 index 000000000..9f1b83f64 --- /dev/null +++ b/extra/net-snmp/snmpd.rc @@ -0,0 +1,38 @@ +#!/bin/bash + +. /etc/rc.conf +. /etc/rc.d/functions + +PID=`pidof -o %PPID /usr/sbin/snmpd` +case "$1" in + start) + stat_busy "Starting Net-SNMP" + [ -z "$PID" ] && /usr/sbin/snmpd + if [ $? -gt 0 ]; then + stat_fail + else + echo $PID > /var/run/snmpd.pid + add_daemon snmpd + stat_done + fi + ;; + stop) + stat_busy "Stopping Net-SNMP" + [ ! -z "$PID" ] && kill $PID &> /dev/null + if [ $? -gt 0 ]; then + stat_fail + else + rm /var/run/snmpd.pid + rm_daemon snmpd + stat_done + fi + ;; + restart) + $0 stop + sleep 2 + $0 start + ;; + *) + echo "usage: $0 {start|stop|restart}" +esac +exit 0 -- cgit v1.2.3-54-g00ecf