net-snmp: import from oldpackages, add myself as maintainer, add license information, update to v5.4.4, refresh patches

Signed-off-by: Jo-Philipp Wich <jow@openwrt.org>
This commit is contained in:
Jo-Philipp Wich 2014-07-02 14:04:57 +02:00
parent 1971a1d567
commit 7c00700f58
12 changed files with 13037 additions and 0 deletions

264
net/net-snmp/Makefile Normal file
View File

@ -0,0 +1,264 @@
#
# Copyright (C) 2006-2014 OpenWrt.org
#
# This is free software, licensed under the GNU General Public License v2.
# See /LICENSE for more information.
#
include $(TOPDIR)/rules.mk
PKG_NAME:=net-snmp
PKG_VERSION:=5.4.4
PKG_RELEASE:=1
PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz
PKG_SOURCE_URL:=@SF/net-snmp
PKG_MD5SUM:=95aa054f3c99a1ce242807d7eaf98619
PKG_MAINTAINER:=Jo-Philipp Wich <jow@openwrt.org>
PKG_LICENSE:=MIT BSD-3-Clause-Clear
PKG_FIXUP = patch-libtool
include $(INCLUDE_DIR)/package.mk
define Package/net-snmp/Default
SECTION:=net
CATEGORY:=Network
URL:=http://www.net-snmp.org/
endef
define Package/net-snmp/Default/description
Simple Network Management Protocol (SNMP) is a widely used protocol for
monitoring the health and welfare of network equipment (eg. routers),
computer equipment and even devices like UPSs. Net-SNMP is a suite of
applications used to implement SNMP v1, SNMP v2c and SNMP v3 using both
IPv4 and IPv6.
endef
define Package/libnetsnmp
$(call Package/net-snmp/Default)
SECTION:=libs
CATEGORY:=Libraries
DEPENDS:=+libelf1
TITLE:=Open source SNMP implementation (libraries)
endef
define Package/libnetsnmp/description
$(call Package/net-snmp/Default/description)
.
This package contains shared libraries, needed by other programs.
endef
define Package/snmp-utils
$(call Package/net-snmp/Default)
DEPENDS:=+libnetsnmp
TITLE:=Open source SNMP implementation (utilities)
endef
define Package/snmp-utils/description
$(call Package/net-snmp/Default/description)
.
This package contains SNMP client utilities.
endef
define Package/snmpd
$(call Package/net-snmp/Default)
DEPENDS:=+libnetsnmp
TITLE:=Open source SNMP implementation (daemon)
endef
define Package/snmpd/description
$(call Package/net-snmp/Default/description)
.
This package contains the SNMP agent, dynamically linked.
endef
define Package/snmpd-static
$(call Package/net-snmp/Default)
TITLE:=Open source SNMP implementation (daemon)
DEPENDS:=+libelf1
endef
define Package/snmpd-static/description
$(call Package/net-snmp/Default/description)
.
This package contains the SNMP agent, statically linked.
endef
SNMP_MIB_MODULES_INCLUDED = \
host/hr_device \
host/hr_disk \
host/hr_filesys \
host/hr_network \
host/hr_partition \
host/hr_proc \
host/hr_storage \
host/hr_system \
ieee802dot11 \
if-mib/ifXTable \
mibII/at \
mibII/icmp \
mibII/ifTable \
mibII/ip \
mibII/snmp_mib \
mibII/sysORTable \
mibII/system_mib \
mibII/tcp \
mibII/udp \
mibII/vacm_context \
mibII/vacm_vars \
snmpv3/snmpEngine \
snmpv3/snmpMPDStats \
snmpv3/usmConf \
snmpv3/usmStats \
snmpv3/usmUser \
tunnel \
ucd-snmp/disk \
ucd-snmp/dlmod \
ucd-snmp/extensible \
ucd-snmp/loadave \
ucd-snmp/memory \
ucd-snmp/pass \
ucd-snmp/proc \
ucd-snmp/vmstat \
util_funcs \
utilities/execute \
SNMP_MIB_MODULES_EXCLUDED = \
agent_mibs \
agentx \
disman/event \
disman/schedule \
hardware \
host \
if-mib \
mibII \
notification \
notification-log-mib \
snmpv3mibs \
target \
tcp-mib \
ucd_snmp \
udp-mib \
utilities \
SNMP_TRANSPORTS_INCLUDED = Callback UDP
SNMP_TRANSPORTS_EXCLUDED = TCP TCPIPv6 Unix
TARGET_CFLAGS += $(FPIC)
CONFIGURE_ARGS += \
--enable-mfd-rewrites \
--enable-shared \
--enable-static \
--with-endianness=$(if $(CONFIG_BIG_ENDIAN),big,little) \
--with-logfile=/var/log/snmpd.log \
--with-persistent-directory=/usr/lib/snmp/ \
--with-default-snmp-version=1 \
--with-sys-contact=root@localhost \
--with-sys-location=Unknown \
--enable-applications \
--disable-debugging \
--disable-manuals \
--disable-mibs \
--disable-scripts \
--with-out-mib-modules="$(SNMP_MIB_MODULES_EXCLUDED)" \
--with-mib-modules="$(SNMP_MIB_MODULES_INCLUDED)" \
--with-out-transports="$(SNMP_TRANSPORTS_EXCLUDED)" \
--with-transports="$(SNMP_TRANSPORTS_INCLUDED)" \
--without-openssl \
--without-libwrap \
--without-rpm \
--without-zlib \
$(call autoconf_bool,CONFIG_IPV6,ipv6) \
ifeq ($(CONFIG_IPV6),y)
SNMP_TRANSPORTS_INCLUDED+= UDPIPv6
endif
TARGET_LDFLAGS += -L$(TOOLCHAIN_DIR)/usr/lib
ifdef CONFIG_PACKAGE_snmpd-static
define Build/Compile/static
$(MAKE) -C $(PKG_BUILD_DIR)/agent \
LDFLAGS="$(TARGET_LDFLAGS) -lm -static" \
EXEEXT="-static" \
snmpd-static
endef
endif
define Build/Compile
$(MAKE) -C $(PKG_BUILD_DIR) \
INSTALL_PREFIX="$(PKG_INSTALL_DIR)" \
LDFLAGS="$(TARGET_LDFLAGS) -lm -lc" \
all install
$(Build/Compile/static)
endef
define Build/InstallDev
$(INSTALL_DIR) $(2)/bin
$(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/bin/net-snmp-config $(2)/bin/
$(SED) 's,=/usr,=$(STAGING_DIR)/usr,g' $(2)/bin/net-snmp-config
$(INSTALL_DIR) $(1)/usr/include
$(CP) $(PKG_INSTALL_DIR)/usr/include/net-snmp $(1)/usr/include/
$(INSTALL_DIR) $(1)/usr/lib
$(CP) $(PKG_INSTALL_DIR)/usr/lib/libnetsnmp{,agent,helpers,mibs}.{a,so*} $(1)/usr/lib/
endef
define Package/libnetsnmp/install
$(INSTALL_DIR) $(1)/usr/lib
$(CP) $(PKG_INSTALL_DIR)/usr/lib/libnetsnmp{,agent,helpers,mibs}.so.* $(1)/usr/lib/
endef
define Package/snmpd/conffiles
/etc/default/snmpd
/etc/config/snmpd
endef
define Package/snmpd/install
$(INSTALL_DIR) $(1)/etc/config
$(INSTALL_DATA) ./files/snmpd.conf $(1)/etc/config/snmpd
$(INSTALL_DIR) $(1)/etc/snmp
ln -sf /var/run/snmpd.conf $(1)/etc/snmp/
$(INSTALL_DIR) $(1)/etc/default
$(INSTALL_DATA) ./files/snmpd.default $(1)/etc/default/snmpd
$(INSTALL_DIR) $(1)/etc/init.d
$(INSTALL_BIN) ./files/snmpd.init $(1)/etc/init.d/snmpd
$(INSTALL_DIR) $(1)/usr/sbin
$(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/sbin/snmpd $(1)/usr/sbin/snmpd
endef
define Package/snmpd-static/conffiles
/etc/default/snmpd
/etc/config/snmpd
endef
define Package/snmpd-static/install
$(INSTALL_DIR) $(1)/etc/config
$(INSTALL_DATA) ./files/snmpd.conf $(1)/etc/config/snmpd
$(INSTALL_DIR) $(1)/etc/snmp
ln -sf /var/run/snmpd.conf $(1)/etc/snmp/
$(INSTALL_DIR) $(1)/etc/default
$(INSTALL_DATA) ./files/snmpd.default $(1)/etc/default/snmpd
$(INSTALL_DIR) $(1)/etc/init.d
$(INSTALL_BIN) ./files/snmpd.init $(1)/etc/init.d/snmpd
$(INSTALL_DIR) $(1)/usr/sbin
$(INSTALL_BIN) $(PKG_BUILD_DIR)/agent/snmpd-static $(1)/usr/sbin/snmpd
endef
define Package/snmp-utils/install
$(INSTALL_DIR) $(1)/usr/bin
$(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/bin/snmp{get,set,status,test,trap,walk} $(1)/usr/bin/
endef
$(eval $(call BuildPackage,libnetsnmp))
$(eval $(call BuildPackage,snmp-utils))
$(eval $(call BuildPackage,snmpd))
$(eval $(call BuildPackage,snmpd-static))

View File

@ -0,0 +1,82 @@
config agent
option agentaddress UDP:161
config com2sec public
option secname ro
option source default
option community public
config com2sec private
option secname rw
option source localhost
option community private
config group public_v1
option group public
option version v1
option secname ro
config group public_v2c
option group public
option version v2c
option secname ro
config group public_usm
option group public
option version usm
option secname ro
config group private_v1
option group private
option version v1
option secname rw
config group private_v2c
option group private
option version v2c
option secname rw
config group private_usm
option group private
option version usm
option secname rw
config view all
option viewname all
option type included
option oid .1
config access public_access
option group public
option context none
option version any
option level noauth
option prefix exact
option read all
option write none
option notify none
config access private_access
option group private
option context none
option version any
option level noauth
option prefix exact
option read all
option write all
option notify all
config system
option sysLocation 'office'
option sysContact 'bofh@example.com'
option sysName 'HeartOfGold'
# option sysServices 72
# option sysDescr 'adult playground'
# option sysObjectID '1.2.3.4'
config exec
option name filedescriptors
option prog /bin/cat
option args /proc/sys/fs/file-nr
# option miboid 1.2.3.4

View File

@ -0,0 +1 @@
OPTIONS="-Lf /dev/null -p /var/run/snmpd.pid"

View File

@ -0,0 +1,146 @@
#!/bin/sh /etc/rc.common
# Copyright (C) 2008 OpenWrt.org
START=50
DEFAULT=/etc/default/snmpd
LIB_D=/var/lib/snmp
LOG_D=/var/log
RUN_D=/var/run
PID_F=$RUN_D/snmpd.pid
RUN_C=$RUN_D/snmpd.conf
snmpd_agent_add() {
local cfg="$1"
config_get agentaddress "$cfg" agentaddress
[ -n "$agentaddress" ] || return 0
echo "agentaddress $agentaddress" >> $RUN_C
}
snmpd_system_add() {
local cfg="$1"
config_get syslocation "$cfg" sysLocation
[ -n "$syslocation" ] && echo "sysLocation $syslocation" >> $RUN_C
config_get syscontact "$cfg" sysContact
[ -n "$syscontact" ] && echo "sysContact $syscontact" >> $RUN_C
config_get sysname "$cfg" sysName
[ -n "$sysname" ] && echo "sysName $sysname" >> $RUN_C
config_get sysservice "$cfg" sysService
[ -n "$sysservice" ] && echo "sysService $sysservice" >> $RUN_C
config_get sysdescr "$cfg" sysDescr
[ -n "$sysdescr" ] && echo "sysDescr $sysdescr" >> $RUN_C
config_get sysobjectid "$cfg" sysObjectID
[ -n "$sysobjectid" ] && echo "sysObjectID $sysobjectid" >> $RUN_C
}
snmpd_com2sec_add() {
local cfg="$1"
config_get secname "$cfg" secname
[ -n "$secname" ] || return 0
config_get source "$cfg" source
[ -n "$source" ] || return 0
config_get community "$cfg" community
[ -n "$community" ] || return 0
echo "com2sec $secname $source $community" >> $RUN_C
}
snmpd_com2sec6_add() {
local cfg="$1"
config_get secname "$cfg" secname
[ -n "$secname" ] || return 0
config_get source "$cfg" source
[ -n "$source" ] || return 0
config_get community "$cfg" community
[ -n "$community" ] || return 0
echo "com2sec6 $secname $source $community" >> $RUN_C
}
snmpd_group_add() {
local cfg="$1"
config_get group "$cfg" group
[ -n "$group" ] || return 0
config_get version "$cfg" version
[ -n "$version" ] || return 0
config_get secname "$cfg" secname
[ -n "$secname" ] || return 0
echo "group $group $version $secname" >> $RUN_C
}
snmpd_view_add() {
local cfg="$1"
config_get viewname "$cfg" viewname
[ -n "$viewname" ] || return 0
config_get type "$cfg" type
[ -n "$type" ] || return 0
config_get oid "$cfg" oid
[ -n "$oid" ] || return 0
# optional mask
config_get mask "$cfg" mask
echo "view $viewname $type $oid $mask" >> $RUN_C
}
snmpd_access_add() {
local cfg="$1"
config_get group "$cfg" group
[ -n "$group" ] || return 0
config_get context "$cfg" context
[ -n $context ] || return 0
[ "$context" == "none" ] && context='""'
config_get version "$cfg" version
[ -n "$version" ] || return 0
config_get level "$cfg" level
[ -n "$level" ] || return 0
config_get prefix "$cfg" prefix
[ -n "$prefix" ] || return 0
config_get read "$cfg" read
[ -n "$read" ] || return 0
config_get write "$cfg" write
[ -n "$write" ] || return 0
config_get notify "$cfg" notify
[ -n "$notify" ] || return 0
echo "access $group $context $version $level $prefix $read $write $notify" >> $RUN_C
}
snmpd_pass_add() {
local cfg="$1"
local pass='pass'
config_get miboid "$cfg" miboid
[ -n "$miboid" ] || return 0
config_get prog "$cfg" prog
[ -n "$prog" ] || return 0
config_get_bool persist "$cfg" persist 0
[ $persist -ne 0 ] && pass='pass_persist'
config_get priority "$cfg" priority
priority=${priority:+-p $priority}
echo "$pass $priority $miboid $prog" >> $RUN_C
}
snmpd_exec_add() {
local cfg="$1"
config_get name "$cfg" name
[ -n "$name" ] || return 0
config_get prog "$cfg" prog
[ -n "$prog" ] || return 0
config_get args "$cfg" args
config_get miboid "$cfg" miboid
echo "exec $miboid $name $prog $args" >> $RUN_C
}
start() {
[ -d $LIB_D ] || mkdir -p $LIB_D
[ -d $LOG_D ] || mkdir -p $LOG_D
[ -d $RUN_D ] || mkdir -p $RUN_D
[ -f $RUN_C ] && rm -f $RUN_C
config_load snmpd
config_foreach snmpd_agent_add agent
config_foreach snmpd_system_add system
config_foreach snmpd_com2sec_add com2sec
config_foreach snmpd_com2sec6_add com2sec6
config_foreach snmpd_group_add group
config_foreach snmpd_view_add view
config_foreach snmpd_access_add access
config_foreach snmpd_pass_add pass
config_foreach snmpd_exec_add exec
[ -f $DEFAULT ] && . $DEFAULT
$DEBUG /usr/sbin/snmpd $OPTIONS
}
stop() {
[ -f $PID_F ] && kill $(cat $PID_F)
[ -f $RUN_C ] && rm -f $RUN_C
}

View File

@ -0,0 +1,22 @@
--- a/agent/mibgroup/mibII/interfaces.c
+++ b/agent/mibgroup/mibII/interfaces.c
@@ -1561,6 +1561,10 @@ Interface_Scan_Init(void)
struct ifnet *nnew;
char *stats, *ifstart = line;
+ /* Ignore interfaces with no statistics. */
+ if (strstr(line, "No statistics available."))
+ continue;
+
if (line[strlen(line) - 1] == '\n')
line[strlen(line) - 1] = '\0';
@@ -1594,7 +1598,7 @@ Interface_Scan_Init(void)
&coll) != 5)) {
if ((scan_line_to_use == scan_line_2_2)
&& !strstr(line, "No statistics available"))
- snmp_log(LOG_ERR,
+ snmp_log(LOG_DEBUG,
"/proc/net/dev data format error, line ==|%s|",
line);
continue;

View File

@ -0,0 +1,40 @@
--- a/local/Makefile.in
+++ b/local/Makefile.in
@@ -100,7 +100,7 @@ tkmib.made: $(srcdir)/tkmib
mib2c.made: $(srcdir)/mib2c
if test "x$(PERL)" != "x" ; then \
- $(PERL) -p -e 's%^#!.*/perl.*%#!$(PERL)%;s#/usr/local/share/snmp#$(snmplibdir)#;' ${srcdir}/mib2c > mib2c.made; \
+ $(PERL) -p -e 's%^#!.*/perl.*%#!$(PERL)%;s#/usr/local/share/snmp#$(snmplibdir)#;s#/usr/local/etc/snmp#$(SNMPCONFPATH)#;' ${srcdir}/mib2c > mib2c.made; \
else \
touch mib2c.made; \
fi
--- a/mibs/Makefile.in
+++ b/mibs/Makefile.in
@@ -48,11 +48,15 @@ NETSNMPMIBS = NET-SNMP-TC.txt NET-SNMP-M
UCDMIBS = UCD-SNMP-MIB.txt UCD-DEMO-MIB.txt UCD-IPFWACC-MIB.txt \
UCD-DLMOD-MIB.txt UCD-DISKIO-MIB.txt
+EXTRAMIBS = BGP4-MIB.txt BRIDGE-MIB.txt GNOME-SMI.txt OSPF-MIB.txt \
+ OSPF-TRAP-MIB.txt RIPv2-MIB.txt SOURCE-ROUTING-MIB.txt \
+ LM-SENSORS-MIB.txt
+
DEFAULTMIBS = @default_mibs_install@
MIBS = $(V1MIBS) $(V2MIBS) $(V3MIBS) $(RFCMIBS) \
$(AGENTMIBS) $(IANAMIBS) \
- $(NETSNMPMIBS) $(UCDMIBS) $(DEFAULTMIBS)
+ $(NETSNMPMIBS) $(UCDMIBS) $(DEFAULTMIBS) $(EXTRAMIBS)
all: standardall
--- a/Makefile.top
+++ b/Makefile.top
@@ -26,6 +26,7 @@ man8dir = $(mandir)/man8
snmplibdir = $(datadir)/snmp
mibdir = $(snmplibdir)/mibs
persistentdir = @PERSISTENT_DIRECTORY@
+sysconfdir = @sysconfdir@
DESTDIR = @INSTALL_PREFIX@
INSTALL_PREFIX = $(DESTDIR)

View File

@ -0,0 +1,14 @@
--- a/local/mib2c
+++ b/local/mib2c
@@ -60,8 +60,9 @@ $currentlevel = -1;
if($ENV{MIB2C_DIR}) {
push @def_search_dirs, split(/:/, $ENV{MIB2C_DIR});
}
-push @def_search_dirs, "/usr/local/share/snmp/";
-push @def_search_dirs, "/usr/local/share/snmp/mib2c-data";
+push @def_search_dirs, "/etc/snmp/";
+push @def_search_dirs, "/usr/share/snmp/";
+push @def_search_dirs, "/usr/share/snmp/mib2c-data";
push @def_search_dirs, "./mib2c-conf.d";
sub usage {

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,11 @@
--- a/configure
+++ b/configure
@@ -10216,7 +10216,7 @@ linux* | k*bsd*-gnu)
need_version=no
library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
soname_spec='${libname}${release}${shared_ext}$major'
- finish_cmds='PATH="\$PATH:/sbin" ldconfig -n $libdir'
+ finish_cmds=''
shlibpath_var=LD_LIBRARY_PATH
shlibpath_overrides_runpath=no
# This implies no fast_install, which is unacceptable.

View File

@ -0,0 +1,11 @@
--- a/Makefile.top
+++ b/Makefile.top
@@ -81,7 +81,7 @@ LIBCURRENT = 16
LIBAGE = 1
LIBREVISION = 3
-LIB_LD_CMD = $(LIBTOOL) --mode=link $(LINKCC) $(CFLAGS) -rpath $(libdir) -version-info $(LIBCURRENT):$(LIBREVISION):$(LIBAGE) -o
+LIB_LD_CMD = $(LIBTOOL) --mode=link $(LINKCC) $(CFLAGS) -rpath $(libdir) $(LDFLAGS) -version-info $(LIBCURRENT):$(LIBREVISION):$(LIBAGE) -o
LIB_EXTENSION = la
LIB_VERSION =
LIB_LDCONFIG_CMD = $(LIBTOOL) --mode=finish $(libdir)

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,29 @@
--- a/agent/mibgroup/host/hr_filesys.c
+++ b/agent/mibgroup/host/hr_filesys.c
@@ -322,13 +322,13 @@ var_hrfilesys(struct variable *vp,
long_return = fsys_idx;
return (u_char *) & long_return;
case HRFSYS_MOUNT:
- snprintf(string, sizeof(string), HRFS_entry->HRFS_mount);
+ snprintf(string, sizeof(string), "%s", HRFS_entry->HRFS_mount);
string[ sizeof(string)-1 ] = 0;
*var_len = strlen(string);
return (u_char *) string;
case HRFSYS_RMOUNT:
if (Check_HR_FileSys_NFS()) {
- snprintf(string, sizeof(string), HRFS_entry->HRFS_name);
+ snprintf(string, sizeof(string), "%s", HRFS_entry->HRFS_name);
string[ sizeof(string)-1 ] = 0;
} else
string[0] = '\0';
--- a/agent/mibgroup/ucd-snmp/extensible.c
+++ b/agent/mibgroup/ucd-snmp/extensible.c
@@ -513,7 +513,7 @@ fixExecError(int action,
}
tmp = *((long *) var_val);
if ((tmp == 1) && (action == COMMIT) && (exten->fixcmd[0] != 0)) {
- sprintf(ex.command, exten->fixcmd);
+ sprintf(ex.command, "%s", exten->fixcmd);
if ((fd = get_exec_output(&ex)) != -1) {
file = fdopen(fd, "r");
while (fgets(ex.output, sizeof(ex.output), file) != NULL);