net-snmp/net-snmp-5.8-fix-python3.patch
Marcus Meissner d10b528e62 Accepting request 641283 from home:abergmann:branches:network:utilities
- 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

OBS-URL: https://build.opensuse.org/request/show/641283
OBS-URL: https://build.opensuse.org/package/show/network:utilities/net-snmp?expand=0&rev=16
2018-10-15 15:40:54 +00:00

579 lines
21 KiB
Diff

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: