Control: tag -1 + patch Hello people,
please find attached two patches to apply to the pkg-net-snmp git repository. The first one is the inclusion of the last NMU by Steinar Gundersson. The second one adds two systemd service files with the required packaging changes. Hideki, you seem to be the only active maintainer lately, can you apply those patches and make an upload or would you prefer an non-maintainer upload? Following systemd best practices, I opted to not load /etc/default/snmpd in the environment. Any customization shall be made with override files and I documented this in the "*.default" files. Thank you. PS: I would have gladly committed my work in your git repository, unfortunately the pkg-net-snmp repository is not writable to all Debian developers. The package does not seem to be very actively maintained... maybe it would be a good idea to drop from Uploaders the people who are not doing anything and possibly move the package to collab-maint so that it's easier for drive-by contributors like me to help you? PPS: Thomas, Tom, Sam, Mathieu, feel free to test this patch and to report back any problem that you might have discovered. While I ensured that the daemon start properly, I'm not an actual net-snmp user and would welcome a confirmation by real users that it works as expected. -- Raphaël Hertzog ◈ Debian Developer Support Debian LTS: http://www.freexian.com/services/debian-lts.html Learn to master Debian: http://debian-handbook.info/get/
>From d3d855abff7578733d7f8d595de2259f01ef0ae1 Mon Sep 17 00:00:00 2001 From: "Steinar H. Gunderson" <[email protected]> Date: Thu, 31 Mar 2016 01:05:01 +0200 Subject: [PATCH 1/2] Imported Debian patch 5.7.3+dfsg-1.3 --- debian/changelog | 51 +++++++- debian/control | 1 + debian/patches/26_kfreebsd.patch | 22 +--- debian/patches/27_kfreebsd.patch | 25 ++++ ...ix-kfreebsd-builds-with-kernel-headers-10.patch | 41 ------- debian/patches/callback_print.diff | 13 +++ .../do_not_callback_for_failed_reports.diff | 129 +++++++++++++++++++++ debian/patches/fix_engineid_reprobe.diff | 16 +++ debian/patches/fix_perl_bulk_gets.diff | 88 ++++++++++++++ debian/patches/let_perl_access_engineid.diff | 94 +++++++++++++++ debian/patches/series | 7 +- debian/rules | 10 +- debian/snmpd.default | 2 +- debian/snmpd.postinst | 2 +- 14 files changed, 437 insertions(+), 64 deletions(-) create mode 100644 debian/patches/27_kfreebsd.patch delete mode 100644 debian/patches/Fix-kfreebsd-builds-with-kernel-headers-10.patch create mode 100644 debian/patches/callback_print.diff create mode 100644 debian/patches/do_not_callback_for_failed_reports.diff create mode 100644 debian/patches/fix_engineid_reprobe.diff create mode 100644 debian/patches/fix_perl_bulk_gets.diff create mode 100644 debian/patches/let_perl_access_engineid.diff diff --git a/debian/changelog b/debian/changelog index cd8a1bd..a0df929 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,5 +1,30 @@ -net-snmp (5.7.3+dfsg-2) UNRELEASED; urgency=medium +net-snmp (5.7.3+dfsg-1.3) unstable; urgency=medium + * _Really_ add missing Build-Depends: pkg-config on kfreebsd + (Closes: #810982). + + -- Steinar H. Gunderson <[email protected]> Thu, 31 Mar 2016 01:05:01 +0200 + +net-snmp (5.7.3+dfsg-1.2) unstable; urgency=medium + + * Non-maintainer upload. + + [ Steven Chamberlain ] + * Add missing Build-Depends: pkg-config on kfreebsd (Closes: #810982) + + [ Steinar H. Gunderson ] + * Add --force-badname when creating the Debian-snmp user, as the name would + otherwise be rejected. (Closes: #819531) + + -- Steinar H. Gunderson <[email protected]> Wed, 30 Mar 2016 21:46:44 +0200 + +net-snmp (5.7.3+dfsg-1.1) unstable; urgency=medium + + * Non-maintainer upload, done on top of the latest version in pkg-net-snmp + git, as well as adding Steven Chamberlain's kFreeBSD patches from + bug #810892. + + [ Hideki Yamane ] * debian/patches - add Bug-788964-net-snmp-snmp_pdu_parse-DoS.patch (Closes: #788964) - add 0026-fix-Bug-785380-incorrect-date-format.patch (Closes: #785380) @@ -14,7 +39,29 @@ net-snmp (5.7.3+dfsg-2) UNRELEASED; urgency=medium * debian/snmp.preinst - revert "killall", it is unnecessary anymore (Closes: #781257) - -- Hideki Yamane <[email protected]> Thu, 18 Jun 2015 06:43:28 +0900 + [ Steven Chamberlain ] + * Fix a typo in 26_kfreebsd.patch + * Add 27_kfreebsd.patch: (Closes: #810982) + - Add missing dependency of mibII/icmp on kfreebsd + - Add kfreebsd definitions not in GNU libc's icmp6.h + * Remove obsolete Fix-kfreebsd-builds-with-kernel-headers-10.patch + * Re-enable IPv6 on kfreebsd (Closes: #765846) + * Build with the libbsd overlay on kfreebsd, for nlist + + [ Steinar H. Gunderson ] + * New patches, mostly for various bug fixes (some of them for crash bugs): + * fix_engineid_reprobe.diff: Do not probe engineID for USM + if it is already given. (Closes: #765873) + * callback_print.diff: Fix enum formatting when doing asynchronous queries + from Perl. (Closes: #765289) + * do_not_callback_for_failed_reports.diff: Fix access of freed data due to + callbacks for reports occasionally coming twice. + * fix_perl_bulk_gets.diff: Fix handling of truncated bulk get responses + in the Perl module. (Patch 1278 in upstream patch tracker.) + * let_perl_access_engineid.diff: Add a new functions to let Perl code + access the security engine ID. + + -- Steinar H. Gunderson <[email protected]> Tue, 29 Mar 2016 10:30:24 +0200 net-snmp (5.7.3+dfsg-1) unstable; urgency=medium diff --git a/debian/control b/debian/control index 0aa5574..a78685b 100644 --- a/debian/control +++ b/debian/control @@ -8,6 +8,7 @@ Build-Depends: debhelper (>= 9), libtool, libwrap0-dev, libssl-dev (>> 0.9.8), p python-all (>= 2.6.6-3~), python-setuptools (>=0.6b3), python2.7-dev, autoconf, automake, autotools-dev, debianutils (>=1.13.1), dh-autoreconf, bash (>=2.05), findutils (>=4.1.20), procps, + pkg-config [kfreebsd-i386 kfreebsd-amd64], libbsd-dev [kfreebsd-i386 kfreebsd-amd64], libkvm-dev [kfreebsd-i386 kfreebsd-amd64], libsensors4-dev [!hurd-i386 !kfreebsd-i386 !kfreebsd-amd64], diff --git a/debian/patches/26_kfreebsd.patch b/debian/patches/26_kfreebsd.patch index d758e17..60fa7a0 100644 --- a/debian/patches/26_kfreebsd.patch +++ b/debian/patches/26_kfreebsd.patch @@ -1,14 +1,4 @@ -From: Net-SNMP Packaging Team <[email protected]> -Date: Thu, 18 Jun 2015 06:12:05 +0900 -Subject: _kfreebsd - Preliminary support for kfreebsd. ---- - agent/mibgroup/hardware/cpu/cpu_sysctl.c | 14 +++++++------- - 1 file changed, 7 insertions(+), 7 deletions(-) - -diff --git a/agent/mibgroup/hardware/cpu/cpu_sysctl.c b/agent/mibgroup/hardware/cpu/cpu_sysctl.c -index 5ecb68e..f0899c2 100644 --- a/agent/mibgroup/hardware/cpu/cpu_sysctl.c +++ b/agent/mibgroup/hardware/cpu/cpu_sysctl.c @@ -12,7 +12,7 @@ @@ -20,7 +10,7 @@ index 5ecb68e..f0899c2 100644 #include <sys/resource.h> #if !defined(CPUSTATES) #include <sys/dkstat.h> -@@ -89,7 +89,7 @@ void init_cpu_sysctl( void ) { +@@ -89,7 +89,7 @@ #elif defined(KERN_CPTIME) /* OpenBSD */ #define NETSNMP_KERN_CPU KERN_CPTIME @@ -29,7 +19,7 @@ index 5ecb68e..f0899c2 100644 #define NETSNMP_KERN_MCPU 1 /* Enable support for multi-cpu stats. Valid for FreeBSD >=6.4, >=7.1, >=8.0 and beyond */ #define NETSNMP_KERN_MCPU_TYPE NETSNMP_CPU_STATS -@@ -129,7 +129,7 @@ void init_cpu_sysctl( void ) { +@@ -129,7 +129,7 @@ #define NETSNMP_VM_STATS_TYPE struct uvmexp #endif /* VM_UVMEXP2 || VM_UVMEXP */ @@ -38,12 +28,12 @@ index 5ecb68e..f0899c2 100644 #define NETSNMP_VM_STATS VM_METER #define NETSNMP_VM_STATS_TYPE struct vmmeter #define NS_VM_INTR v_intr -@@ -169,10 +169,10 @@ int netsnmp_cpu_arch_load( netsnmp_cache *cache, void *magic ) { +@@ -169,10 +169,10 @@ */ NETSNMP_CPU_STATS cpu_stats[CPUSTATES]; size_t cpu_size = sizeof(cpu_stats); -#if !defined(__FreeBSD__) && !defined(__NetBSD__) -+#if !defined(__FreeBSD__) || defined(__FreeBSD_kernel__) && !defined(__NetBSD__) ++#if !defined(__FreeBSD__) && !defined(__FreeBSD_kernel__) && !defined(__NetBSD__) int cpu_mib[] = { CTL_KERN, NETSNMP_KERN_CPU }; #endif -#ifdef __FreeBSD__ @@ -51,7 +41,7 @@ index 5ecb68e..f0899c2 100644 static int cp_times = -1; #endif #ifdef KERN_CPTIME2 -@@ -189,7 +189,7 @@ int netsnmp_cpu_arch_load( netsnmp_cache *cache, void *magic ) { +@@ -189,7 +189,7 @@ size_t mem_size = sizeof(NETSNMP_VM_STATS_TYPE); netsnmp_cpu_info *cpu = netsnmp_cpu_get_byIdx( -1, 0 ); @@ -60,7 +50,7 @@ index 5ecb68e..f0899c2 100644 sysctlbyname("kern.cp_time", cpu_stats, &cpu_size, NULL, 0); #else sysctl(cpu_mib, 2, cpu_stats, &cpu_size, NULL, 0); -@@ -226,7 +226,7 @@ int netsnmp_cpu_arch_load( netsnmp_cache *cache, void *magic ) { +@@ -226,7 +226,7 @@ mcpu_size = cpu_num*sizeof(cpu_stats); mcpu_stats = malloc(mcpu_size); sysctlbyname("kern.cp_time", mcpu_stats, &mcpu_size, NULL, 0); diff --git a/debian/patches/27_kfreebsd.patch b/debian/patches/27_kfreebsd.patch new file mode 100644 index 0000000..4620da4 --- /dev/null +++ b/debian/patches/27_kfreebsd.patch @@ -0,0 +1,25 @@ +--- a/agent/mibgroup/mibII/icmp.h ++++ b/agent/mibgroup/mibII/icmp.h +@@ -14,6 +14,7 @@ + config_arch_require(freebsd8, mibII/kernel_sysctl) + config_arch_require(freebsd9, mibII/kernel_sysctl) + config_arch_require(freebsd10, mibII/kernel_sysctl) ++config_arch_require(kfreebsd, mibII/kernel_sysctl) + config_arch_require(netbsd, mibII/kernel_netbsd) + config_arch_require(netbsdelf, mibII/kernel_netbsd) + config_arch_require(openbsd4, mibII/kernel_sysctl) +--- a/agent/mibgroup/mibII/kernel_sysctl.c ++++ b/agent/mibgroup/mibII/kernel_sysctl.c +@@ -14,6 +14,12 @@ + #include <netinet/icmp_var.h> + #include <netinet/icmp6.h> + ++#if defined(__FreeBSD_kernel__) && defined(__GLIBC__) ++/* definitions unavailable in GNU libc's icmp6.h */ ++#define ICMP6_MAXTYPE 201 ++#define ICMPV6CTL_STATS 1 ++#endif ++ + #include <net-snmp/net-snmp-config.h> + #include <net-snmp/net-snmp-includes.h> + #include <net-snmp/agent/net-snmp-agent-includes.h> diff --git a/debian/patches/Fix-kfreebsd-builds-with-kernel-headers-10.patch b/debian/patches/Fix-kfreebsd-builds-with-kernel-headers-10.patch deleted file mode 100644 index c878ee3..0000000 --- a/debian/patches/Fix-kfreebsd-builds-with-kernel-headers-10.patch +++ /dev/null @@ -1,41 +0,0 @@ -From: Niko Tyni <[email protected]> -Date: Wed, 16 Jul 2014 21:42:30 +0000 -Subject: Fix kfreebsd builds with kernel headers >= 10 - -This fixes warnings like - -In file included from ../../include/net-snmp/net-snmp-config.h:2085:0, - from host/data_access/swinst_apt.c:5: -../../include/net-snmp/system/kfreebsd.h:5:0: warning: "__FreeBSD_version" redefined [enabled by default] - #define __FreeBSD_version __FreeBSD_kernel_version - ^ -In file included from /usr/include/sys/kern/param.h:1:0, - from /usr/include/osreldate.h:1, - from ../../include/net-snmp/system/kfreebsd.h:4, - from ../../include/net-snmp/net-snmp-config.h:2085, - from host/data_access/swinst_apt.c:5: -/usr/include/sys/kglue/sys/param.h:67:0: note: this is the location of the previous definition - #define __FreeBSD_version 1000510 /* Master, propagated to newvers */ - -and makes agent/mibgroup/host/data_access/swrun_kinfo.c use the modern -kinfo_proc field names. - -Bug-Debian: http://bugs.debian.org/753144 ---- - include/net-snmp/system/kfreebsd.h | 2 ++ - 1 file changed, 2 insertions(+) - -diff --git a/include/net-snmp/system/kfreebsd.h b/include/net-snmp/system/kfreebsd.h -index dbf7024..cb32758 100644 ---- a/include/net-snmp/system/kfreebsd.h -+++ b/include/net-snmp/system/kfreebsd.h -@@ -2,7 +2,9 @@ - #define freebsd6 freebsd6 - - #include <osreldate.h> -+#if defined(__FreeBSD_kernel_version) && !defined(__FreeBSD_version) - #define __FreeBSD_version __FreeBSD_kernel_version -+#endif - - #include <sys/queue.h> - #include <sys/_types.h> diff --git a/debian/patches/callback_print.diff b/debian/patches/callback_print.diff new file mode 100644 index 0000000..f4b6df6 --- /dev/null +++ b/debian/patches/callback_print.diff @@ -0,0 +1,13 @@ +--- net-snmp-5.7.2.1~dfsg.orig/perl/SNMP/SNMP.xs ++++ net-snmp-5.7.2.1~dfsg/perl/SNMP/SNMP.xs +@@ -1300,6 +1300,10 @@ void *cb_data; + netsnmp_ds_set_boolean(NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_PRINT_NUMERIC_OIDS, 1); + netsnmp_ds_set_int(NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_OID_OUTPUT_FORMAT, NETSNMP_OID_OUTPUT_NUMERIC); + } ++ if (SvIV(*hv_fetch((HV*)SvRV(sess_ref),"UseEnums", 8, 1))) ++ sprintval_flag = USE_ENUMS; ++ if (SvIV(*hv_fetch((HV*)SvRV(sess_ref),"UseSprintValue", 14, 1))) ++ sprintval_flag = USE_SPRINT_VALUE; + + sv_bless(varlist_ref, gv_stashpv("SNMP::VarList",0)); + for(vars = (pdu?pdu->variables:NULL); vars; vars = vars->next_variable) { diff --git a/debian/patches/do_not_callback_for_failed_reports.diff b/debian/patches/do_not_callback_for_failed_reports.diff new file mode 100644 index 0000000..96db193 --- /dev/null +++ b/debian/patches/do_not_callback_for_failed_reports.diff @@ -0,0 +1,129 @@ +Index: net-snmp-5.7.3/snmplib/snmp_api.c +=================================================================== +--- net-snmp-5.7.3.orig/snmplib/snmp_api.c ++++ net-snmp-5.7.3/snmplib/snmp_api.c +@@ -5346,71 +5346,71 @@ _sess_process_packet(void *sessp, netsnm + * should be per session ! + */ + +- if (callback == NULL +- || callback(NETSNMP_CALLBACK_OP_RECEIVED_MESSAGE, sp, +- pdu->reqid, pdu, magic) == 1) { +- if (pdu->command == SNMP_MSG_REPORT) { +- if (sp->s_snmp_errno == SNMPERR_NOT_IN_TIME_WINDOW || +- snmpv3_get_report_type(pdu) == +- SNMPERR_NOT_IN_TIME_WINDOW) { +- /* +- * trigger immediate retry on recoverable Reports +- * * (notInTimeWindow), incr_retries == TRUE to prevent +- * * inifinite resend +- */ +- if (rp->retries <= sp->retries) { +- snmp_resend_request(slp, rp, TRUE); +- break; +- } else { +- /* We're done with retries, so no longer waiting for a response */ +- if (magic) { +- ((struct synch_state*)magic)->waiting = 0; +- } +- } ++ if (pdu->command == SNMP_MSG_REPORT) { ++ if (sp->s_snmp_errno == SNMPERR_NOT_IN_TIME_WINDOW || ++ snmpv3_get_report_type(pdu) == ++ SNMPERR_NOT_IN_TIME_WINDOW) { ++ /* ++ * trigger immediate retry on recoverable Reports ++ * * (notInTimeWindow), incr_retries == TRUE to prevent ++ * * inifinite resend ++ */ ++ if (rp->retries <= sp->retries) { ++ snmp_resend_request(slp, rp, TRUE); ++ break; + } else { +- if (SNMPV3_IGNORE_UNAUTH_REPORTS) { +- break; +- } else { /* Set the state to no longer be waiting, since we're done with retries */ +- if (magic) { +- ((struct synch_state*)magic)->waiting = 0; +- } ++ /* We're done with retries, so no longer waiting for a response */ ++ if (magic) { ++ ((struct synch_state*)magic)->waiting = 0; ++ } ++ } ++ } else { ++ if (SNMPV3_IGNORE_UNAUTH_REPORTS) { ++ break; ++ } else { /* Set the state to no longer be waiting, since we're done with retries */ ++ if (magic) { ++ ((struct synch_state*)magic)->waiting = 0; + } + } ++ } + +- /* +- * Handle engineID discovery. +- */ +- if (!sp->securityEngineIDLen && pdu->securityEngineIDLen) { +- sp->securityEngineID = +- (u_char *) malloc(pdu->securityEngineIDLen); +- if (sp->securityEngineID == NULL) { ++ /* ++ * Handle engineID discovery. ++ */ ++ if (!sp->securityEngineIDLen && pdu->securityEngineIDLen) { ++ sp->securityEngineID = ++ (u_char *) malloc(pdu->securityEngineIDLen); ++ if (sp->securityEngineID == NULL) { ++ /* ++ * TODO FIX: recover after message callback *? ++ */ ++ return -1; ++ } ++ memcpy(sp->securityEngineID, pdu->securityEngineID, ++ pdu->securityEngineIDLen); ++ sp->securityEngineIDLen = pdu->securityEngineIDLen; ++ if (!sp->contextEngineIDLen) { ++ sp->contextEngineID = ++ (u_char *) malloc(pdu-> ++ securityEngineIDLen); ++ if (sp->contextEngineID == NULL) { + /* + * TODO FIX: recover after message callback *? +- */ ++ */ + return -1; + } +- memcpy(sp->securityEngineID, pdu->securityEngineID, ++ memcpy(sp->contextEngineID, ++ pdu->securityEngineID, + pdu->securityEngineIDLen); +- sp->securityEngineIDLen = pdu->securityEngineIDLen; +- if (!sp->contextEngineIDLen) { +- sp->contextEngineID = +- (u_char *) malloc(pdu-> +- securityEngineIDLen); +- if (sp->contextEngineID == NULL) { +- /* +- * TODO FIX: recover after message callback *? +- */ +- return -1; +- } +- memcpy(sp->contextEngineID, +- pdu->securityEngineID, +- pdu->securityEngineIDLen); +- sp->contextEngineIDLen = +- pdu->securityEngineIDLen; +- } ++ sp->contextEngineIDLen = ++ pdu->securityEngineIDLen; + } + } ++ } + ++ if (callback == NULL || ++ callback(NETSNMP_CALLBACK_OP_RECEIVED_MESSAGE, sp, ++ pdu->reqid, pdu, magic) == 1) { + /* + * Successful, so delete request. + */ diff --git a/debian/patches/fix_engineid_reprobe.diff b/debian/patches/fix_engineid_reprobe.diff new file mode 100644 index 0000000..c9d4778 --- /dev/null +++ b/debian/patches/fix_engineid_reprobe.diff @@ -0,0 +1,16 @@ +Index: net-snmp-5.7.3/snmplib/snmpusm.c +=================================================================== +--- net-snmp-5.7.3.orig/snmplib/snmpusm.c ++++ net-snmp-5.7.3/snmplib/snmpusm.c +@@ -3129,6 +3129,11 @@ int usm_discover_engineid(void *slpv, ne + int status, i; + struct session_list *slp = (struct session_list *) slpv; + ++ if (slp->session->securityEngineIDLen != 0) { ++ DEBUGMSGTL(("snmp_api", "engineID already known, skipping probe\n")); ++ return SNMPERR_SUCCESS; ++ } ++ + if (usm_build_probe_pdu(&pdu) != 0) { + DEBUGMSGTL(("snmp_api", "unable to create probe PDU\n")); + return SNMP_ERR_GENERR; diff --git a/debian/patches/fix_perl_bulk_gets.diff b/debian/patches/fix_perl_bulk_gets.diff new file mode 100644 index 0000000..88d1fe4 --- /dev/null +++ b/debian/patches/fix_perl_bulk_gets.diff @@ -0,0 +1,88 @@ +Index: net-snmp-5.7.2.1+dfsg/perl/SNMP/SNMP.pm +=================================================================== +--- net-snmp-5.7.2.1+dfsg.orig/perl/SNMP/SNMP.pm ++++ net-snmp-5.7.2.1+dfsg/perl/SNMP/SNMP.pm +@@ -866,22 +866,11 @@ sub _gettable_do_it() { + + $vbl = $_[$#_] if ($state->{'options'}{'callback'}); + +- while ($#$vbl > -1 && !$this->{ErrorNum}) { +- if (($#$vbl + 1) % ($#{$state->{'stopconds'}} + 1) != 0) { +- if ($vbl->[$#$vbl][2] ne 'ENDOFMIBVIEW') { +- # unless it's an end of mib view we didn't get the +- # proper number of results back. +- print STDERR "ack: gettable results not appropriate\n"; +- } +- my @k = keys(%{$state->{'result_hash'}}); +- last if ($#k > -1); # bail with what we have +- return; +- } +- +- $state->{'varbinds'} = []; +- my $newstopconds; ++ my $num_vbls = defined($vbl) ? scalar @$vbl : 0; ++ my $num_stopconds = scalar @{$state->{'stopconds'}}; + +- my $lastsetstart = ($state->{'repeatcount'}-1) * ($#{$state->{'stopconds'}}+1); ++ while ($num_vbls > 0 && !$this->{ErrorNum}) { ++ my @found_eof = (0) x $num_stopconds; + + for (my $i = 0; $i <= $#$vbl; $i++) { + my $row_oid = SNMP::translateObj($vbl->[$i][0]); +@@ -890,9 +879,11 @@ sub _gettable_do_it() { + my $row_value = $vbl->[$i][2]; + my $row_type = $vbl->[$i][3]; + +- if ($row_oid =~ +- /^$state->{'stopconds'}[$i % ($#{$state->{'stopconds'}}+1)]/ && +- $row_value ne 'ENDOFMIBVIEW' ){ ++ my $stopcond_num = $i % $num_stopconds; ++ my $stopcond = $state->{'stopconds'}[$stopcond_num]; ++ if ($row_oid !~ /^\Q$stopcond\E/ || $row_value eq 'ENDOFMIBVIEW') { ++ $found_eof[$stopcond_num] = 1; ++ } else { + + if ($row_type eq "OBJECTID") { + +@@ -903,26 +894,30 @@ sub _gettable_do_it() { + + } + ++ # continue past this next time ++ ++ $state->{'varbinds'}[$stopcond_num] = [ $row_text, $row_index ]; ++ + # Place the results in a hash + + $state->{'result_hash'}{$row_index}{$row_text} = $row_value; ++ } ++ } + +- # continue past this next time +- if ($i >= $lastsetstart) { +- push @$newstopconds, +- $state->{'stopconds'}->[$i%($#{$state->{'stopconds'}}+1)]; +- push @{$state->{'varbinds'}},[$vbl->[$i][0],$vbl->[$i][1]]; +- } ++ my @newstopconds = (); ++ my @newvarbinds = (); ++ for (my $i = 0; $i < $num_stopconds; ++$i) { ++ unless ($found_eof[$i]) { ++ push @newstopconds, $state->{'stopconds'}[$i]; ++ push @newvarbinds, $state->{'varbinds'}[$i]; + } + } +- if ($#$newstopconds == -1) { ++ if ($#newstopconds == -1) { + last; + } +- if ($#{$state->{'varbinds'}} == -1) { +- print "gettable ack. shouldn't get here\n"; +- } ++ $state->{'varbinds'} = \@newvarbinds; ++ $state->{'stopconds'} = \@newstopconds; + $vbl = $state->{'varbinds'}; +- $state->{'stopconds'} = $newstopconds; + + # + # if we've been configured with a callback, then call the diff --git a/debian/patches/let_perl_access_engineid.diff b/debian/patches/let_perl_access_engineid.diff new file mode 100644 index 0000000..b65135f --- /dev/null +++ b/debian/patches/let_perl_access_engineid.diff @@ -0,0 +1,94 @@ +Index: net-snmp-5.7.2.1+dfsg/perl/SNMP/SNMP.pm +=================================================================== +--- net-snmp-5.7.2.1+dfsg.orig/perl/SNMP/SNMP.pm ++++ net-snmp-5.7.2.1+dfsg/perl/SNMP/SNMP.pm +@@ -1238,6 +1238,16 @@ sub inform { + return(wantarray() ? @res : $res[0]); + } + ++sub get_sec_engine_id { ++ my $this = shift; ++ return SNMP::_get_sec_engine_id($this); ++} ++ ++sub get_context_engine_id { ++ my $this = shift; ++ return SNMP::_get_context_engine_id($this); ++} ++ + package SNMP::TrapSession; + @SNMP::TrapSession::ISA = ('SNMP::Session'); + +@@ -2034,6 +2044,17 @@ as well. + + =back + ++=item $sess->get_sec_engine_id ++ ++Returns the security engine ID for the current session, whether probed ++or provided by the client, in hex format suitable for the SecEngineId ++parameter when creating a session in the future. Returns undef if we have not ++had not had any contact with the remote agent yet. ++ ++=item $sess->get_context_engine_id ++ ++Like get_sec_engine_id, but for the context engine ID (ContextEngineId). ++ + =back + + =head1 SNMP::TrapSession +Index: net-snmp-5.7.2.1+dfsg/perl/SNMP/SNMP.xs +=================================================================== +--- net-snmp-5.7.2.1+dfsg.orig/perl/SNMP/SNMP.xs ++++ net-snmp-5.7.2.1+dfsg/perl/SNMP/SNMP.xs +@@ -4741,6 +4741,50 @@ done: + + + char * ++snmp_get_sec_engine_id(sess_ref) ++ SV * sess_ref ++ CODE: ++ { ++ RETVAL = NULL; ++ if (SvROK(sess_ref)) { ++ SV **sess_ptr_sv = hv_fetch((HV*)SvRV(sess_ref), "SessPtr", 7, 1); ++ SnmpSession *ss = (SnmpSession *)SvIV((SV*)SvRV(*sess_ptr_sv)); ++ if (ss->securityEngineIDLen > 0) { ++ binary_to_hex(ss->securityEngineID, ++ ss->securityEngineIDLen, ++ &RETVAL); ++ } ++ } ++ } ++ OUTPUT: ++ RETVAL ++ CLEANUP: ++ netsnmp_free(RETVAL); ++ ++ ++char * ++snmp_get_context_engine_id(sess_ref) ++ SV * sess_ref ++ CODE: ++ { ++ RETVAL = NULL; ++ if (SvROK(sess_ref)) { ++ SV **sess_ptr_sv = hv_fetch((HV*)SvRV(sess_ref), "SessPtr", 7, 1); ++ SnmpSession *ss = (SnmpSession *)SvIV((SV*)SvRV(*sess_ptr_sv)); ++ if (ss->contextEngineIDLen > 0) { ++ binary_to_hex(ss->contextEngineID, ++ ss->contextEngineIDLen, ++ &RETVAL); ++ } ++ } ++ } ++ OUTPUT: ++ RETVAL ++ CLEANUP: ++ netsnmp_free(RETVAL); ++ ++ ++char * + snmp_get_type(tag, best_guess) + char * tag + int best_guess diff --git a/debian/patches/series b/debian/patches/series index d51c163..a93def2 100644 --- a/debian/patches/series +++ b/debian/patches/series @@ -4,6 +4,7 @@ 06_extramibs.patch 07_docfiles.patch 26_kfreebsd.patch +27_kfreebsd.patch 60_libsensors_api.patch 61_vacm_missing_dependency_check.patch 62_add_lib_cflags.patch @@ -20,8 +21,12 @@ fix_manpage-has-errors_break_line.patch add_rocommunity6.patch fix_manpage-has-errors-from-man.patch agentx-crash.patch -Fix-kfreebsd-builds-with-kernel-headers-10.patch fix-request-id-0.patch 0025-Bug-788964-net-snmp-snmp_pdu_parse-DoS.patch 0026-fix-Bug-785380-incorrect-date-format.patch 0027-fix-455707-traptoemail-use-FQDN.patch +let_perl_access_engineid.diff +fix_perl_bulk_gets.diff +do_not_callback_for_failed_reports.diff +callback_print.diff +fix_engineid_reprobe.diff diff --git a/debian/rules b/debian/rules index d1da11e..d2e7ece 100755 --- a/debian/rules +++ b/debian/rules @@ -23,8 +23,10 @@ IPV6 = --enable-ipv6 DEB_DH_GENCONTROL_ARGS=-- -Vos-specific-dev="libsensors4-dev" else ifeq (kfreebsd,$(DEB_BUILD_ARCH_OS)) -IPV6 = --disable-ipv6 +IPV6 = --enable-ipv6 DEB_DH_GENCONTROL_ARGS=-- -Vos-specific-dev="libkvm-dev" +CFLAGS += $(shell pkg-config --cflags libbsd-overlay) +LDFLAGS += $(shell pkg-config --libs libbsd-overlay) endif endif ifeq (hurd,$(DEB_BUILD_ARCH_OS)) @@ -62,7 +64,11 @@ override_dh_clean: dh_clean rm -rf `find . -name .libs` \ python/build \ - python/netsnmp_python.egg-info + python/netsnmp_python.egg-info \ + dist/generation-scripts/gen-variables \ + perl/SNMP/t/snmptest.cmd \ + perl/TrapReceiver/const-c.inc \ + perl/TrapReceiver/const-xs.inc override_dh_strip: dh_strip -plibsnmp$(LIB_VERSION) --dbg-package=libsnmp$(LIB_VERSION)-dbg diff --git a/debian/snmpd.default b/debian/snmpd.default index e47dec8..f4ee7a7 100644 --- a/debian/snmpd.default +++ b/debian/snmpd.default @@ -8,4 +8,4 @@ export MIBS= SNMPDRUN=yes # snmpd options (use syslog, close stdin/out/err). -SNMPDOPTS='-Lsd -Lf /dev/null -u snmp -g snmp -I -smux,mteTrigger,mteTriggerConf -p /run/snmpd.pid' +SNMPDOPTS='-Lsd -Lf /dev/null -u Debian-snmp -g Debian-snmp -I -smux,mteTrigger,mteTriggerConf -p /run/snmpd.pid' diff --git a/debian/snmpd.postinst b/debian/snmpd.postinst index 67f4712..13d9baa 100644 --- a/debian/snmpd.postinst +++ b/debian/snmpd.postinst @@ -15,7 +15,7 @@ case "$1" in adduser --quiet --system --group --home "$SNMP_DIR" \ --disabled-password --disabled-login \ - --shell "$SNMP_SHELL" "$SNMP_USER" + --shell "$SNMP_SHELL" --force-badname "$SNMP_USER" # care if SNMP_DIR is used by previous "snmp" user chown -R "$SNMP_USER"."$SNMP_GROUP" "$SNMP_DIR" -- 2.8.1
>From c1a94db887e9da65ae2f879b8bae8fa7ac758982 Mon Sep 17 00:00:00 2001 From: Sophie Brun <[email protected]> Date: Fri, 10 Jun 2016 10:49:55 +0200 Subject: [PATCH 2/2] Add systemd service files MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Closes: #782243 Signed-off-by: Raphaël Hertzog <[email protected]> --- debian/changelog | 7 +++++++ debian/control | 3 ++- debian/rules | 6 +++++- debian/snmpd.default | 6 +++++- debian/snmpd.service | 15 +++++++++++++++ debian/snmptrapd.default | 6 +++++- debian/snmptrapd.service | 13 +++++++++++++ 7 files changed, 52 insertions(+), 4 deletions(-) create mode 100644 debian/snmpd.service create mode 100644 debian/snmptrapd.service diff --git a/debian/changelog b/debian/changelog index a0df929..bc94a83 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,10 @@ +net-snmp (5.7.3+dfsg-1.4) UNRELEASED; urgency=medium + + * Non-maintainer upload. + * Add a snmpd.service and a snmptrapd.service (Closes: #782243) + + -- Sophie Brun <[email protected]> Fri, 10 Jun 2016 10:48:02 +0200 + net-snmp (5.7.3+dfsg-1.3) unstable; urgency=medium * _Really_ add missing Build-Depends: pkg-config on kfreebsd diff --git a/debian/control b/debian/control index a78685b..d3af344 100644 --- a/debian/control +++ b/debian/control @@ -6,7 +6,8 @@ Uploaders: Jochen Friedrich <[email protected]>, Thomas Anders <[email protected] Hideki Yamane <[email protected]> Build-Depends: debhelper (>= 9), libtool, libwrap0-dev, libssl-dev (>> 0.9.8), perl (>=5.8), libperl-dev, python-all (>= 2.6.6-3~), python-setuptools (>=0.6b3), python2.7-dev, - autoconf, automake, autotools-dev, debianutils (>=1.13.1), dh-autoreconf, + autoconf, automake, autotools-dev, debianutils (>=1.13.1), + dh-autoreconf, dh-systemd, bash (>=2.05), findutils (>=4.1.20), procps, pkg-config [kfreebsd-i386 kfreebsd-amd64], libbsd-dev [kfreebsd-i386 kfreebsd-amd64], diff --git a/debian/rules b/debian/rules index d2e7ece..61ef247 100755 --- a/debian/rules +++ b/debian/rules @@ -37,7 +37,7 @@ MIB_MODULES += host endif %: - dh $@ --with autotools-dev,autoreconf,python2 + dh $@ --with autotools-dev,autoreconf,python2,systemd override_dh_auto_configure: dh_auto_configure -- --prefix=/usr --sysconfdir=/etc --mandir=/usr/share/man \ @@ -107,6 +107,10 @@ override_dh_auto_test: # prevent test since it fails with network configuration under pbuilder/etc. true +override_dh_systemd_enable: + dh_systemd_enable --package=snmptrapd --no-enable + dh_systemd_enable --remaining-packages + get-orig-source: @uscan --download-version $(UPSTREAM_VERSION) --destdir /tmp --force-download --no-symlink @tar xf /tmp/net-snmp-$(UPSTREAM_VERSION).tar.gz -C /tmp diff --git a/debian/snmpd.default b/debian/snmpd.default index f4ee7a7..f779013 100644 --- a/debian/snmpd.default +++ b/debian/snmpd.default @@ -1,4 +1,8 @@ -# This file controls the activity of snmpd +# This file controls the behaviour of /etc/init.d/snmpd +# but not of the corresponding systemd service file. +# If needed, create an override file in +# /etc/systemd/system/snmpd.service.d/local.conf +# see man 5 systemd.unit and man 5 systemd.service # Don't load any MIBs by default. # You might comment this lines once you have the MIBs downloaded. diff --git a/debian/snmpd.service b/debian/snmpd.service new file mode 100644 index 0000000..64ccb3a --- /dev/null +++ b/debian/snmpd.service @@ -0,0 +1,15 @@ +[Unit] +Description=Simple Network Management Protocol (SNMP) Daemon. +After=network.target +ConditionPathExists=/etc/snmp/snmpd.conf + +[Service] +Environment="MIBSDIR=/usr/share/snmp/mibs:/usr/share/snmp/mibs/iana:/usr/share/snmp/mibs/ietf:/usr/share/mibs/site:/usr/share/snmp/mibs:/usr/share/mibs/iana:/usr/share/mibs/ietf:/usr/share/mibs/netsnmp" +Environment="MIBS=" +Type=simple +ExecStartPre=/bin/mkdir -p /var/run/agentx +ExecStart=/usr/sbin/snmpd -Lsd -Lf /dev/null -u Debian-snmp -g Debian-snmp -I -smux,mteTrigger,mteTriggerConf -f +ExecReload=/bin/kill -HUP $MAINPID + +[Install] +WantedBy=multi-user.target diff --git a/debian/snmptrapd.default b/debian/snmptrapd.default index 3649c48..0b8d9d1 100644 --- a/debian/snmptrapd.default +++ b/debian/snmptrapd.default @@ -1,4 +1,8 @@ -# This file controls the activity of snmptrapd +# This file controls the behaviour of /etc/init.d/snmptrapd +# but not of the corresponding systemd service file. +# If needed, create an override file in +# /etc/systemd/system/snmptrapd.service.d/local.conf +# see man 5 systemd.unit and man 5 systemd.service # snmptrapd control (yes means start daemon). As of net-snmp version # 5.0, master agentx support must be enabled in snmpd before snmptrapd diff --git a/debian/snmptrapd.service b/debian/snmptrapd.service new file mode 100644 index 0000000..052331b --- /dev/null +++ b/debian/snmptrapd.service @@ -0,0 +1,13 @@ +[Unit] +Description=Simple Network Management Protocol (SNMP) Trap Daemon. +After=network.target +ConditionPathExists=/etc/snmp/snmptrapd.conf + +[Service] +Environment="MIBSDIR=/usr/share/snmp/mibs:/usr/share/snmp/mibs/iana:/usr/share/snmp/mibs/ietf:/usr/share/mibs/site:/usr/share/snmp/mibs:/usr/share/mibs/iana:/usr/share/mibs/ietf:/usr/share/mibs/netsnmp" +Type=simple +ExecStart=/usr/sbin/snmptrapd -Lsd -f +ExecReload=/bin/kill -HUP $MAINPID + +[Install] +WantedBy=multi-user.target -- 2.8.1

