Accepting request 642087 from network:utilities

OBS-URL: https://build.opensuse.org/request/show/642087
OBS-URL: https://build.opensuse.org/package/show/openSUSE:Factory/net-snmp?expand=0&rev=88
This commit is contained in:
Dominique Leuenberger 2018-10-25 06:11:05 +00:00 committed by Git OBS Bridge
commit d8735beaeb
24 changed files with 757 additions and 6546 deletions

File diff suppressed because it is too large Load Diff

View File

@ -1,23 +0,0 @@
diff -up net-snmp-5.7.3/perl/ASN/Makefile.PL.orig net-snmp-5.7.3/perl/ASN/Makefile.PL
--- net-snmp-5.7.3/perl/ASN/Makefile.PL.orig 2016-05-06 10:35:30.005905040 +0200
+++ net-snmp-5.7.3/perl/ASN/Makefile.PL 2016-05-06 10:35:57.518776400 +0200
@@ -3,6 +3,7 @@ require 5;
use Config;
use Getopt::Long;
my $lib_version;
+my %MakeParams = ();
# See lib/ExtUtils/MakeMaker.pm for details of how to influence
# the contents of the Makefile that is written.
diff -up net-snmp-5.7.3/perl/Makefile.PL.orig net-snmp-5.7.3/perl/Makefile.PL
--- net-snmp-5.7.3/perl/Makefile.PL.orig 2016-05-06 10:34:38.975143641 +0200
+++ net-snmp-5.7.3/perl/Makefile.PL 2016-05-06 10:35:13.326983024 +0200
@@ -2,6 +2,7 @@ use ExtUtils::MakeMaker;
use Config;
use Getopt::Long;
require 5;
+my %MakeParams = ();
%MakeParams = InitMakeParams();

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -1,120 +0,0 @@
diff -Nurp net-snmp-5.7.3.pre5-orig/snmplib/snmp_api.c net-snmp-5.7.3.pre5/snmplib/snmp_api.c
--- net-snmp-5.7.3.pre5-orig/snmplib/snmp_api.c 2015-08-13 21:33:38.835653065 +0200
+++ net-snmp-5.7.3.pre5/snmplib/snmp_api.c 2015-08-13 21:54:03.099348588 +0200
@@ -4350,10 +4350,9 @@ snmp_pdu_parse(netsnmp_pdu *pdu, u_char
u_char type;
u_char msg_type;
u_char *var_val;
- int badtype = 0;
size_t len;
size_t four;
- netsnmp_variable_list *vp = NULL;
+ netsnmp_variable_list *vp = NULL, *vplast = NULL;
oid objid[MAX_OID_LEN];
u_char *p;
@@ -4493,38 +4492,24 @@ snmp_pdu_parse(netsnmp_pdu *pdu, u_char
(ASN_SEQUENCE | ASN_CONSTRUCTOR),
"varbinds");
if (data == NULL)
- return -1;
+ goto fail;
/*
* get each varBind sequence
*/
while ((int) *length > 0) {
- netsnmp_variable_list *vptemp;
- vptemp = (netsnmp_variable_list *) malloc(sizeof(*vptemp));
- if (NULL == vptemp) {
- return -1;
- }
- if (NULL == vp) {
- pdu->variables = vptemp;
- } else {
- vp->next_variable = vptemp;
- }
- vp = vptemp;
+ vp = SNMP_MALLOC_TYPEDEF(netsnmp_variable_list);
+ if (NULL == vp)
+ goto fail;
- vp->next_variable = NULL;
- vp->val.string = NULL;
vp->name_length = MAX_OID_LEN;
- vp->name = NULL;
- vp->index = 0;
- vp->data = NULL;
- vp->dataFreeHook = NULL;
DEBUGDUMPSECTION("recv", "VarBind");
data = snmp_parse_var_op(data, objid, &vp->name_length, &vp->type,
&vp->val_len, &var_val, length);
if (data == NULL)
- return -1;
+ goto fail;
if (snmp_set_var_objid(vp, objid, vp->name_length))
- return -1;
+ goto fail;
len = MAX_PACKET_LENGTH;
DEBUGDUMPHEADER("recv", "Value");
@@ -4604,7 +4589,7 @@ snmp_pdu_parse(netsnmp_pdu *pdu, u_char
vp->val.string = (u_char *) malloc(vp->val_len);
}
if (vp->val.string == NULL) {
- return -1;
+ goto fail;
}
p = asn_parse_string(var_val, &len, &vp->type, vp->val.string,
&vp->val_len);
@@ -4619,7 +4604,7 @@ snmp_pdu_parse(netsnmp_pdu *pdu, u_char
vp->val_len *= sizeof(oid);
vp->val.objid = (oid *) malloc(vp->val_len);
if (vp->val.objid == NULL) {
- return -1;
+ goto fail;
}
memmove(vp->val.objid, objid, vp->val_len);
break;
@@ -4631,21 +4616,37 @@ snmp_pdu_parse(netsnmp_pdu *pdu, u_char
case ASN_BIT_STR:
vp->val.bitstring = (u_char *) malloc(vp->val_len);
if (vp->val.bitstring == NULL) {
- return -1;
+ goto fail;
}
p = asn_parse_bitstring(var_val, &len, &vp->type,
vp->val.bitstring, &vp->val_len);
if (!p)
- return -1;
+ goto fail;
break;
default:
snmp_log(LOG_ERR, "bad type returned (%x)\n", vp->type);
- badtype = -1;
+ goto fail;
break;
}
DEBUGINDENTADD(-4);
+
+ if (NULL == vplast) {
+ pdu->variables = vp;
+ } else {
+ vplast->next_variable = vp;
+ }
+ vplast = vp;
+ vp = NULL;
}
- return badtype;
+ return 0;
+
+ fail:
+ DEBUGMSGTL(("recv", "error while parsing VarBindList\n"));
+ /** if we were parsing a var, remove it from the pdu and free it */
+ if (vp)
+ snmp_free_var(vp);
+
+ return -1;
}
/*

View File

@ -1,54 +0,0 @@
commit f9304c83f76202db0e684269ca1af32e43cd9db4
Author: Jan Safranek <jsafranek@users.sourceforge.net>
Date: Tue Feb 7 14:53:44 2012 +0100
CHANGES: PATCH 1633670: fixed snmpd crashing when an AgentX subagent disconnect in the middle of processing of a request.
I fixed also the memory leak reported in the tracker comments.
Index: net-snmp-5.7.2/agent/mibgroup/agentx/master.c
===================================================================
--- net-snmp-5.7.2.orig/agent/mibgroup/agentx/master.c
+++ net-snmp-5.7.2/agent/mibgroup/agentx/master.c
@@ -219,6 +219,9 @@ agentx_got_response(int operation,
if (!cache) {
DEBUGMSGTL(("agentx/master", "response too late on session %8p\n",
session));
+ /* response is too late, free the cache */
+ if (magic)
+ netsnmp_free_delegated_cache((netsnmp_delegated_cache*) magic);
return 0;
}
requests = cache->requests;
@@ -606,6 +609,8 @@ agentx_master_handler(netsnmp_mib_handle
result = snmp_async_send(ax_session, pdu, agentx_got_response, cb_data);
if (result == 0) {
snmp_free_pdu(pdu);
+ if (cb_data)
+ netsnmp_free_delegated_cache((netsnmp_delegated_cache*) cb_data);
}
return SNMP_ERR_NOERROR;
Index: net-snmp-5.7.2/agent/mibgroup/agentx/master_admin.c
===================================================================
--- net-snmp-5.7.2.orig/agent/mibgroup/agentx/master_admin.c
+++ net-snmp-5.7.2/agent/mibgroup/agentx/master_admin.c
@@ -133,11 +133,16 @@ close_agentx_session(netsnmp_session * s
* requests, so that the delegated request will be completed and
* further requests can be processed
*/
- netsnmp_remove_delegated_requests_for_session(session);
+ while (netsnmp_remove_delegated_requests_for_session(session)) {
+ DEBUGMSGTL(("agentx/master", "Continue removing delegated reqests\n"));
+ }
+
if (session->subsession != NULL) {
netsnmp_session *subsession = session->subsession;
for(; subsession; subsession = subsession->next) {
- netsnmp_remove_delegated_requests_for_session(subsession);
+ while (netsnmp_remove_delegated_requests_for_session(subsession)) {
+ DEBUGMSGTL(("agentx/master", "Continue removing delegated subsession reqests\n"));
+ }
}
}

View File

@ -1,21 +0,0 @@
diff -Nurp net-snmp-5.7.3-orig/agent/helpers/table.c net-snmp-5.7.3/agent/helpers/table.c
--- net-snmp-5.7.3-orig/agent/helpers/table.c 2014-12-08 21:23:22.000000000 +0100
+++ net-snmp-5.7.3/agent/helpers/table.c 2018-10-09 00:54:37.410522720 +0200
@@ -406,6 +406,8 @@ table_helper_handler(netsnmp_mib_handler
if (reqinfo->mode == MODE_GET)
table_helper_cleanup(reqinfo, request,
SNMP_NOSUCHOBJECT);
+ else
+ request->processed = 1; /* skip if next handler called */
continue;
}
@@ -483,6 +485,8 @@ table_helper_handler(netsnmp_mib_handler
#endif /* NETSNMP_NO_WRITE_SUPPORT */
table_helper_cleanup(reqinfo, request,
SNMP_NOSUCHOBJECT);
+ else
+ request->processed = 1; /* skip if next handler called */
continue;
}
/*

View File

@ -1,286 +0,0 @@
diff -Nurp net-snmp-5.7.3.orig/configure.d/config_os_functions net-snmp-5.7.3/configure.d/config_os_functions
--- net-snmp-5.7.3.orig/configure.d/config_os_functions 2014-12-08 21:23:22.000000000 +0100
+++ net-snmp-5.7.3/configure.d/config_os_functions 2015-07-16 10:32:15.159643068 +0200
@@ -31,11 +31,12 @@ AC_CHECK_FUNCS([lrand48 rand
[signal sigset ] )
# Library:
-AC_CHECK_FUNCS([closedir fgetc_unlocked flockfile ] dnl
- [fork funlockfile getipnodebyname ] dnl
- [gettimeofday if_nametoindex mkstemp ] dnl
- [opendir readdir regcomp ] dnl
- [setenv setitimer setlocale ] dnl
+AC_CHECK_FUNCS([closedir endnetgrent fgetc_unlocked ] dnl
+ [flockfile fork funlockfile ] dnl
+ [getipnodebyname getnetgrent gettimeofday ] dnl
+ [if_nametoindex mkstemp opendir ] dnl
+ [readdir regcomp setenv ] dnl
+ [setitimer setlocale setnetgrent ] dnl
[setsid snprintf strcasestr ] dnl
[strdup strerror strncasecmp ] dnl
[sysconf times vsnprintf ] )
diff -Nurp net-snmp-5.7.3.orig/man/snmpd.conf.5.def net-snmp-5.7.3/man/snmpd.conf.5.def
--- net-snmp-5.7.3.orig/man/snmpd.conf.5.def 2014-12-08 21:23:22.000000000 +0100
+++ net-snmp-5.7.3/man/snmpd.conf.5.def 2015-07-16 10:41:34.337850287 +0200
@@ -389,7 +389,14 @@ map an SNMPv1 or SNMPv2c community strin
a particular range of source addresses, or globally (\fI"default"\fR).
A restricted source can either be a specific hostname (or address), or
a subnet - represented as IP/MASK (e.g. 10.10.10.0/255.255.255.0), or
-IP/BITS (e.g. 10.10.10.0/24), or the IPv6 equivalents.
+IP/BITS (e.g. 10.10.10.0/24), or the IPv6 equivalents. It is also possible
+to reference a specific \fInetgroup\fR starting with an '@' character (e.g.
+@adminhosts). The \fInetgroup\fR lookup is running through the NSS (Name
+Services Switch) making it possible to define the group locally or via
+NIS/LDAP.
+.IP
+Note: The hostname DNS lookup and \fInetgroup\fR resolution is done only
+during snmpd start or reload.
.IP
The same community string can be specified in several separate directives
(presumably with different source tokens), and the first source/community
diff -Nurp net-snmp-5.7.3.orig/snmplib/transports/snmpUDPDomain.c net-snmp-5.7.3/snmplib/transports/snmpUDPDomain.c
--- net-snmp-5.7.3.orig/snmplib/transports/snmpUDPDomain.c 2014-12-08 21:23:22.000000000 +0100
+++ net-snmp-5.7.3/snmplib/transports/snmpUDPDomain.c 2015-07-16 10:32:15.160643078 +0200
@@ -88,6 +88,11 @@ void _netsnmp_udp_sockopt_set(int fd, in
int
netsnmp_sockaddr_in2(struct sockaddr_in *addr,
const char *inpeername, const char *default_target);
+static void
+netsnmp_udp_com2SecList_add(char *secName, size_t secNameLen,
+ char *contextName, size_t contextNameLen,
+ char *community, size_t communityLen,
+ struct in_addr network, struct in_addr mask);
/*
* Return a string representing the address in data, or else the "far end"
@@ -100,6 +105,59 @@ netsnmp_udp_fmtaddr(netsnmp_transport *t
return netsnmp_ipv4_fmtaddr("UDP", t, data, len);
}
+static int
+netsnmp_udp_resolve_source(char *source, struct in_addr *network,
+ struct in_addr *mask)
+{
+ /* Split the source/netmask parts */
+ char *strmask = strchr(source, '/');
+ if (strmask != NULL)
+ /* Mask given. */
+ *strmask++ = '\0';
+
+ /* Try interpreting as a dotted quad. */
+ if (inet_pton(AF_INET, source, network) == 0) {
+ /* Nope, wasn't a dotted quad. Must be a hostname. */
+ int ret = netsnmp_gethostbyname_v4(source, &(network->s_addr));
+ if (ret < 0) {
+ config_perror("cannot resolve source hostname");
+ return ret;
+ }
+ }
+
+ /* Now work out the mask. */
+ if (strmask == NULL || *strmask == '\0') {
+ /* No mask was given. Assume /32 */
+ mask->s_addr = (in_addr_t)(~0UL);
+ } else {
+ /* Try to interpret mask as a "number of 1 bits". */
+ char* cp;
+ long maskLen = strtol(strmask, &cp, 10);
+ if (*cp == '\0') {
+ if (0 < maskLen && maskLen <= 32)
+ mask->s_addr = htonl((in_addr_t)(~0UL << (32 - maskLen)));
+ else if (maskLen == 0)
+ mask->s_addr = 0;
+ else {
+ config_perror("bad mask length");
+ return -1;
+ }
+ }
+ /* Try to interpret mask as a dotted quad. */
+ else if (inet_pton(AF_INET, strmask, mask) == 0) {
+ config_perror("bad mask");
+ return -1;
+ }
+
+ /* Check that the network and mask are consistent. */
+ if (network->s_addr & ~mask->s_addr) {
+ config_perror("source/mask mismatch");
+ return -1;
+ }
+ }
+ return 0;
+}
+
#if defined(HAVE_IP_PKTINFO) || defined(HAVE_IP_RECVDSTADDR)
@@ -259,102 +317,85 @@ netsnmp_udp_parse_security(const char *t
if (strcmp(source, "default") == 0) {
network.s_addr = 0;
mask.s_addr = 0;
+ netsnmp_udp_com2SecList_add(secName, secNameLen, contextName,
+ contextNameLen, community, communityLen, network, mask);
} else {
- /* Split the source/netmask parts */
- char *strmask = strchr(source, '/');
- if (strmask != NULL)
- /* Mask given. */
- *strmask++ = '\0';
-
- /* Try interpreting as a dotted quad. */
- if (inet_pton(AF_INET, source, &network) == 0) {
- /* Nope, wasn't a dotted quad. Must be a hostname. */
- int ret = netsnmp_gethostbyname_v4(source, &network.s_addr);
- if (ret < 0) {
- config_perror("cannot resolve source hostname");
- return;
- }
- }
-
- /* Now work out the mask. */
- if (strmask == NULL || *strmask == '\0') {
- /* No mask was given. Assume /32 */
- mask.s_addr = (in_addr_t)(~0UL);
- } else {
- /* Try to interpret mask as a "number of 1 bits". */
- char* cp;
- long maskLen = strtol(strmask, &cp, 10);
- if (*cp == '\0') {
- if (0 < maskLen && maskLen <= 32)
- mask.s_addr = htonl((in_addr_t)(~0UL << (32 - maskLen)));
- else if (maskLen == 0)
- mask.s_addr = 0;
- else {
- config_perror("bad mask length");
- return;
+#if HAVE_ENDNETGRENT && HAVE_GETNETGRENT && HAVE_SETNETGRENT
+ /* Interpret as netgroup */
+ if (*source == '@') {
+ char *netgroup = source+1;
+ char *host, *user, *domain;
+ setnetgrent(netgroup);
+ while (getnetgrent(&host, &user, &domain)) {
+ if (netsnmp_udp_resolve_source(host, &network, &mask) == 0) {
+ netsnmp_udp_com2SecList_add(secName, secNameLen, contextName,
+ contextNameLen, community, communityLen, network, mask);
}
}
- /* Try to interpret mask as a dotted quad. */
- else if (inet_pton(AF_INET, strmask, &mask) == 0) {
- config_perror("bad mask");
- return;
- }
-
- /* Check that the network and mask are consistent. */
- if (network.s_addr & ~mask.s_addr) {
- config_perror("source/mask mismatch");
- return;
+ endnetgrent();
+ }
+ /* Without '@' it has to be an address or hostname */
+ else
+#endif
+ {
+ if (netsnmp_udp_resolve_source(source, &network, &mask) == 0) {
+ netsnmp_udp_com2SecList_add(secName, secNameLen, contextName,
+ contextNameLen, community, communityLen, network, mask);
}
}
}
+}
- {
- void* v = malloc(offsetof(com2SecEntry, community) + communityLen +
- secNameLen + contextNameLen);
-
- com2SecEntry* e = (com2SecEntry*)v;
- char* last = ((char*)v) + offsetof(com2SecEntry, community);
+static void
+netsnmp_udp_com2SecList_add(char *secName, size_t secNameLen, char *contextName,
+ size_t contextNameLen, char *community, size_t communityLen,
+ struct in_addr network, struct in_addr mask)
+{
+ void *v = malloc(offsetof(com2SecEntry, community) + communityLen +
+ secNameLen + contextNameLen);
- if (v == NULL) {
- config_perror("memory error");
- return;
- }
+ com2SecEntry* e = (com2SecEntry*)v;
+ char* last = ((char*)v) + offsetof(com2SecEntry, community);
- /*
- * Everything is okay. Copy the parameters to the structure allocated
- * above and add it to END of the list.
- */
+ if (v == NULL) {
+ config_perror("memory error");
+ return;
+ }
- {
- char buf1[INET_ADDRSTRLEN];
- char buf2[INET_ADDRSTRLEN];
- DEBUGMSGTL(("netsnmp_udp_parse_security",
- "<\"%s\", %s/%s> => \"%s\"\n", community,
- inet_ntop(AF_INET, &network, buf1, sizeof(buf1)),
- inet_ntop(AF_INET, &mask, buf2, sizeof(buf2)),
- secName));
- }
+ /*
+ * Everything is okay. Copy the parameters to the structure allocated
+ * above and add it to END of the list.
+ */
- memcpy(last, community, communityLen);
- last += communityLen;
- memcpy(last, secName, secNameLen);
- e->secName = last;
- last += secNameLen;
- if (contextNameLen) {
- memcpy(last, contextName, contextNameLen);
- e->contextName = last;
- } else
- e->contextName = last - 1;
- e->network = network.s_addr;
- e->mask = mask.s_addr;
- e->next = NULL;
-
- if (com2SecListLast != NULL) {
- com2SecListLast->next = e;
- com2SecListLast = e;
- } else {
- com2SecListLast = com2SecList = e;
- }
+ {
+ char buf1[INET_ADDRSTRLEN];
+ char buf2[INET_ADDRSTRLEN];
+ DEBUGMSGTL(("netsnmp_udp_parse_security",
+ "<\"%s\", %s/%s> => \"%s\"\n", community,
+ inet_ntop(AF_INET, &network, buf1, sizeof(buf1)),
+ inet_ntop(AF_INET, &mask, buf2, sizeof(buf2)),
+ secName));
+ }
+
+ memcpy(last, community, communityLen);
+ last += communityLen;
+ memcpy(last, secName, secNameLen);
+ e->secName = last;
+ last += secNameLen;
+ if (contextNameLen) {
+ memcpy(last, contextName, contextNameLen);
+ e->contextName = last;
+ } else
+ e->contextName = last - 1;
+ e->network = network.s_addr;
+ e->mask = mask.s_addr;
+ e->next = NULL;
+
+ if (com2SecListLast != NULL) {
+ com2SecListLast->next = e;
+ com2SecListLast = e;
+ } else {
+ com2SecListLast = com2SecList = e;
}
}

View File

@ -1,3 +0,0 @@
version https://git-lfs.github.com/spec/v1
oid sha256:12ef89613c7707dc96d13335f153c1921efc9d61d3708ef09f3fc4a7014fb4f0
size 6382428

View File

@ -0,0 +1,22 @@
diff -Nurp net-snmp-5.8-orig/perl/ASN/Makefile.PL net-snmp-5.8/perl/ASN/Makefile.PL
--- net-snmp-5.8-orig/perl/ASN/Makefile.PL 2018-10-10 09:45:14.875074783 +0000
+++ net-snmp-5.8/perl/ASN/Makefile.PL 2018-10-10 15:02:06.342732928 +0000
@@ -8,6 +8,7 @@ use Config;
use MakefileSubs;
my $lib_version;
+my %MakeParams = ();
# See lib/ExtUtils/MakeMaker.pm for details of how to influence
# the contents of the Makefile that is written.
diff -Nurp net-snmp-5.8-orig/perl/Makefile.PL net-snmp-5.8/perl/Makefile.PL
--- net-snmp-5.8-orig/perl/Makefile.PL 2018-10-10 09:45:14.875074783 +0000
+++ net-snmp-5.8/perl/Makefile.PL 2018-10-10 15:02:25.810916073 +0000
@@ -4,6 +4,7 @@ use ExtUtils::MakeMaker;
use Config;
require 5;
use MakefileSubs;
+my %MakeParams = ();
WriteMakefile(TopLevelInitMakeParams());

View File

@ -0,0 +1,578 @@
diff -Nurp net-snmp-5.8-orig/python/netsnmp/client.py net-snmp-5.8/python/netsnmp/client.py
--- net-snmp-5.8-orig/python/netsnmp/client.py 2018-10-10 09:45:14.951075479 +0000
+++ net-snmp-5.8/python/netsnmp/client.py 2018-10-10 19:40:47.130879742 +0000
@@ -34,12 +34,12 @@ def _parse_session_args(kargs):
'TheirHostname':'',
'TrustCert':''
}
- keys = kargs.keys()
+ keys = list(kargs.keys())
for key in keys:
- if sessArgs.has_key(key):
+ if key in sessArgs:
sessArgs[key] = kargs[key]
else:
- print >>stderr, "ERROR: unknown key", key
+ print("ERROR: unknown key", key, file=stderr)
return sessArgs
def STR(obj):
@@ -132,7 +132,7 @@ class Session(object):
sess_args = _parse_session_args(args)
- for k, v in sess_args.items():
+ for k, v in list(sess_args.items()):
self.__dict__[k] = v
diff -Nurp net-snmp-5.8-orig/python/netsnmp/client_intf.c net-snmp-5.8/python/netsnmp/client_intf.c
--- net-snmp-5.8-orig/python/netsnmp/client_intf.c 2018-10-10 09:45:14.951075479 +0000
+++ net-snmp-5.8/python/netsnmp/client_intf.c 2018-10-10 19:52:16.993235587 +0000
@@ -853,7 +853,11 @@ py_netsnmp_attr_string(PyObject *obj, ch
PyObject *attr = PyObject_GetAttrString(obj, attr_name);
if (attr) {
int retval;
+#if PY_MAJOR_VERSION >= 3
+ retval = PyBytes_AsStringAndSize(attr, val, len);
+#else
retval = PyString_AsStringAndSize(attr, val, len);
+#endif
Py_DECREF(attr);
return retval;
}
@@ -870,7 +874,11 @@ py_netsnmp_attr_long(PyObject *obj, char
if (obj && attr_name && PyObject_HasAttrString(obj, attr_name)) {
PyObject *attr = PyObject_GetAttrString(obj, attr_name);
if (attr) {
+#if PY_MAJOR_VERSION >= 3
+ val = PyLong_AsLong(attr);
+#else
val = PyInt_AsLong(attr);
+#endif
Py_DECREF(attr);
}
}
@@ -955,13 +963,22 @@ __py_netsnmp_update_session_errors(PyObj
py_netsnmp_attr_set_string(session, "ErrorStr", err_str, STRLEN(err_str));
+#if PY_MAJOR_VERSION >= 3
+ tmp_for_conversion = PyLong_FromLong(err_num);
+#else
tmp_for_conversion = PyInt_FromLong(err_num);
+#endif
+
if (!tmp_for_conversion)
return; /* nothing better to do? */
PyObject_SetAttrString(session, "ErrorNum", tmp_for_conversion);
Py_DECREF(tmp_for_conversion);
+#if PY_MAJOR_VERSION >= 3
+ tmp_for_conversion = PyLong_FromLong(err_ind);
+#else
tmp_for_conversion = PyInt_FromLong(err_ind);
+#endif
if (!tmp_for_conversion)
return; /* nothing better to do? */
PyObject_SetAttrString(session, "ErrorInd", tmp_for_conversion);
@@ -2490,13 +2507,28 @@ static PyMethodDef ClientMethods[] = {
{NULL, NULL, 0, NULL} /* Sentinel */
};
+#if PY_MAJOR_VERSION >= 3
+static struct PyModuleDef ClientModuleDef = {
+ PyModuleDef_HEAD_INIT,
+ "client_intf",
+ NULL,
+ -1,
+ ClientMethods,
+ NULL,
+ NULL,
+ NULL,
+ NULL
+};
+
+PyMODINIT_FUNC
+PyInit_client_intf(void)
+{
+ return PyModule_Create(&ClientModuleDef);
+}
+#else
PyMODINIT_FUNC
initclient_intf(void)
{
(void) Py_InitModule("client_intf", ClientMethods);
}
-
-
-
-
-
+#endif
diff -Nurp net-snmp-5.8-orig/python/netsnmp/tests/test.py net-snmp-5.8/python/netsnmp/tests/test.py
--- net-snmp-5.8-orig/python/netsnmp/tests/test.py 2018-10-10 09:45:14.951075479 +0000
+++ net-snmp-5.8/python/netsnmp/tests/test.py 2018-10-10 19:46:04.689790403 +0000
@@ -62,107 +62,107 @@ class BasicTests(unittest.TestCase):
self.assertEqual(var.iid, '')
def test_v1_get(self):
- print "\n"
- print "---v1 GET tests -------------------------------------\n"
+ print("\n")
+ print("---v1 GET tests -------------------------------------\n")
var = netsnmp.Varbind('.1.3.6.1.2.1.1.1', '0')
res = netsnmp.snmpget(var, **snmp_dest())
- print "v1 snmpget result: ", res, "\n"
+ print("v1 snmpget result: ", res, "\n")
self.assertEqual(len(res), 1)
- print "v1 get var: ", var.tag, var.iid, "=", var.val, '(', var.type, ')'
+ print("v1 get var: ", var.tag, var.iid, "=", var.val, '(', var.type, ')')
self.assertEqual(var.tag, 'sysDescr')
self.assertEqual(var.iid, '0')
self.assertEqual(var.val, res[0])
self.assertEqual(var.type, 'OCTETSTR')
def test_v1_getnext(self):
- print "\n"
- print "---v1 GETNEXT tests-------------------------------------\n"
+ print("\n")
+ print("---v1 GETNEXT tests-------------------------------------\n")
var = netsnmp.Varbind('.1.3.6.1.2.1.1.1', '0')
res = netsnmp.snmpgetnext(var, **snmp_dest())
- print "v1 snmpgetnext result: ", res, "\n"
+ print("v1 snmpgetnext result: ", res, "\n")
self.assertEqual(len(res), 1)
- print "v1 getnext var: ", var.tag, var.iid, "=", var.val, '(', var.type, ')'
+ print("v1 getnext var: ", var.tag, var.iid, "=", var.val, '(', var.type, ')')
self.assertTrue(var.tag is not None)
self.assertTrue(var.iid is not None)
self.assertTrue(var.val is not None)
self.assertTrue(var.type is not None)
def test_v1_set(self):
- print "\n"
- print "---v1 SET tests-------------------------------------\n"
+ print("\n")
+ print("---v1 SET tests-------------------------------------\n")
var = netsnmp.Varbind('sysLocation', '0', 'my new location')
res = netsnmp.snmpset(var, **snmp_dest())
- print "v1 snmpset result: ", res, "\n"
+ print("v1 snmpset result: ", res, "\n")
self.assertEqual(res, 1)
- print "v1 set var: ", var.tag, var.iid, "=", var.val, '(', var.type, ')'
+ print("v1 set var: ", var.tag, var.iid, "=", var.val, '(', var.type, ')')
self.assertEqual(var.tag, 'sysLocation')
self.assertEqual(var.iid, '0')
self.assertEqual(var.val, 'my new location')
self.assertTrue(var.type is None)
def test_v1_walk(self):
- print "\n"
- print "---v1 walk tests-------------------------------------\n"
+ print("\n")
+ print("---v1 walk tests-------------------------------------\n")
varlist = netsnmp.VarList(netsnmp.Varbind('system'))
- print "v1 varlist walk in: "
+ print("v1 varlist walk in: ")
for var in varlist:
- print " ", var.tag, var.iid, "=", var.val, '(', var.type, ')'
+ print(" ", var.tag, var.iid, "=", var.val, '(', var.type, ')')
res = netsnmp.snmpwalk(varlist, **snmp_dest())
- print "v1 snmpwalk result: ", res, "\n"
+ print("v1 snmpwalk result: ", res, "\n")
self.assertTrue(len(res) > 0)
for var in varlist:
- print var.tag, var.iid, "=", var.val, '(', var.type, ')'
+ print(var.tag, var.iid, "=", var.val, '(', var.type, ')')
def test_v1_walk_2(self):
- print "\n"
- print "---v1 walk 2-------------------------------------\n"
+ print("\n")
+ print("---v1 walk 2-------------------------------------\n")
- print "v1 varbind walk in: "
+ print("v1 varbind walk in: ")
var = netsnmp.Varbind('system')
self.assertEqual(var.tag, 'system')
self.assertEqual(var.iid, '')
self.assertEqual(var.val, None)
self.assertEqual(var.type, None)
res = netsnmp.snmpwalk(var, **snmp_dest())
- print "v1 snmpwalk result (should be = orig): ", res, "\n"
+ print("v1 snmpwalk result (should be = orig): ", res, "\n")
self.assertTrue(len(res) > 0)
- print var.tag, var.iid, "=", var.val, '(', var.type, ')'
+ print(var.tag, var.iid, "=", var.val, '(', var.type, ')')
self.assertEqual(var.tag, 'system')
self.assertEqual(var.iid, '')
self.assertEqual(var.val, None)
self.assertEqual(var.type, None)
def test_v1_mv_get(self):
- print "\n"
- print "---v1 multi-varbind test-------------------------------------\n"
+ print("\n")
+ print("---v1 multi-varbind test-------------------------------------\n")
sess = setup_v1()
varlist = netsnmp.VarList(netsnmp.Varbind('sysUpTime', 0),
netsnmp.Varbind('sysContact', 0),
netsnmp.Varbind('sysLocation', 0))
vals = sess.get(varlist)
- print "v1 sess.get result: ", vals, "\n"
+ print("v1 sess.get result: ", vals, "\n")
self.assertTrue(len(vals) > 0)
for var in varlist:
- print var.tag, var.iid, "=", var.val, '(', var.type, ')'
+ print(var.tag, var.iid, "=", var.val, '(', var.type, ')')
vals = sess.getnext(varlist)
- print "v1 sess.getnext result: ", vals, "\n"
+ print("v1 sess.getnext result: ", vals, "\n")
self.assertTrue(len(vals) > 0)
for var in varlist:
- print var.tag, var.iid, "=", var.val, '(', var.type, ')'
+ print(var.tag, var.iid, "=", var.val, '(', var.type, ')')
varlist = netsnmp.VarList(netsnmp.Varbind('sysUpTime'),
netsnmp.Varbind('sysORLastChange'),
@@ -171,71 +171,71 @@ class BasicTests(unittest.TestCase):
netsnmp.Varbind('sysORUpTime'))
vals = sess.getbulk(2, 8, varlist)
- print "v1 sess.getbulk result: ", vals, "\n"
+ print("v1 sess.getbulk result: ", vals, "\n")
self.assertEqual(vals, None) # GetBulk is not supported for v1
for var in varlist:
- print var.tag, var.iid, "=", var.val, '(', var.type, ')'
+ print(var.tag, var.iid, "=", var.val, '(', var.type, ')')
def test_v1_set_2(self):
- print "\n"
- print "---v1 set2-------------------------------------\n"
+ print("\n")
+ print("---v1 set2-------------------------------------\n")
sess = setup_v1()
varlist = netsnmp.VarList(
netsnmp.Varbind('sysLocation', '0', 'my newer location'))
res = sess.set(varlist)
- print "v1 sess.set result: ", res, "\n"
+ print("v1 sess.set result: ", res, "\n")
def test_v1_walk_3(self):
- print "\n"
- print "---v1 walk3-------------------------------------\n"
+ print("\n")
+ print("---v1 walk3-------------------------------------\n")
sess = setup_v1()
varlist = netsnmp.VarList(netsnmp.Varbind('system'))
vals = sess.walk(varlist)
- print "v1 sess.walk result: ", vals, "\n"
+ print("v1 sess.walk result: ", vals, "\n")
self.assertTrue(len(vals) > 0)
for var in varlist:
- print " ", var.tag, var.iid, "=", var.val, '(', var.type, ')'
+ print(" ", var.tag, var.iid, "=", var.val, '(', var.type, ')')
def test_v2c_get(self):
- print "\n"
- print "---v2c get-------------------------------------\n"
+ print("\n")
+ print("---v2c get-------------------------------------\n")
sess = setup_v2()
varlist = netsnmp.VarList(netsnmp.Varbind('sysUpTime', 0),
netsnmp.Varbind('sysContact', 0),
netsnmp.Varbind('sysLocation', 0))
vals = sess.get(varlist)
- print "v2 sess.get result: ", vals, "\n"
+ print("v2 sess.get result: ", vals, "\n")
self.assertEqual(len(vals), 3)
def test_v2c_getnext(self):
- print "\n"
- print "---v2c getnext-------------------------------------\n"
+ print("\n")
+ print("---v2c getnext-------------------------------------\n")
sess = setup_v2()
varlist = netsnmp.VarList(netsnmp.Varbind('sysUpTime', 0),
netsnmp.Varbind('sysContact', 0),
netsnmp.Varbind('sysLocation', 0))
for var in varlist:
- print var.tag, var.iid, "=", var.val, '(', var.type, ')'
- print "\n"
+ print(var.tag, var.iid, "=", var.val, '(', var.type, ')')
+ print("\n")
vals = sess.getnext(varlist)
- print "v2 sess.getnext result: ", vals, "\n"
+ print("v2 sess.getnext result: ", vals, "\n")
self.assertTrue(len(vals) > 0)
for var in varlist:
- print var.tag, var.iid, "=", var.val, '(', var.type, ')'
- print "\n"
+ print(var.tag, var.iid, "=", var.val, '(', var.type, ')')
+ print("\n")
def test_v2c_getbulk(self):
- print "\n"
- print "---v2c getbulk-------------------------------------\n"
+ print("\n")
+ print("---v2c getbulk-------------------------------------\n")
sess = setup_v2()
varlist = netsnmp.VarList(netsnmp.Varbind('sysUpTime'),
@@ -245,16 +245,16 @@ class BasicTests(unittest.TestCase):
netsnmp.Varbind('sysORUpTime'))
vals = sess.getbulk(2, 8, varlist)
- print "v2 sess.getbulk result: ", vals, "\n"
+ print("v2 sess.getbulk result: ", vals, "\n")
self.assertTrue(len(vals) > 0)
for var in varlist:
- print var.tag, var.iid, "=", var.val, '(', var.type, ')'
- print "\n"
+ print(var.tag, var.iid, "=", var.val, '(', var.type, ')')
+ print("\n")
def test_v2c_set(self):
- print "\n"
- print "---v2c set-------------------------------------\n"
+ print("\n")
+ print("---v2c set-------------------------------------\n")
sess = setup_v2()
@@ -262,54 +262,54 @@ class BasicTests(unittest.TestCase):
netsnmp.Varbind('sysLocation', '0', 'my even newer location'))
res = sess.set(varlist)
- print "v2 sess.set result: ", res, "\n"
+ print("v2 sess.set result: ", res, "\n")
self.assertEqual(res, 1)
def test_v2c_walk(self):
- print "\n"
- print "---v2c walk-------------------------------------\n"
+ print("\n")
+ print("---v2c walk-------------------------------------\n")
sess = setup_v2()
varlist = netsnmp.VarList(netsnmp.Varbind('system'))
vals = sess.walk(varlist)
- print "v2 sess.walk result: ", vals, "\n"
+ print("v2 sess.walk result: ", vals, "\n")
self.assertTrue(len(vals) > 0)
for var in varlist:
- print " ", var.tag, var.iid, "=", var.val, '(', var.type, ')'
+ print(" ", var.tag, var.iid, "=", var.val, '(', var.type, ')')
def test_v3_get(self):
- print "\n"
+ print("\n")
sess = setup_v3();
varlist = netsnmp.VarList(netsnmp.Varbind('sysUpTime', 0),
netsnmp.Varbind('sysContact', 0),
netsnmp.Varbind('sysLocation', 0))
- print "---v3 get-------------------------------------\n"
+ print("---v3 get-------------------------------------\n")
vals = sess.get(varlist)
- print "v3 sess.get result: ", vals, "\n"
+ print("v3 sess.get result: ", vals, "\n")
self.assertTrue(len(vals) > 0)
for var in varlist:
- print var.tag, var.iid, "=", var.val, '(', var.type, ')'
- print "\n"
+ print(var.tag, var.iid, "=", var.val, '(', var.type, ')')
+ print("\n")
def test_v3_getnext(self):
- print "\n"
- print "---v3 getnext-------------------------------------\n"
+ print("\n")
+ print("---v3 getnext-------------------------------------\n")
sess = setup_v3();
varlist = netsnmp.VarList(netsnmp.Varbind('sysUpTime', 0),
netsnmp.Varbind('sysContact', 0),
netsnmp.Varbind('sysLocation', 0))
vals = sess.getnext(varlist)
- print "v3 sess.getnext result: ", vals, "\n"
+ print("v3 sess.getnext result: ", vals, "\n")
self.assertTrue(len(vals) > 0)
for var in varlist:
- print var.tag, var.iid, "=", var.val, '(', var.type, ')'
- print "\n"
+ print(var.tag, var.iid, "=", var.val, '(', var.type, ')')
+ print("\n")
def test_v3_getbulk(self):
sess = setup_v3();
@@ -320,47 +320,47 @@ class BasicTests(unittest.TestCase):
netsnmp.Varbind('sysORUpTime'))
vals = sess.getbulk(2, 8, varlist)
- print "v3 sess.getbulk result: ", vals, "\n"
+ print("v3 sess.getbulk result: ", vals, "\n")
self.assertTrue(len(vals) > 0)
for var in varlist:
- print var.tag, var.iid, "=", var.val, '(', var.type, ')'
- print "\n"
+ print(var.tag, var.iid, "=", var.val, '(', var.type, ')')
+ print("\n")
def test_v3_set(self):
- print "\n"
- print "---v3 set-------------------------------------\n"
+ print("\n")
+ print("---v3 set-------------------------------------\n")
sess = setup_v3();
varlist = netsnmp.VarList(
netsnmp.Varbind('sysLocation', '0', 'my final destination'))
res = sess.set(varlist)
- print "v3 sess.set result: ", res, "\n"
+ print("v3 sess.set result: ", res, "\n")
self.assertEqual(res, 1)
def test_v3_walk(self):
- print "\n"
- print "---v3 walk-------------------------------------\n"
+ print("\n")
+ print("---v3 walk-------------------------------------\n")
sess = setup_v3();
varlist = netsnmp.VarList(netsnmp.Varbind('system'))
vals = sess.walk(varlist)
- print "v3 sess.walk result: ", vals, "\n"
+ print("v3 sess.walk result: ", vals, "\n")
self.assertTrue(len(vals) > 0)
for var in varlist:
- print " ", var.tag, var.iid, "=", var.val, '(', var.type, ')'
+ print(" ", var.tag, var.iid, "=", var.val, '(', var.type, ')')
class SetTests(unittest.TestCase):
"""SNMP set tests for the Net-SNMP Python interface"""
def testFuncs(self):
"""Test code"""
- print "\n-------------- SET Test Start ----------------------------\n"
+ print("\n-------------- SET Test Start ----------------------------\n")
var = netsnmp.Varbind('sysUpTime', '0')
res = netsnmp.snmpget(var, **snmp_dest())
- print "uptime = ", res[0]
+ print("uptime = ", res[0])
self.assertEqual(len(res), 1)
@@ -370,19 +370,19 @@ class SetTests(unittest.TestCase):
var = netsnmp.Varbind('sysUpTime', '0')
res = netsnmp.snmpget(var, **snmp_dest())
- print "uptime = ", res[0]
+ print("uptime = ", res[0])
self.assertEqual(len(res), 1)
var = netsnmp.Varbind('nsCacheEntry')
res = netsnmp.snmpgetnext(var, **snmp_dest())
- print "var = ", var.tag, var.iid, "=", var.val, '(', var.type, ')'
+ print("var = ", var.tag, var.iid, "=", var.val, '(', var.type, ')')
self.assertEqual(len(res), 1)
var.val = 65
res = netsnmp.snmpset(var, **snmp_dest())
self.assertEqual(res, 1)
res = netsnmp.snmpget(var, **snmp_dest())
- print "var = ", var.tag, var.iid, "=", var.val, '(', var.type, ')'
+ print("var = ", var.tag, var.iid, "=", var.val, '(', var.type, ')')
self.assertEqual(len(res), 1)
self.assertEqual(res[0], '65');
@@ -394,7 +394,7 @@ class SetTests(unittest.TestCase):
netsnmp.Varbind('.1.3.6.1.6.3.12.1.2.1.9.116.101.115.116', '', 4))
res = sess.set(varlist)
- print "res = ", res
+ print("res = ", res)
self.assertEqual(res, 1)
varlist = netsnmp.VarList(netsnmp.Varbind('snmpTargetAddrTDomain'),
@@ -414,15 +414,15 @@ class SetTests(unittest.TestCase):
self.assertEqual(varlist[2].val, '3')
for var in varlist:
- print var.tag, var.iid, "=", var.val, '(', var.type, ')'
- print "\n"
+ print(var.tag, var.iid, "=", var.val, '(', var.type, ')')
+ print("\n")
varlist = netsnmp.VarList(
netsnmp.Varbind('.1.3.6.1.6.3.12.1.2.1.9.116.101.115.116', '', 6))
res = sess.set(varlist)
- print "res = ", res
+ print("res = ", res)
self.assertEqual(res, 1)
varlist = netsnmp.VarList(netsnmp.Varbind('snmpTargetAddrTDomain'),
@@ -436,10 +436,10 @@ class SetTests(unittest.TestCase):
self.assertNotEqual(varlist[2].tag, 'snmpTargetAddrRowStatus')
for var in varlist:
- print var.tag, var.iid, "=", var.val, '(', var.type, ')'
- print "\n"
+ print(var.tag, var.iid, "=", var.val, '(', var.type, ')')
+ print("\n")
- print "\n-------------- SET Test End ----------------------------\n"
+ print("\n-------------- SET Test End ----------------------------\n")
if __name__ == '__main__':
diff -Nurp net-snmp-5.8-orig/python/setup.py net-snmp-5.8/python/setup.py
--- net-snmp-5.8-orig/python/setup.py 2018-10-10 09:45:14.951075479 +0000
+++ net-snmp-5.8/python/setup.py 2018-10-10 19:38:51.185817022 +0000
@@ -9,9 +9,9 @@ intree=0
args = sys.argv[:]
for arg in args:
- if string.find(arg,'--basedir=') == 0:
- basedir = string.split(arg,'=')[1]
- sys.argv.remove(arg)
+ if arg.find('--basedir=') == 0:
+ basedir = arg.split('=')[1]
+ sys.argv.remove(arg)
intree=1
if intree:

View File

@ -1,20 +1,20 @@
diff -uNr net-snmp-5.7.3.orig/agent/mibgroup/host/data_access/swinst_rpm.c net-snmp-5.7.3/agent/mibgroup/host/data_access/swinst_rpm.c
--- net-snmp-5.7.3.orig/agent/mibgroup/host/data_access/swinst_rpm.c 2014-12-08 21:23:22.000000000 +0100
+++ net-snmp-5.7.3/agent/mibgroup/host/data_access/swinst_rpm.c 2017-08-11 00:16:35.232470439 +0200
@@ -96,8 +96,7 @@
rpmdbMatchIterator mi;
Header h;
diff -Nurp net-snmp-5.8-orig/agent/mibgroup/host/data_access/swinst_rpm.c net-snmp-5.8/agent/mibgroup/host/data_access/swinst_rpm.c
--- net-snmp-5.8-orig/agent/mibgroup/host/data_access/swinst_rpm.c 2018-10-10 09:45:14.907075076 +0000
+++ net-snmp-5.8/agent/mibgroup/host/data_access/swinst_rpm.c 2018-10-10 19:31:51.161967195 +0000
@@ -101,8 +101,7 @@ netsnmp_swinst_arch_load( netsnmp_contai
const char *g;
rpmtd td_name, td_version, td_release, td_group, td_time;
#else
- char *n, *v, *r, *g;
- int32_t *t;
+ const char *n, *v, *r, *g;
#endif
time_t install_time;
size_t date_len;
int i = 1;
@@ -119,11 +118,11 @@
CONTAINER_INSERT(container, entry);
h = headerLink( h );
@@ -146,14 +145,14 @@ netsnmp_swinst_arch_load( netsnmp_contai
install_time = rpmtdGetNumber(td_time);
g = rpmtdGetString(td_group);
#else
- headerGetEntry( h, RPMTAG_NAME, NULL, (void**)&n, NULL);
- headerGetEntry( h, RPMTAG_VERSION, NULL, (void**)&v, NULL);
- headerGetEntry( h, RPMTAG_RELEASE, NULL, (void**)&r, NULL);
@ -25,21 +25,17 @@ diff -uNr net-snmp-5.7.3.orig/agent/mibgroup/host/data_access/swinst_rpm.c net-s
+ r = headerGetString( h, RPMTAG_RELEASE);
+ g = headerGetString( h, RPMTAG_GROUP);
+ install_time = headerGetNumber( h, RPMTAG_INSTALLTIME);
+
entry->swName_len = snprintf( entry->swName, sizeof(entry->swName),
"%s-%s-%s", n, v, r);
@@ -133,7 +132,6 @@
? 2 /* operatingSystem */
: 4; /* application */
- install_time = *t;
dt = date_n_time( &install_time, &date_len );
if (date_len != 8 && date_len != 11) {
snmp_log(LOG_ERR, "Bogus length from date_n_time for %s", entry->swName);
diff -uNr net-snmp-5.7.3.orig/agent/mibgroup/host/hr_swinst.c net-snmp-5.7.3/agent/mibgroup/host/hr_swinst.c
--- net-snmp-5.7.3.orig/agent/mibgroup/host/hr_swinst.c 2014-12-08 21:23:22.000000000 +0100
+++ net-snmp-5.7.3/agent/mibgroup/host/hr_swinst.c 2017-08-11 00:17:07.488544492 +0200
@@ -484,9 +484,9 @@
#endif
entry->swType = (g && NULL != strstr( g, "System Environment"))
? 2 /* operatingSystem */
diff -Nurp net-snmp-5.8-orig/agent/mibgroup/host/hr_swinst.c net-snmp-5.8/agent/mibgroup/host/hr_swinst.c
--- net-snmp-5.8-orig/agent/mibgroup/host/hr_swinst.c 2018-10-10 09:45:14.907075076 +0000
+++ net-snmp-5.8/agent/mibgroup/host/hr_swinst.c 2018-10-10 19:34:48.935596621 +0000
@@ -479,9 +479,9 @@ var_hrswinst(struct variable * vp,
}
#else
# ifdef HAVE_LIBRPM
@ -52,7 +48,7 @@ diff -uNr net-snmp-5.7.3.orig/agent/mibgroup/host/hr_swinst.c net-snmp-5.7.3/age
long_return = 2; /* operatingSystem */
else
long_return = 4; /* applcation */
@@ -503,9 +503,8 @@
@@ -498,9 +498,8 @@ var_hrswinst(struct variable * vp,
case HRSWINST_DATE:
{
#ifdef HAVE_LIBRPM
@ -64,16 +60,16 @@ diff -uNr net-snmp-5.7.3.orig/agent/mibgroup/host/hr_swinst.c net-snmp-5.7.3/age
ret = date_n_time(&installTime, var_len);
} else {
ret = date_n_time(NULL, var_len);
@@ -665,7 +664,7 @@
@@ -660,7 +659,7 @@ Save_HR_SW_info(int ix)
if (1 <= ix && ix <= swi->swi_nrec && ix != swi->swi_prevx) {
int offset;
Header h;
- char *n, *v, *r;
+ const char *n, *v, *r;
+ const char *n, *v, *r;
offset = swi->swi_recs[ix - 1];
@@ -690,11 +689,9 @@
@@ -685,11 +684,9 @@ Save_HR_SW_info(int ix)
swi->swi_h = h;
swi->swi_prevx = ix;

View File

@ -1,7 +1,6 @@
Index: net-snmp-5.7.2/net-snmp-config.in
===================================================================
--- net-snmp-5.7.2.orig/net-snmp-config.in
+++ net-snmp-5.7.2/net-snmp-config.in
diff -Nurp net-snmp-5.8-orig/net-snmp-config.in net-snmp-5.8/net-snmp-config.in
--- net-snmp-5.8-orig/net-snmp-config.in 2018-10-10 09:45:14.947075442 +0000
+++ net-snmp-5.8/net-snmp-config.in 2018-10-10 09:48:04.792631474 +0000
@@ -41,6 +41,14 @@ count()
echo $#
}
@ -17,7 +16,7 @@ Index: net-snmp-5.7.2/net-snmp-config.in
prefix=@prefix@
exec_prefix=@exec_prefix@
includedir=@includedir@
@@ -138,9 +146,11 @@ else
@@ -140,9 +148,11 @@ else
;;
#################################################### compile
--base-cflags)
@ -29,7 +28,7 @@ Index: net-snmp-5.7.2/net-snmp-config.in
echo @CFLAGS@ @DEVFLAGS@ @CPPFLAGS@ -I. -I${NSC_INCLUDEDIR}
;;
--srcdir)
@@ -151,6 +161,7 @@ else
@@ -153,6 +163,7 @@ else
echo $NSC_LIBDIR
;;
--ldflags|--ld*)
@ -37,7 +36,7 @@ Index: net-snmp-5.7.2/net-snmp-config.in
echo $NSC_LDFLAGS
;;
--build-lib-dirs)
@@ -188,29 +199,37 @@ else
@@ -190,29 +201,37 @@ else
#################################################### client lib
--libs)
# use this one == --netsnmp-libs + --external-libs
@ -75,7 +74,7 @@ Index: net-snmp-5.7.2/net-snmp-config.in
echo $NSC_LDFLAGS $NSC_LMIBLIBS $NSC_LAGENTLIBS $NSC_LNETSNMPLIBS $NSC_LIBS
;;
####################################################
@@ -236,6 +255,7 @@ else
@@ -238,6 +257,7 @@ else
####################################################
--compile-subagent)

View File

@ -0,0 +1,41 @@
diff -Nurp net-snmp-5.8-orig/configure.d/config_os_functions net-snmp-5.8/configure.d/config_os_functions
--- net-snmp-5.8-orig/configure.d/config_os_functions 2018-10-10 09:45:14.899075003 +0000
+++ net-snmp-5.8/configure.d/config_os_functions 2018-10-10 10:06:55.326988809 +0000
@@ -37,11 +37,12 @@ AC_CHECK_FUNCS([rand random srand sran
# Library:
AC_CHECK_FUNCS([asprintf ] dnl
- [closedir fgetc_unlocked flockfile ] dnl
- [fork funlockfile getipnodebyname ] dnl
- [gettimeofday if_nametoindex mkstemp ] dnl
- [opendir readdir regcomp ] dnl
- [setenv setitimer setlocale ] dnl
+ [closedir endnetgrent fgetc_unlocked ] dnl
+ [flockfile fork funlockfile ] dnl
+ [getipnodebyname getnetgrent gettimeofday ] dnl
+ [if_nametoindex mkstemp opendir ] dnl
+ [readdir regcomp setenv ] dnl
+ [setitimer setlocale setnetgrent ] dnl
[setsid snprintf strcasestr ] dnl
[strdup strerror strncasecmp ] dnl
[sysconf times vsnprintf ] )
diff -Nurp net-snmp-5.8-orig/man/snmpd.conf.5.def net-snmp-5.8/man/snmpd.conf.5.def
--- net-snmp-5.8-orig/man/snmpd.conf.5.def 2018-10-10 09:45:14.951075479 +0000
+++ net-snmp-5.8/man/snmpd.conf.5.def 2018-10-10 10:10:44.057084311 +0000
@@ -390,7 +390,15 @@ map an SNMPv1 or SNMPv2c community strin
a particular range of source addresses, or globally (\fI"default"\fR).
A restricted source can either be a specific hostname (or address), or
a subnet - represented as IP/MASK (e.g. 10.10.10.0/255.255.255.0), or
-IP/BITS (e.g. 10.10.10.0/24), or the IPv6 equivalents.
+IP/BITS (e.g. 10.10.10.0/24), or the IPv6 equivalents. It is also possible
+to reference a specific \fInetgroup\fR starting with an '@' character (e.g.
+@adminhosts). The \fInetgroup\fR lookup is running through the NSS (Name
+Services Switch) making it possible to define the group locally or via
+NIS/LDAP.
+.IP
+Note: The hostname DNS lookup and \fInetgroup\fR resolution is done only
+during snmpd start or reload.
+.IP
A restriction preceded by an exclamation mark (!) denies access from
that address or subnet, e.g., !10.10.10.0/24 denies requests from
that sources in that subnet. Deny restrictions must be before

View File

@ -1,8 +1,7 @@
Index: net-snmp-5.7.2/agent/Makefile.in
===================================================================
--- net-snmp-5.7.2.orig/agent/Makefile.in
+++ net-snmp-5.7.2/agent/Makefile.in
@@ -294,7 +294,7 @@ getmibstat.o: mibgroup/kernel_sunos5.c
diff -Nurp net-snmp-5.8-orig/agent/Makefile.in net-snmp-5.8/agent/Makefile.in
--- net-snmp-5.8-orig/agent/Makefile.in 2018-10-10 20:12:33.288508471 +0000
+++ net-snmp-5.8/agent/Makefile.in 2018-10-10 20:12:13.236322553 +0000
@@ -297,7 +297,7 @@ getmibstat.o: mibgroup/kernel_sunos5.c
$(CC) $(CFLAGS) -o $@ -D_GETMIBSTAT_TEST -DDODEBUG -c $?
snmpd$(EXEEXT): ${LAGENTOBJS} $(USELIBS) $(AGENTLIB) $(HELPERLIB) $(MIBLIB) $(LIBTARG)
@ -11,11 +10,10 @@ Index: net-snmp-5.7.2/agent/Makefile.in
libnetsnmpagent.$(LIB_EXTENSION)$(LIB_VERSION): ${LLIBAGENTOBJS} $(USELIBS)
$(LIB_LD_CMD) $(AGENTLIB) ${LLIBAGENTOBJS} $(USELIBS) ${LAGENTLIBS} @LD_NO_UNDEFINED@ $(LDFLAGS) $(PERLLDOPTS_FOR_LIBS) $(LIB_LD_LIBS) @AGENTLIBS@
Index: net-snmp-5.7.2/apps/Makefile.in
===================================================================
--- net-snmp-5.7.2.orig/apps/Makefile.in
+++ net-snmp-5.7.2/apps/Makefile.in
@@ -170,7 +170,7 @@ snmptest$(EXEEXT): snmptest.$(OSUFFIX
diff -Nurp net-snmp-5.8-orig/apps/Makefile.in net-snmp-5.8/apps/Makefile.in
--- net-snmp-5.8-orig/apps/Makefile.in 2018-10-10 20:10:23.983309589 +0000
+++ net-snmp-5.8/apps/Makefile.in 2018-10-10 20:11:50.172108708 +0000
@@ -183,7 +183,7 @@ snmptest$(EXEEXT): snmptest.$(OSUFFIX
$(LINK) ${CFLAGS} -o $@ snmptest.$(OSUFFIX) ${LDFLAGS} ${LIBS}
snmptrapd$(EXEEXT): $(TRAPD_OBJECTS) $(USETRAPLIBS) $(INSTALLLIBS)

View File

@ -1,6 +1,6 @@
diff -Nurp net-snmp-5.7.3.orig/apps/snmpstatus.c net-snmp-5.7.3/apps/snmpstatus.c
--- net-snmp-5.7.3.orig/apps/snmpstatus.c 2015-07-14 22:06:08.938851077 +0200
+++ net-snmp-5.7.3/apps/snmpstatus.c 2015-07-14 22:06:23.905980889 +0200
diff -Nurp net-snmp-5.8-orig/apps/snmpstatus.c net-snmp-5.8/apps/snmpstatus.c
--- net-snmp-5.8-orig/apps/snmpstatus.c 2018-10-10 09:45:14.955075516 +0000
+++ net-snmp-5.8/apps/snmpstatus.c 2018-10-10 10:15:16.131576910 +0000
@@ -96,6 +96,15 @@ size_t length_ipOutRequests =
#define NETSNMP_DS_APP_DONT_FIX_PDUS 0
@ -53,14 +53,14 @@ diff -Nurp net-snmp-5.7.3.orig/apps/snmpstatus.c net-snmp-5.7.3/apps/snmpstatus.
}
@@ -152,7 +183,7 @@ main(int argc, char *argv[])
@@ -154,7 +185,7 @@ main(int argc, char *argv[])
/*
* get the common command line arguments
*/
- switch (snmp_parse_args(argc, argv, &session, "C:", &optProc)) {
+ switch (snmp_parse_args(argc, argv, &session, "C:S:", &optProc)) {
case NETSNMP_PARSE_ARGS_ERROR:
exit(1);
goto out;
case NETSNMP_PARSE_ARGS_SUCCESS_EXIT:
@@ -185,8 +216,10 @@ main(int argc, char *argv[])
pdu = snmp_pdu_create(SNMP_MSG_GET);
@ -75,7 +75,7 @@ diff -Nurp net-snmp-5.7.3.orig/apps/snmpstatus.c net-snmp-5.7.3/apps/snmpstatus.
/*
* do the request
@@ -278,6 +311,10 @@ main(int argc, char *argv[])
@@ -279,6 +312,10 @@ main(int argc, char *argv[])
if (response)
snmp_free_pdu(response);
@ -86,7 +86,7 @@ diff -Nurp net-snmp-5.7.3.orig/apps/snmpstatus.c net-snmp-5.7.3/apps/snmpstatus.
/*
* create PDU for GET request and add object names to request
*/
@@ -375,11 +412,11 @@ main(int argc, char *argv[])
@@ -386,11 +423,11 @@ main(int argc, char *argv[])
}
printf("Interfaces: %d, Recv/Trans packets: %d/%d | IP: %d/%d\n",
interfaces, ipackets, opackets, ipin, ipout);
@ -98,11 +98,11 @@ diff -Nurp net-snmp-5.7.3.orig/apps/snmpstatus.c net-snmp-5.7.3/apps/snmpstatus.
-
+ done:
snmp_close(ss);
SOCK_CLEANUP;
return exitval;
diff -Nurp net-snmp-5.7.3.orig/man/snmpstatus.1.def net-snmp-5.7.3/man/snmpstatus.1.def
--- net-snmp-5.7.3.orig/man/snmpstatus.1.def 2015-07-14 22:06:08.838850210 +0200
+++ net-snmp-5.7.3/man/snmpstatus.1.def 2015-07-14 22:13:19.891588792 +0200
out:
diff -Nurp net-snmp-5.8-orig/man/snmpstatus.1.def net-snmp-5.8/man/snmpstatus.1.def
--- net-snmp-5.8-orig/man/snmpstatus.1.def 2018-10-10 09:45:14.951075479 +0000
+++ net-snmp-5.8/man/snmpstatus.1.def 2018-10-10 10:15:16.131576910 +0000
@@ -32,7 +32,7 @@
snmpstatus - retrieves a fixed set of management information from a network entity
.SH SYNOPSIS

3
net-snmp-5.8.tar.gz Normal file
View File

@ -0,0 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:b2fc3500840ebe532734c4786b0da4ef0a5f67e51ef4c86b3345d697e4976adf
size 6591680

View File

@ -1,505 +0,0 @@
Index: net-snmp-5.7.3/python/setup.py
===================================================================
--- net-snmp-5.7.3.orig/python/setup.py
+++ net-snmp-5.7.3/python/setup.py
@@ -9,9 +9,9 @@ intree=0
args = sys.argv[:]
for arg in args:
- if string.find(arg,'--basedir=') == 0:
- basedir = string.split(arg,'=')[1]
- sys.argv.remove(arg)
+ if arg.find('--basedir=') == 0:
+ basedir = arg.split('=')[1]
+ sys.argv.remove(arg)
intree=1
if intree:
Index: net-snmp-5.7.3/python/netsnmp/client.py
===================================================================
--- net-snmp-5.7.3.orig/python/netsnmp/client.py
+++ net-snmp-5.7.3/python/netsnmp/client.py
@@ -1,3 +1,4 @@
+from __future__ import print_function
import client_intf
import string
import re
@@ -35,12 +36,12 @@ def _parse_session_args(kargs):
'TheirHostname':'',
'TrustCert':''
}
- keys = kargs.keys()
+ keys = list(kargs.keys())
for key in keys:
- if sessArgs.has_key(key):
+ if key in sessArgs:
sessArgs[key] = kargs[key]
else:
- print >>stderr, "ERROR: unknown key", key
+ print("ERROR: unknown key", key, file=stderr)
return sessArgs
def STR(obj):
@@ -127,7 +128,7 @@ class Session(object):
sess_args = _parse_session_args(args)
- for k,v in sess_args.items():
+ for k,v in list(sess_args.items()):
self.__dict__[k] = v
Index: net-snmp-5.7.3/python/netsnmp/tests/test.py
===================================================================
--- net-snmp-5.7.3.orig/python/netsnmp/tests/test.py
+++ net-snmp-5.7.3/python/netsnmp/tests/test.py
@@ -8,7 +8,7 @@ import time
class BasicTests(unittest.TestCase):
def testFuncs(self):
- print ""
+ print("")
var = netsnmp.Varbind('sysDescr.0')
var = netsnmp.Varbind('sysDescr','0')
var = netsnmp.Varbind(
@@ -19,67 +19,67 @@ class BasicTests(unittest.TestCase):
var = netsnmp.Varbind('.1.3.6.1.2.1.1.1','0')
- print "---v1 GET tests -------------------------------------\n"
+ print("---v1 GET tests -------------------------------------\n")
res = netsnmp.snmpget(var,
Version = 1,
DestHost='localhost',
Community='public')
- print "v1 snmpget result: ", res, "\n"
+ print("v1 snmpget result: ", res, "\n")
- print "v1 get var: ", var.tag, var.iid, "=", var.val, '(',var.type,')'
+ print("v1 get var: ", var.tag, var.iid, "=", var.val, '(',var.type,')')
- print "---v1 GETNEXT tests-------------------------------------\n"
+ print("---v1 GETNEXT tests-------------------------------------\n")
res = netsnmp.snmpgetnext(var,
Version = 1,
DestHost='localhost',
Community='public')
- print "v1 snmpgetnext result: ", res, "\n"
+ print("v1 snmpgetnext result: ", res, "\n")
- print "v1 getnext var: ", var.tag, var.iid, "=", var.val, '(',var.type,')'
+ print("v1 getnext var: ", var.tag, var.iid, "=", var.val, '(',var.type,')')
- print "---v1 SET tests-------------------------------------\n"
+ print("---v1 SET tests-------------------------------------\n")
var = netsnmp.Varbind('sysLocation','0', 'my new location')
res = netsnmp.snmpset(var,
Version = 1,
DestHost='localhost',
Community='public')
- print "v1 snmpset result: ", res, "\n"
+ print("v1 snmpset result: ", res, "\n")
- print "v1 set var: ", var.tag, var.iid, "=", var.val, '(',var.type,')'
+ print("v1 set var: ", var.tag, var.iid, "=", var.val, '(',var.type,')')
- print "---v1 walk tests-------------------------------------\n"
+ print("---v1 walk tests-------------------------------------\n")
vars = netsnmp.VarList(netsnmp.Varbind('system'))
- print "v1 varlist walk in: "
+ print("v1 varlist walk in: ")
for var in vars:
- print " ",var.tag, var.iid, "=", var.val, '(',var.type,')'
+ print(" ",var.tag, var.iid, "=", var.val, '(',var.type,')')
res = netsnmp.snmpwalk(vars,
Version = 1,
DestHost='localhost',
Community='public')
- print "v1 snmpwalk result: ", res, "\n"
+ print("v1 snmpwalk result: ", res, "\n")
for var in vars:
- print var.tag, var.iid, "=", var.val, '(',var.type,')'
+ print(var.tag, var.iid, "=", var.val, '(',var.type,')')
- print "---v1 walk 2-------------------------------------\n"
+ print("---v1 walk 2-------------------------------------\n")
- print "v1 varbind walk in: "
+ print("v1 varbind walk in: ")
var = netsnmp.Varbind('system')
res = netsnmp.snmpwalk(var,
Version = 1,
DestHost='localhost',
Community='public')
- print "v1 snmpwalk result (should be = orig): ", res, "\n"
+ print("v1 snmpwalk result (should be = orig): ", res, "\n")
- print var.tag, var.iid, "=", var.val, '(',var.type,')'
+ print(var.tag, var.iid, "=", var.val, '(',var.type,')')
- print "---v1 multi-varbind test-------------------------------------\n"
+ print("---v1 multi-varbind test-------------------------------------\n")
sess = netsnmp.Session(Version=1,
DestHost='localhost',
Community='public')
@@ -88,16 +88,16 @@ class BasicTests(unittest.TestCase):
netsnmp.Varbind('sysContact', 0),
netsnmp.Varbind('sysLocation', 0))
vals = sess.get(vars)
- print "v1 sess.get result: ", vals, "\n"
+ print("v1 sess.get result: ", vals, "\n")
for var in vars:
- print var.tag, var.iid, "=", var.val, '(',var.type,')'
+ print(var.tag, var.iid, "=", var.val, '(',var.type,')')
vals = sess.getnext(vars)
- print "v1 sess.getnext result: ", vals, "\n"
+ print("v1 sess.getnext result: ", vals, "\n")
for var in vars:
- print var.tag, var.iid, "=", var.val, '(',var.type,')'
+ print(var.tag, var.iid, "=", var.val, '(',var.type,')')
vars = netsnmp.VarList(netsnmp.Varbind('sysUpTime'),
netsnmp.Varbind('sysORLastChange'),
@@ -106,28 +106,28 @@ class BasicTests(unittest.TestCase):
netsnmp.Varbind('sysORUpTime'))
vals = sess.getbulk(2, 8, vars)
- print "v1 sess.getbulk result: ", vals, "\n"
+ print("v1 sess.getbulk result: ", vals, "\n")
for var in vars:
- print var.tag, var.iid, "=", var.val, '(',var.type,')'
+ print(var.tag, var.iid, "=", var.val, '(',var.type,')')
- print "---v1 set2-------------------------------------\n"
+ print("---v1 set2-------------------------------------\n")
vars = netsnmp.VarList(
netsnmp.Varbind('sysLocation', '0', 'my newer location'))
res = sess.set(vars)
- print "v1 sess.set result: ", res, "\n"
+ print("v1 sess.set result: ", res, "\n")
- print "---v1 walk3-------------------------------------\n"
+ print("---v1 walk3-------------------------------------\n")
vars = netsnmp.VarList(netsnmp.Varbind('system'))
vals = sess.walk(vars)
- print "v1 sess.walk result: ", vals, "\n"
+ print("v1 sess.walk result: ", vals, "\n")
for var in vars:
- print " ",var.tag, var.iid, "=", var.val, '(',var.type,')'
+ print(" ",var.tag, var.iid, "=", var.val, '(',var.type,')')
- print "---v2c get-------------------------------------\n"
+ print("---v2c get-------------------------------------\n")
sess = netsnmp.Session(Version=2,
DestHost='localhost',
@@ -140,22 +140,22 @@ class BasicTests(unittest.TestCase):
netsnmp.Varbind('sysContact', 0),
netsnmp.Varbind('sysLocation', 0))
vals = sess.get(vars)
- print "v2 sess.get result: ", vals, "\n"
+ print("v2 sess.get result: ", vals, "\n")
- print "---v2c getnext-------------------------------------\n"
+ print("---v2c getnext-------------------------------------\n")
for var in vars:
- print var.tag, var.iid, "=", var.val, '(',var.type,')'
- print "\n"
+ print(var.tag, var.iid, "=", var.val, '(',var.type,')')
+ print("\n")
vals = sess.getnext(vars)
- print "v2 sess.getnext result: ", vals, "\n"
+ print("v2 sess.getnext result: ", vals, "\n")
for var in vars:
- print var.tag, var.iid, "=", var.val, '(',var.type,')'
- print "\n"
+ print(var.tag, var.iid, "=", var.val, '(',var.type,')')
+ print("\n")
- print "---v2c getbulk-------------------------------------\n"
+ print("---v2c getbulk-------------------------------------\n")
vars = netsnmp.VarList(netsnmp.Varbind('sysUpTime'),
netsnmp.Varbind('sysORLastChange'),
@@ -164,30 +164,30 @@ class BasicTests(unittest.TestCase):
netsnmp.Varbind('sysORUpTime'))
vals = sess.getbulk(2, 8, vars)
- print "v2 sess.getbulk result: ", vals, "\n"
+ print("v2 sess.getbulk result: ", vals, "\n")
for var in vars:
- print var.tag, var.iid, "=", var.val, '(',var.type,')'
- print "\n"
+ print(var.tag, var.iid, "=", var.val, '(',var.type,')')
+ print("\n")
- print "---v2c set-------------------------------------\n"
+ print("---v2c set-------------------------------------\n")
vars = netsnmp.VarList(
netsnmp.Varbind('sysLocation','0','my even newer location'))
res = sess.set(vars)
- print "v2 sess.set result: ", res, "\n"
+ print("v2 sess.set result: ", res, "\n")
- print "---v2c walk-------------------------------------\n"
+ print("---v2c walk-------------------------------------\n")
vars = netsnmp.VarList(netsnmp.Varbind('system'))
vals = sess.walk(vars)
- print "v2 sess.walk result: ", vals, "\n"
+ print("v2 sess.walk result: ", vals, "\n")
for var in vars:
- print " ",var.tag, var.iid, "=", var.val, '(',var.type,')'
+ print(" ",var.tag, var.iid, "=", var.val, '(',var.type,')')
- print "---v3 setup-------------------------------------\n"
+ print("---v3 setup-------------------------------------\n")
sess = netsnmp.Session(Version=3,
DestHost='localhost',
SecLevel='authPriv',
@@ -200,22 +200,22 @@ class BasicTests(unittest.TestCase):
vars = netsnmp.VarList(netsnmp.Varbind('sysUpTime', 0),
netsnmp.Varbind('sysContact', 0),
netsnmp.Varbind('sysLocation', 0))
- print "---v3 get-------------------------------------\n"
+ print("---v3 get-------------------------------------\n")
vals = sess.get(vars)
- print "v3 sess.get result: ", vals, "\n"
+ print("v3 sess.get result: ", vals, "\n")
for var in vars:
- print var.tag, var.iid, "=", var.val, '(',var.type,')'
- print "\n"
+ print(var.tag, var.iid, "=", var.val, '(',var.type,')')
+ print("\n")
- print "---v3 getnext-------------------------------------\n"
+ print("---v3 getnext-------------------------------------\n")
vals = sess.getnext(vars)
- print "v3 sess.getnext result: ", vals, "\n"
+ print("v3 sess.getnext result: ", vals, "\n")
for var in vars:
- print var.tag, var.iid, "=", var.val, '(',var.type,')'
- print "\n"
+ print(var.tag, var.iid, "=", var.val, '(',var.type,')')
+ print("\n")
vars = netsnmp.VarList(netsnmp.Varbind('sysUpTime'),
netsnmp.Varbind('sysORLastChange'),
@@ -224,37 +224,37 @@ class BasicTests(unittest.TestCase):
netsnmp.Varbind('sysORUpTime'))
vals = sess.getbulk(2, 8, vars)
- print "v3 sess.getbulk result: ", vals, "\n"
+ print("v3 sess.getbulk result: ", vals, "\n")
for var in vars:
- print var.tag, var.iid, "=", var.val, '(',var.type,')'
- print "\n"
+ print(var.tag, var.iid, "=", var.val, '(',var.type,')')
+ print("\n")
- print "---v3 set-------------------------------------\n"
+ print("---v3 set-------------------------------------\n")
vars = netsnmp.VarList(
netsnmp.Varbind('sysLocation','0', 'my final destination'))
res = sess.set(vars)
- print "v3 sess.set result: ", res, "\n"
+ print("v3 sess.set result: ", res, "\n")
- print "---v3 walk-------------------------------------\n"
+ print("---v3 walk-------------------------------------\n")
vars = netsnmp.VarList(netsnmp.Varbind('system'))
vals = sess.walk(vars)
- print "v3 sess.walk result: ", vals, "\n"
+ print("v3 sess.walk result: ", vals, "\n")
for var in vars:
- print " ",var.tag, var.iid, "=", var.val, '(',var.type,')'
+ print(" ",var.tag, var.iid, "=", var.val, '(',var.type,')')
class SetTests(unittest.TestCase):
def testFuncs(self):
- print "\n-------------- SET Test Start ----------------------------\n"
+ print("\n-------------- SET Test Start ----------------------------\n")
var = netsnmp.Varbind('sysUpTime','0')
res = netsnmp.snmpget(var, Version = 1, DestHost='localhost',
Community='public')
- print "uptime = ", res[0]
+ print("uptime = ", res[0])
var = netsnmp.Varbind('versionRestartAgent','0', 1)
@@ -264,19 +264,19 @@ class SetTests(unittest.TestCase):
var = netsnmp.Varbind('sysUpTime','0')
res = netsnmp.snmpget(var, Version = 1, DestHost='localhost',
Community='public')
- print "uptime = ", res[0]
+ print("uptime = ", res[0])
var = netsnmp.Varbind('nsCacheEntry')
res = netsnmp.snmpgetnext(var, Version = 1, DestHost='localhost',
Community='public')
- print "var = ", var.tag, var.iid, "=", var.val, '(',var.type,')'
+ print("var = ", var.tag, var.iid, "=", var.val, '(',var.type,')')
var.val = 65
res = netsnmp.snmpset(var, Version = 1, DestHost='localhost',
Community='public')
res = netsnmp.snmpget(var, Version = 1, DestHost='localhost',
Community='public')
- print "var = ", var.tag, var.iid, "=", var.val, '(',var.type,')'
+ print("var = ", var.tag, var.iid, "=", var.val, '(',var.type,')')
sess = netsnmp.Session(Version = 1, DestHost='localhost',
Community='public')
@@ -286,7 +286,7 @@ class SetTests(unittest.TestCase):
netsnmp.Varbind('.1.3.6.1.6.3.12.1.2.1.9.116.101.115.116','', 4))
res = sess.set(vars)
- print "res = ", res
+ print("res = ", res)
vars = netsnmp.VarList(netsnmp.Varbind('snmpTargetAddrTDomain'),
netsnmp.Varbind('snmpTargetAddrTAddress'),
@@ -295,14 +295,14 @@ class SetTests(unittest.TestCase):
res = sess.getnext(vars)
for var in vars:
- print var.tag, var.iid, "=", var.val, '(',var.type,')'
- print "\n"
+ print(var.tag, var.iid, "=", var.val, '(',var.type,')')
+ print("\n")
vars = netsnmp.VarList(netsnmp.Varbind('.1.3.6.1.6.3.12.1.2.1.9.116.101.115.116','', 6))
res = sess.set(vars)
- print "res = ", res
+ print("res = ", res)
vars = netsnmp.VarList(netsnmp.Varbind('snmpTargetAddrTDomain'),
netsnmp.Varbind('snmpTargetAddrTAddress'),
@@ -311,10 +311,10 @@ class SetTests(unittest.TestCase):
res = sess.getnext(vars)
for var in vars:
- print var.tag, var.iid, "=", var.val, '(',var.type,')'
- print "\n"
+ print(var.tag, var.iid, "=", var.val, '(',var.type,')')
+ print("\n")
- print "\n-------------- SET Test End ----------------------------\n"
+ print("\n-------------- SET Test End ----------------------------\n")
if __name__=='__main__':
Index: net-snmp-5.7.3/python/netsnmp/client_intf.c
===================================================================
--- net-snmp-5.7.3.orig/python/netsnmp/client_intf.c
+++ net-snmp-5.7.3/python/netsnmp/client_intf.c
@@ -979,7 +979,11 @@ py_netsnmp_attr_string(PyObject *obj, ch
PyObject *attr = PyObject_GetAttrString(obj, attr_name);
if (attr) {
int retval;
+#if PY_MAJOR_VERSION >= 3
+ retval = PyBytes_AsStringAndSize(attr, val, len);
+#else
retval = PyString_AsStringAndSize(attr, val, len);
+#endif
Py_DECREF(attr);
return retval;
}
@@ -996,7 +1000,11 @@ py_netsnmp_attr_long(PyObject *obj, char
if (obj && attr_name && PyObject_HasAttrString(obj, attr_name)) {
PyObject *attr = PyObject_GetAttrString(obj, attr_name);
if (attr) {
+#if PY_MAJOR_VERSION >= 3
+ val = PyLong_AsLong(attr);
+#else
val = PyInt_AsLong(attr);
+#endif
Py_DECREF(attr);
}
}
@@ -1079,11 +1087,19 @@ __py_netsnmp_update_session_errors(PyObj
py_netsnmp_attr_set_string(session, "ErrorStr", err_str, STRLEN(err_str));
+#if PY_MAJOR_VERSION >= 3
+ tmp_for_conversion = PyLong_FromLong(err_num);
+#else
tmp_for_conversion = PyInt_FromLong(err_num);
+#endif
PyObject_SetAttrString(session, "ErrorNum", tmp_for_conversion);
Py_DECREF(tmp_for_conversion);
+#if PY_MAJOR_VERSION >= 3
+ tmp_for_conversion = PyLong_FromLong(err_ind);
+#else
tmp_for_conversion = PyInt_FromLong(err_ind);
+#endif
PyObject_SetAttrString(session, "ErrorInd", tmp_for_conversion);
Py_DECREF(tmp_for_conversion);
}
@@ -2607,13 +2623,28 @@ static PyMethodDef ClientMethods[] = {
{NULL, NULL, 0, NULL} /* Sentinel */
};
+#if PY_MAJOR_VERSION >= 3
+static struct PyModuleDef ClientModuleDef = {
+ PyModuleDef_HEAD_INIT,
+ "client_intf",
+ NULL,
+ -1,
+ ClientMethods,
+ NULL,
+ NULL,
+ NULL,
+ NULL
+};
+
+PyMODINIT_FUNC
+PyInit_client_intf(void)
+{
+ return PyModule_Create(&ClientModuleDef);
+}
+#else
PyMODINIT_FUNC
initclient_intf(void)
{
(void) Py_InitModule("client_intf", ClientMethods);
}
-
-
-
-
-
+#endif

View File

@ -1,3 +1,45 @@
-------------------------------------------------------------------
Wed Oct 10 20:22:35 UTC 2018 - abergmann@suse.com
- Update to net-snmp-5.8.
Fixes included:
* Fix remote DoS in agent/helpers/table.c (bsc#1111122, CVE-2018-18065)
* Fix agentx freezing on timeout (bsc#1027353)
* swintst_rpm: Protect against unspecified Group name (bsc#1102775)
- Add tsm and tlstm MIBs and the USM security module. (bsc#1081164)
- Rename and refactor patches and remove those that are already included
inside the new version.
Added:
* net-snmp-5.8-socket-path.patch
* net-snmp-5.8-testing-empty-arptable.patch
* net-snmp-5.8-pie.patch
* net-snmp-5.8-net-snmp-config-headercheck.patch
* net-snmp-5.8-perl-tk-warning.patch
* net-snmp-5.8-velocity-mib.patch
* net-snmp-5.8-netgroups.patch
* net-snmp-5.8-snmpstatus-suppress-output.patch
* net-snmp-5.8-fix-Makefile.PL.patch
* net-snmp-5.8-modern-rpm-api.patch
* net-snmp-5.8-fix-python3.patch
Removed:
* net-snmp-5.7.3-socket-path.patch
* net-snmp-5.7.3-testing-empty-arptable.patch
* net-snmp-5.7.3-pie.patch
* net-snmp-5.7.3-net-snmp-config-headercheck.patch
* net-snmp-5.7.3-perl-tk-warning.patch
* net-snmp-5.7.3-velocity-mib.patch
* net-snmp-5.7.3-fix-snmpd-crashing-when-an-agentx-disconnects.patch
* net-snmp-5.7.3-netgroups.patch
* net-snmp-5.7.3-snmpstatus-suppress-output.patch
* net-snmp-5.7.3-fix-snmp_pdu_parse-incomplete.patch
* net-snmp-5.7.3-Remove-U64-typedef.patch
* net-snmp-5.7.3-Fix-Makefile.PL.patch
* net-snmp-5.7.3-build-with-openssl-1.1.patch
* net-snmp-5.7.3-modern-rpm-api.patch
* net-snmp-python3.patch
* net-snmp-5.7.2-systemd.patch
* net-snmp-5.7.3-helpers-table-skip-if-next-handler-called.patch
-------------------------------------------------------------------
Mon Oct 8 23:44:37 UTC 2018 - abergmann@suse.com

View File

@ -30,7 +30,7 @@
%define libname libsnmp30
%bcond_without python2
Name: net-snmp
Version: 5.7.3
Version: 5.8
Release: 0
Summary: SNMP Daemon
License: BSD-3-Clause AND MIT
@ -48,23 +48,17 @@ Source11: snmptrapd.sysconfig
Source20: net-snmp-tmpfs.conf
Source98: net-snmp-rpmlintrc
Source99: baselibs.conf
Patch1: net-snmp-5.7.3-socket-path.patch
Patch2: net-snmp-5.7.3-testing-empty-arptable.patch
Patch3: net-snmp-5.7.3-pie.patch
Patch4: net-snmp-5.7.3-net-snmp-config-headercheck.patch
Patch5: net-snmp-5.7.3-perl-tk-warning.patch
Patch6: net-snmp-5.7.3-velocity-mib.patch
Patch7: net-snmp-5.7.3-fix-snmpd-crashing-when-an-agentx-disconnects.patch
Patch8: net-snmp-5.7.3-netgroups.patch
Patch9: net-snmp-5.7.3-snmpstatus-suppress-output.patch
Patch10: net-snmp-5.7.3-fix-snmp_pdu_parse-incomplete.patch
Patch11: net-snmp-5.7.3-Remove-U64-typedef.patch
Patch12: net-snmp-5.7.3-Fix-Makefile.PL.patch
Patch13: net-snmp-5.7.3-build-with-openssl-1.1.patch
Patch14: net-snmp-5.7.3-modern-rpm-api.patch
Patch15: net-snmp-python3.patch
Patch16: net-snmp-5.7.2-systemd.patch
Patch17: net-snmp-5.7.3-helpers-table-skip-if-next-handler-called.patch
Patch1: net-snmp-5.8-socket-path.patch
Patch2: net-snmp-5.8-testing-empty-arptable.patch
Patch3: net-snmp-5.8-pie.patch
Patch4: net-snmp-5.8-net-snmp-config-headercheck.patch
Patch5: net-snmp-5.8-perl-tk-warning.patch
Patch6: net-snmp-5.8-velocity-mib.patch
Patch7: net-snmp-5.8-netgroups.patch
Patch8: net-snmp-5.8-snmpstatus-suppress-output.patch
Patch9: net-snmp-5.8-fix-Makefile.PL.patch
Patch10: net-snmp-5.8-modern-rpm-api.patch
Patch11: net-snmp-5.8-fix-python3.patch
BuildRequires: %{python_module devel}
BuildRequires: %{python_module setuptools}
BuildRequires: autoconf
@ -215,7 +209,8 @@ Net-SNMP toolkit library.
MIBS="misc/ipfwacc ucd-snmp/diskio etherlike-mib rmon-mib velocity smux \
ip-mib/ipv4InterfaceTable ip-mib/ipv6InterfaceTable \
ip-mib/ipDefaultRouterTable ip-mib/ipAddressPrefixTable \
ip-mib/ipv6ScopeZoneIndexTable ip-mib/ipIfStatsTable"
ip-mib/ipv6ScopeZoneIndexTable ip-mib/ipIfStatsTable \
tsm-mib tlstm-mib"
%if 0%{?netsnmp_with_sensors}
MIBS="$MIBS ucd-snmp/lmsensorsMib"
@ -242,7 +237,7 @@ autoreconf -fvi
--enable-local-smux \
--enable-ipv6 \
--enable-ucd-snmp-compatibility \
--with-security-modules=tsm \
--with-security-modules=tsm,usm \
--with-transports=TLSTCP,DTLSUDP \
--with-systemd
@ -345,6 +340,10 @@ find %{buildroot} -type f -name "*.la" -delete -print
%{_bindir}/net-snmp-cert
%{_bindir}/agentxtrap
%{_bindir}/snmp-bridge-mib
%{_bindir}/checkbandwidth
%{_bindir}/snmpping
%{_bindir}/snmpps
%{_bindir}/snmptop
%dir %{_libexecdir}/net-snmp
%dir %{_libexecdir}/net-snmp/agents
%{_mandir}/man[158]/*
@ -383,7 +382,7 @@ find %{buildroot} -type f -name "*.la" -delete -print
%files -n perl-SNMP
%{perl_vendorarch}/auto/SNMP
%{perl_vendorarch}/auto/NetSNMP
%{perl_vendorarch}/auto/Bundle
%{perl_vendorarch}/Bundle
%{perl_vendorarch}/SNMP.pm
%{perl_vendorarch}/NetSNMP
%{_bindir}/tkmib