update net-snmp to 5.9.1
This commit is contained in:
parent
c39a0a4049
commit
9f97e728d6
@ -1,363 +0,0 @@
|
||||
From adc9b71aba9168ec64149345ea37a1acc11875c6 Mon Sep 17 00:00:00 2001
|
||||
From: Sam Tannous <stannous@cumulusnetworks.com>
|
||||
Date: Wed, 10 Apr 2019 06:57:21 -0700
|
||||
Subject: [PATCH] snmpd: Avoid that snmpv3 bulkget errors result in a double
|
||||
free
|
||||
|
||||
See also https://sourceforge.net/p/net-snmp/bugs/2923/.
|
||||
See also https://sourceforge.net/p/net-snmp/patches/1388/.
|
||||
---
|
||||
agent/snmp_agent.c | 7 ++++++
|
||||
include/net-snmp/pdu_api.h | 2 ++
|
||||
snmplib/snmp_api.c | 11 ++++++++
|
||||
snmplib/snmpusm.c | 51 ++++++++------------------------------
|
||||
4 files changed, 31 insertions(+), 40 deletions(-)
|
||||
|
||||
diff --git a/agent/snmp_agent.c b/agent/snmp_agent.c
|
||||
index 26653f4e6..100c4d001 100644
|
||||
--- a/agent/snmp_agent.c
|
||||
+++ b/agent/snmp_agent.c
|
||||
@@ -1604,6 +1604,13 @@ free_agent_snmp_session(netsnmp_agent_session *asp)
|
||||
|
||||
DEBUGMSGTL(("verbose:asp", "asp %p reqinfo %p freed\n",
|
||||
asp, asp->reqinfo));
|
||||
+
|
||||
+ /* Clean up securityStateRef here to prevent a double free */
|
||||
+ if (asp->orig_pdu && asp->orig_pdu->securityStateRef)
|
||||
+ snmp_free_securityStateRef(asp->orig_pdu);
|
||||
+ if (asp->pdu && asp->pdu->securityStateRef)
|
||||
+ snmp_free_securityStateRef(asp->pdu);
|
||||
+
|
||||
if (asp->orig_pdu)
|
||||
snmp_free_pdu(asp->orig_pdu);
|
||||
if (asp->pdu)
|
||||
diff --git a/include/net-snmp/pdu_api.h b/include/net-snmp/pdu_api.h
|
||||
index 125595d9a..270aff054 100644
|
||||
--- a/include/net-snmp/pdu_api.h
|
||||
+++ b/include/net-snmp/pdu_api.h
|
||||
@@ -19,6 +19,8 @@ NETSNMP_IMPORT
|
||||
netsnmp_pdu *snmp_fix_pdu( netsnmp_pdu *pdu, int idx);
|
||||
NETSNMP_IMPORT
|
||||
void snmp_free_pdu( netsnmp_pdu *pdu);
|
||||
+NETSNMP_IMPORT
|
||||
+void snmp_free_securityStateRef( netsnmp_pdu *pdu);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
diff --git a/snmplib/snmp_api.c b/snmplib/snmp_api.c
|
||||
index 554767a83..321a48f1b 100644
|
||||
--- a/snmplib/snmp_api.c
|
||||
+++ b/snmplib/snmp_api.c
|
||||
@@ -4028,6 +4028,17 @@ free_securityStateRef(netsnmp_pdu* pdu)
|
||||
pdu->securityStateRef = NULL;
|
||||
}
|
||||
|
||||
+/*
|
||||
+ * This function is here to provide a separate call to
|
||||
+ * free the securityStateRef memory. This is needed to prevent
|
||||
+ * a double free if this memory is freed in snmp_free_pdu.
|
||||
+ */
|
||||
+void
|
||||
+snmp_free_securityStateRef(netsnmp_pdu* pdu)
|
||||
+{
|
||||
+ free_securityStateRef(pdu);
|
||||
+}
|
||||
+
|
||||
#define ERROR_STAT_LENGTH 11
|
||||
|
||||
int
|
||||
diff --git a/snmplib/snmpusm.c b/snmplib/snmpusm.c
|
||||
index 3cfa1267a..873bd890f 100644
|
||||
--- a/snmplib/snmpusm.c
|
||||
+++ b/snmplib/snmpusm.c
|
||||
@@ -299,16 +299,20 @@ usm_free_usmStateReference(void *old)
|
||||
|
||||
if (old_ref) {
|
||||
|
||||
- SNMP_FREE(old_ref->usr_name);
|
||||
- SNMP_FREE(old_ref->usr_engine_id);
|
||||
- SNMP_FREE(old_ref->usr_auth_protocol);
|
||||
- SNMP_FREE(old_ref->usr_priv_protocol);
|
||||
-
|
||||
- if (old_ref->usr_auth_key) {
|
||||
+ if (old_ref->usr_name_length)
|
||||
+ SNMP_FREE(old_ref->usr_name);
|
||||
+ if (old_ref->usr_engine_id_length)
|
||||
+ SNMP_FREE(old_ref->usr_engine_id);
|
||||
+ if (old_ref->usr_auth_protocol_length)
|
||||
+ SNMP_FREE(old_ref->usr_auth_protocol);
|
||||
+ if (old_ref->usr_auth_protocol_length)
|
||||
+ SNMP_FREE(old_ref->usr_priv_protocol);
|
||||
+
|
||||
+ if (old_ref->usr_auth_key_length && old_ref->usr_auth_key) {
|
||||
SNMP_ZERO(old_ref->usr_auth_key, old_ref->usr_auth_key_length);
|
||||
SNMP_FREE(old_ref->usr_auth_key);
|
||||
}
|
||||
- if (old_ref->usr_priv_key) {
|
||||
+ if (old_ref->usr_priv_key_length && old_ref->usr_priv_key) {
|
||||
SNMP_ZERO(old_ref->usr_priv_key, old_ref->usr_priv_key_length);
|
||||
SNMP_FREE(old_ref->usr_priv_key);
|
||||
}
|
||||
@@ -1039,7 +1043,6 @@ usm_generate_out_msg(int msgProcModel, /* (UNUSED) */
|
||||
if ((user = usm_get_user(secEngineID, secEngineIDLen, secName))
|
||||
== NULL && secLevel != SNMP_SEC_LEVEL_NOAUTH) {
|
||||
DEBUGMSGTL(("usm", "Unknown User(%s)\n", secName));
|
||||
- usm_free_usmStateReference(secStateRef);
|
||||
return SNMPERR_USM_UNKNOWNSECURITYNAME;
|
||||
}
|
||||
|
||||
@@ -1091,7 +1094,6 @@ usm_generate_out_msg(int msgProcModel, /* (UNUSED) */
|
||||
thePrivProtocolLength) == 1) {
|
||||
DEBUGMSGTL(("usm", "Unsupported Security Level (%d)\n",
|
||||
theSecLevel));
|
||||
- usm_free_usmStateReference(secStateRef);
|
||||
return SNMPERR_USM_UNSUPPORTEDSECURITYLEVEL;
|
||||
}
|
||||
|
||||
@@ -1121,7 +1123,6 @@ usm_generate_out_msg(int msgProcModel, /* (UNUSED) */
|
||||
&msgAuthParmLen, &msgPrivParmLen, &otstlen,
|
||||
&seq_len, &msgSecParmLen) == -1) {
|
||||
DEBUGMSGTL(("usm", "Failed calculating offsets.\n"));
|
||||
- usm_free_usmStateReference(secStateRef);
|
||||
return SNMPERR_USM_GENERICERROR;
|
||||
}
|
||||
|
||||
@@ -1143,7 +1144,6 @@ usm_generate_out_msg(int msgProcModel, /* (UNUSED) */
|
||||
ptr = *wholeMsg = globalData;
|
||||
if (theTotalLength > *wholeMsgLen) {
|
||||
DEBUGMSGTL(("usm", "Message won't fit in buffer.\n"));
|
||||
- usm_free_usmStateReference(secStateRef);
|
||||
return SNMPERR_USM_GENERICERROR;
|
||||
}
|
||||
|
||||
@@ -1169,7 +1169,6 @@ usm_generate_out_msg(int msgProcModel, /* (UNUSED) */
|
||||
htonl(boots_uint), htonl(time_uint),
|
||||
&ptr[privParamsOffset]) == -1) {
|
||||
DEBUGMSGTL(("usm", "Can't set AES iv.\n"));
|
||||
- usm_free_usmStateReference(secStateRef);
|
||||
return SNMPERR_USM_GENERICERROR;
|
||||
}
|
||||
}
|
||||
@@ -1185,7 +1184,6 @@ usm_generate_out_msg(int msgProcModel, /* (UNUSED) */
|
||||
&ptr[privParamsOffset])
|
||||
== -1)) {
|
||||
DEBUGMSGTL(("usm", "Can't set DES-CBC salt.\n"));
|
||||
- usm_free_usmStateReference(secStateRef);
|
||||
return SNMPERR_USM_GENERICERROR;
|
||||
}
|
||||
}
|
||||
@@ -1198,7 +1196,6 @@ usm_generate_out_msg(int msgProcModel, /* (UNUSED) */
|
||||
&ptr[dataOffset], &encrypted_length)
|
||||
!= SNMP_ERR_NOERROR) {
|
||||
DEBUGMSGTL(("usm", "encryption error.\n"));
|
||||
- usm_free_usmStateReference(secStateRef);
|
||||
return SNMPERR_USM_ENCRYPTIONERROR;
|
||||
}
|
||||
#ifdef NETSNMP_ENABLE_TESTING_CODE
|
||||
@@ -1226,7 +1223,6 @@ usm_generate_out_msg(int msgProcModel, /* (UNUSED) */
|
||||
if ((encrypted_length != (theTotalLength - dataOffset))
|
||||
|| (salt_length != msgPrivParmLen)) {
|
||||
DEBUGMSGTL(("usm", "encryption length error.\n"));
|
||||
- usm_free_usmStateReference(secStateRef);
|
||||
return SNMPERR_USM_ENCRYPTIONERROR;
|
||||
}
|
||||
|
||||
@@ -1362,7 +1358,6 @@ usm_generate_out_msg(int msgProcModel, /* (UNUSED) */
|
||||
|
||||
if (temp_sig == NULL) {
|
||||
DEBUGMSGTL(("usm", "Out of memory.\n"));
|
||||
- usm_free_usmStateReference(secStateRef);
|
||||
return SNMPERR_USM_GENERICERROR;
|
||||
}
|
||||
|
||||
@@ -1376,7 +1371,6 @@ usm_generate_out_msg(int msgProcModel, /* (UNUSED) */
|
||||
SNMP_ZERO(temp_sig, temp_sig_len);
|
||||
SNMP_FREE(temp_sig);
|
||||
DEBUGMSGTL(("usm", "Signing failed.\n"));
|
||||
- usm_free_usmStateReference(secStateRef);
|
||||
return SNMPERR_USM_AUTHENTICATIONFAILURE;
|
||||
}
|
||||
|
||||
@@ -1384,7 +1378,6 @@ usm_generate_out_msg(int msgProcModel, /* (UNUSED) */
|
||||
SNMP_ZERO(temp_sig, temp_sig_len);
|
||||
SNMP_FREE(temp_sig);
|
||||
DEBUGMSGTL(("usm", "Signing lengths failed.\n"));
|
||||
- usm_free_usmStateReference(secStateRef);
|
||||
return SNMPERR_USM_AUTHENTICATIONFAILURE;
|
||||
}
|
||||
|
||||
@@ -1398,7 +1391,6 @@ usm_generate_out_msg(int msgProcModel, /* (UNUSED) */
|
||||
/*
|
||||
* endif -- create keyed hash
|
||||
*/
|
||||
- usm_free_usmStateReference(secStateRef);
|
||||
|
||||
DEBUGMSGTL(("usm", "USM processing completed.\n"));
|
||||
|
||||
@@ -1548,7 +1540,6 @@ usm_rgenerate_out_msg(int msgProcModel, /* (UNUSED) */
|
||||
if ((user = usm_get_user(secEngineID, secEngineIDLen, secName))
|
||||
== NULL && secLevel != SNMP_SEC_LEVEL_NOAUTH) {
|
||||
DEBUGMSGTL(("usm", "Unknown User\n"));
|
||||
- usm_free_usmStateReference(secStateRef);
|
||||
return SNMPERR_USM_UNKNOWNSECURITYNAME;
|
||||
}
|
||||
|
||||
@@ -1601,7 +1592,6 @@ usm_rgenerate_out_msg(int msgProcModel, /* (UNUSED) */
|
||||
DEBUGMSGTL(("usm", "Unsupported Security Level or type (%d)\n",
|
||||
theSecLevel));
|
||||
|
||||
- usm_free_usmStateReference(secStateRef);
|
||||
return SNMPERR_USM_UNSUPPORTEDSECURITYLEVEL;
|
||||
}
|
||||
|
||||
@@ -1636,7 +1626,6 @@ usm_rgenerate_out_msg(int msgProcModel, /* (UNUSED) */
|
||||
DEBUGMSGTL(("usm",
|
||||
"couldn't malloc %d bytes for encrypted PDU\n",
|
||||
(int)ciphertextlen));
|
||||
- usm_free_usmStateReference(secStateRef);
|
||||
return SNMPERR_MALLOC;
|
||||
}
|
||||
|
||||
@@ -1652,7 +1641,6 @@ usm_rgenerate_out_msg(int msgProcModel, /* (UNUSED) */
|
||||
htonl(boots_uint), htonl(time_uint),
|
||||
iv) == -1) {
|
||||
DEBUGMSGTL(("usm", "Can't set AES iv.\n"));
|
||||
- usm_free_usmStateReference(secStateRef);
|
||||
SNMP_FREE(ciphertext);
|
||||
return SNMPERR_USM_GENERICERROR;
|
||||
}
|
||||
@@ -1667,7 +1655,6 @@ usm_rgenerate_out_msg(int msgProcModel, /* (UNUSED) */
|
||||
thePrivKeyLength - 8,
|
||||
iv) == -1)) {
|
||||
DEBUGMSGTL(("usm", "Can't set DES-CBC salt.\n"));
|
||||
- usm_free_usmStateReference(secStateRef);
|
||||
SNMP_FREE(ciphertext);
|
||||
return SNMPERR_USM_GENERICERROR;
|
||||
}
|
||||
@@ -1686,7 +1673,6 @@ usm_rgenerate_out_msg(int msgProcModel, /* (UNUSED) */
|
||||
scopedPdu, scopedPduLen,
|
||||
ciphertext, &ciphertextlen) != SNMP_ERR_NOERROR) {
|
||||
DEBUGMSGTL(("usm", "encryption error.\n"));
|
||||
- usm_free_usmStateReference(secStateRef);
|
||||
SNMP_FREE(ciphertext);
|
||||
return SNMPERR_USM_ENCRYPTIONERROR;
|
||||
}
|
||||
@@ -1703,7 +1689,6 @@ usm_rgenerate_out_msg(int msgProcModel, /* (UNUSED) */
|
||||
ciphertext, ciphertextlen);
|
||||
if (rc == 0) {
|
||||
DEBUGMSGTL(("usm", "Encryption failed.\n"));
|
||||
- usm_free_usmStateReference(secStateRef);
|
||||
SNMP_FREE(ciphertext);
|
||||
return SNMPERR_USM_ENCRYPTIONERROR;
|
||||
}
|
||||
@@ -1743,7 +1728,6 @@ usm_rgenerate_out_msg(int msgProcModel, /* (UNUSED) */
|
||||
DEBUGINDENTLESS();
|
||||
if (rc == 0) {
|
||||
DEBUGMSGTL(("usm", "building privParams failed.\n"));
|
||||
- usm_free_usmStateReference(secStateRef);
|
||||
return SNMPERR_TOO_LONG;
|
||||
}
|
||||
|
||||
@@ -1766,7 +1750,6 @@ usm_rgenerate_out_msg(int msgProcModel, /* (UNUSED) */
|
||||
DEBUGINDENTLESS();
|
||||
if (rc == 0) {
|
||||
DEBUGMSGTL(("usm", "building authParams failed.\n"));
|
||||
- usm_free_usmStateReference(secStateRef);
|
||||
return SNMPERR_TOO_LONG;
|
||||
}
|
||||
|
||||
@@ -1789,7 +1772,6 @@ usm_rgenerate_out_msg(int msgProcModel, /* (UNUSED) */
|
||||
DEBUGINDENTLESS();
|
||||
if (rc == 0) {
|
||||
DEBUGMSGTL(("usm", "building authParams failed.\n"));
|
||||
- usm_free_usmStateReference(secStateRef);
|
||||
return SNMPERR_TOO_LONG;
|
||||
}
|
||||
|
||||
@@ -1805,7 +1787,6 @@ usm_rgenerate_out_msg(int msgProcModel, /* (UNUSED) */
|
||||
if (rc == 0) {
|
||||
DEBUGMSGTL(("usm",
|
||||
"building msgAuthoritativeEngineTime failed.\n"));
|
||||
- usm_free_usmStateReference(secStateRef);
|
||||
return SNMPERR_TOO_LONG;
|
||||
}
|
||||
|
||||
@@ -1821,7 +1802,6 @@ usm_rgenerate_out_msg(int msgProcModel, /* (UNUSED) */
|
||||
if (rc == 0) {
|
||||
DEBUGMSGTL(("usm",
|
||||
"building msgAuthoritativeEngineBoots failed.\n"));
|
||||
- usm_free_usmStateReference(secStateRef);
|
||||
return SNMPERR_TOO_LONG;
|
||||
}
|
||||
|
||||
@@ -1833,7 +1813,6 @@ usm_rgenerate_out_msg(int msgProcModel, /* (UNUSED) */
|
||||
DEBUGINDENTLESS();
|
||||
if (rc == 0) {
|
||||
DEBUGMSGTL(("usm", "building msgAuthoritativeEngineID failed.\n"));
|
||||
- usm_free_usmStateReference(secStateRef);
|
||||
return SNMPERR_TOO_LONG;
|
||||
}
|
||||
|
||||
@@ -1846,7 +1825,6 @@ usm_rgenerate_out_msg(int msgProcModel, /* (UNUSED) */
|
||||
*offset - sp_offset);
|
||||
if (rc == 0) {
|
||||
DEBUGMSGTL(("usm", "building usm security parameters failed.\n"));
|
||||
- usm_free_usmStateReference(secStateRef);
|
||||
return SNMPERR_TOO_LONG;
|
||||
}
|
||||
|
||||
@@ -1860,7 +1838,6 @@ usm_rgenerate_out_msg(int msgProcModel, /* (UNUSED) */
|
||||
|
||||
if (rc == 0) {
|
||||
DEBUGMSGTL(("usm", "building msgSecurityParameters failed.\n"));
|
||||
- usm_free_usmStateReference(secStateRef);
|
||||
return SNMPERR_TOO_LONG;
|
||||
}
|
||||
|
||||
@@ -1870,7 +1847,6 @@ usm_rgenerate_out_msg(int msgProcModel, /* (UNUSED) */
|
||||
while ((*wholeMsgLen - *offset) < globalDataLen) {
|
||||
if (!asn_realloc(wholeMsg, wholeMsgLen)) {
|
||||
DEBUGMSGTL(("usm", "building global data failed.\n"));
|
||||
- usm_free_usmStateReference(secStateRef);
|
||||
return SNMPERR_TOO_LONG;
|
||||
}
|
||||
}
|
||||
@@ -1886,7 +1862,6 @@ usm_rgenerate_out_msg(int msgProcModel, /* (UNUSED) */
|
||||
ASN_CONSTRUCTOR), *offset);
|
||||
if (rc == 0) {
|
||||
DEBUGMSGTL(("usm", "building master packet sequence failed.\n"));
|
||||
- usm_free_usmStateReference(secStateRef);
|
||||
return SNMPERR_TOO_LONG;
|
||||
}
|
||||
|
||||
@@ -1904,7 +1879,6 @@ usm_rgenerate_out_msg(int msgProcModel, /* (UNUSED) */
|
||||
|
||||
if (temp_sig == NULL) {
|
||||
DEBUGMSGTL(("usm", "Out of memory.\n"));
|
||||
- usm_free_usmStateReference(secStateRef);
|
||||
return SNMPERR_USM_GENERICERROR;
|
||||
}
|
||||
|
||||
@@ -1915,14 +1889,12 @@ usm_rgenerate_out_msg(int msgProcModel, /* (UNUSED) */
|
||||
!= SNMP_ERR_NOERROR) {
|
||||
SNMP_FREE(temp_sig);
|
||||
DEBUGMSGTL(("usm", "Signing failed.\n"));
|
||||
- usm_free_usmStateReference(secStateRef);
|
||||
return SNMPERR_USM_AUTHENTICATIONFAILURE;
|
||||
}
|
||||
|
||||
if (temp_sig_len != msgAuthParmLen) {
|
||||
SNMP_FREE(temp_sig);
|
||||
DEBUGMSGTL(("usm", "Signing lengths failed.\n"));
|
||||
- usm_free_usmStateReference(secStateRef);
|
||||
return SNMPERR_USM_AUTHENTICATIONFAILURE;
|
||||
}
|
||||
|
||||
@@ -1933,7 +1905,6 @@ usm_rgenerate_out_msg(int msgProcModel, /* (UNUSED) */
|
||||
/*
|
||||
* endif -- create keyed hash
|
||||
*/
|
||||
- usm_free_usmStateReference(secStateRef);
|
||||
DEBUGMSGTL(("usm", "USM processing completed.\n"));
|
||||
return SNMPERR_SUCCESS;
|
||||
} /* end usm_rgenerate_out_msg() */
|
||||
@ -1,89 +0,0 @@
|
||||
From 92ccd5a82a019fbfa835cc8ab2294cf0ca48c8f2 Mon Sep 17 00:00:00 2001
|
||||
From: Bart Van Assche <bvanassche@acm.org>
|
||||
Date: Sat, 25 May 2019 16:33:31 +0200
|
||||
Subject: [PATCH] libsnmp: Move the securityStateRef check into
|
||||
free_securityStateRef()
|
||||
|
||||
Instead of making each free_securityStateRef() caller check the
|
||||
securityStateRef pointer, move that check into free_securityStateRef().
|
||||
---
|
||||
agent/snmp_agent.c | 4 ++--
|
||||
snmplib/snmp_api.c | 21 ++++++++++-----------
|
||||
2 files changed, 12 insertions(+), 13 deletions(-)
|
||||
|
||||
diff --git a/agent/snmp_agent.c b/agent/snmp_agent.c
|
||||
index 9d2355e33..b1881c96e 100644
|
||||
--- a/agent/snmp_agent.c
|
||||
+++ b/agent/snmp_agent.c
|
||||
@@ -1606,9 +1606,9 @@ free_agent_snmp_session(netsnmp_agent_session *asp)
|
||||
asp, asp->reqinfo));
|
||||
|
||||
/* Clean up securityStateRef here to prevent a double free */
|
||||
- if (asp->orig_pdu && asp->orig_pdu->securityStateRef)
|
||||
+ if (asp->orig_pdu)
|
||||
snmp_free_securityStateRef(asp->orig_pdu);
|
||||
- if (asp->pdu && asp->pdu->securityStateRef)
|
||||
+ if (asp->pdu)
|
||||
snmp_free_securityStateRef(asp->pdu);
|
||||
|
||||
if (asp->orig_pdu)
|
||||
diff --git a/snmplib/snmp_api.c b/snmplib/snmp_api.c
|
||||
index 36ab2d2d8..7922ea794 100644
|
||||
--- a/snmplib/snmp_api.c
|
||||
+++ b/snmplib/snmp_api.c
|
||||
@@ -4020,7 +4020,12 @@ snmpv3_parse(netsnmp_pdu *pdu,
|
||||
static void
|
||||
free_securityStateRef(netsnmp_pdu* pdu)
|
||||
{
|
||||
- struct snmp_secmod_def *sptr = find_sec_mod(pdu->securityModel);
|
||||
+ struct snmp_secmod_def *sptr;
|
||||
+
|
||||
+ if (!pdu->securityStateRef)
|
||||
+ return;
|
||||
+
|
||||
+ sptr = find_sec_mod(pdu->securityModel);
|
||||
if (sptr) {
|
||||
if (sptr->pdu_free_state_ref) {
|
||||
(*sptr->pdu_free_state_ref) (pdu->securityStateRef);
|
||||
@@ -4142,9 +4147,7 @@ snmpv3_make_report(netsnmp_pdu *pdu, int error)
|
||||
* FIX - yes they should but USM needs to follow new EoP to determine
|
||||
* which cached values to use
|
||||
*/
|
||||
- if (pdu->securityStateRef) {
|
||||
- free_securityStateRef(pdu);
|
||||
- }
|
||||
+ free_securityStateRef(pdu);
|
||||
|
||||
if (error == SNMPERR_USM_NOTINTIMEWINDOW) {
|
||||
pdu->securityLevel = SNMP_SEC_LEVEL_AUTHNOPRIV;
|
||||
@@ -5658,9 +5661,7 @@ _sess_process_packet_parse_pdu(void *sessp, netsnmp_session * sp,
|
||||
/*
|
||||
* Call the security model to free any securityStateRef supplied w/ msg.
|
||||
*/
|
||||
- if (pdu->securityStateRef != NULL) {
|
||||
- free_securityStateRef(pdu);
|
||||
- }
|
||||
+ free_securityStateRef(pdu);
|
||||
snmp_free_pdu(pdu);
|
||||
return NULL;
|
||||
}
|
||||
@@ -5698,9 +5699,7 @@ _sess_process_packet_handle_pdu(void *sessp, netsnmp_session * sp,
|
||||
/*
|
||||
* Call USM to free any securityStateRef supplied with the message.
|
||||
*/
|
||||
- if (pdu->securityStateRef) {
|
||||
- free_securityStateRef(pdu);
|
||||
- }
|
||||
+ free_securityStateRef(pdu);
|
||||
|
||||
for (rp = isp->requests; rp; orp = rp, rp = rp->next_request) {
|
||||
snmp_callback callback;
|
||||
@@ -5845,7 +5844,7 @@ _sess_process_packet_handle_pdu(void *sessp, netsnmp_session * sp,
|
||||
/*
|
||||
* Call USM to free any securityStateRef supplied with the message.
|
||||
*/
|
||||
- if (pdu->securityStateRef && pdu->command == SNMP_MSG_TRAP2)
|
||||
+ if (pdu->command == SNMP_MSG_TRAP2)
|
||||
free_securityStateRef(pdu);
|
||||
|
||||
if (!handled) {
|
||||
@ -1,25 +0,0 @@
|
||||
From 7384a8b550d4ed4a00e41b72229cfcc124926b06 Mon Sep 17 00:00:00 2001
|
||||
From: Ming Chen <ming0903@users.sourceforge.net>
|
||||
Date: Wed, 5 Jun 2019 19:58:44 -0700
|
||||
Subject: [PATCH] libsnmp: Fix usm_free_usmStateReference()
|
||||
|
||||
See also https://sourceforge.net/p/net-snmp/bugs/2923/.
|
||||
|
||||
Fixes: adc9b71aba91 ("snmpd: Avoid that snmpv3 bulkget errors result in a double free")
|
||||
---
|
||||
snmplib/snmpusm.c | 2 +-
|
||||
1 file changed, 1 insertion(+), 1 deletion(-)
|
||||
|
||||
diff --git a/snmplib/snmpusm.c b/snmplib/snmpusm.c
|
||||
index ed7dc2e59..90c485c3c 100644
|
||||
--- a/snmplib/snmpusm.c
|
||||
+++ b/snmplib/snmpusm.c
|
||||
@@ -305,7 +305,7 @@ usm_free_usmStateReference(void *old)
|
||||
SNMP_FREE(old_ref->usr_engine_id);
|
||||
if (old_ref->usr_auth_protocol_length)
|
||||
SNMP_FREE(old_ref->usr_auth_protocol);
|
||||
- if (old_ref->usr_auth_protocol_length)
|
||||
+ if (old_ref->usr_priv_protocol_length)
|
||||
SNMP_FREE(old_ref->usr_priv_protocol);
|
||||
|
||||
if (old_ref->usr_auth_key_length && old_ref->usr_auth_key) {
|
||||
@ -1,68 +0,0 @@
|
||||
From 39381c4d20dd8042870c28ae3b0c16291e50b705 Mon Sep 17 00:00:00 2001
|
||||
From: Bart Van Assche <bvanassche@acm.org>
|
||||
Date: Tue, 23 Jul 2019 10:52:28 -0700
|
||||
Subject: [PATCH] libsnmp: Unexport struct usmStateReference
|
||||
|
||||
Certain snmpd crashes can only be fixed by introducing a reference
|
||||
count in struct usmStateReference. Unexport that structure such that
|
||||
changing it does not affect the ABI.
|
||||
---
|
||||
include/net-snmp/library/snmpusm.h | 17 +----------------
|
||||
snmplib/snmpusm.c | 16 ++++++++++++++++
|
||||
2 files changed, 17 insertions(+), 16 deletions(-)
|
||||
|
||||
diff --git a/include/net-snmp/library/snmpusm.h b/include/net-snmp/library/snmpusm.h
|
||||
index 3f6078799..49061d8b1 100644
|
||||
--- a/include/net-snmp/library/snmpusm.h
|
||||
+++ b/include/net-snmp/library/snmpusm.h
|
||||
@@ -42,22 +42,7 @@ extern "C" {
|
||||
/*
|
||||
* Structures.
|
||||
*/
|
||||
- struct usmStateReference {
|
||||
- char *usr_name;
|
||||
- size_t usr_name_length;
|
||||
- u_char *usr_engine_id;
|
||||
- size_t usr_engine_id_length;
|
||||
- oid *usr_auth_protocol;
|
||||
- size_t usr_auth_protocol_length;
|
||||
- u_char *usr_auth_key;
|
||||
- size_t usr_auth_key_length;
|
||||
- oid *usr_priv_protocol;
|
||||
- size_t usr_priv_protocol_length;
|
||||
- u_char *usr_priv_key;
|
||||
- size_t usr_priv_key_length;
|
||||
- u_int usr_sec_level;
|
||||
- };
|
||||
-
|
||||
+ struct usmStateReference;
|
||||
|
||||
/*
|
||||
* struct usmUser: a structure to represent a given user in a list
|
||||
diff --git a/snmplib/snmpusm.c b/snmplib/snmpusm.c
|
||||
index ae2d16906..917865267 100644
|
||||
--- a/snmplib/snmpusm.c
|
||||
+++ b/snmplib/snmpusm.c
|
||||
@@ -84,6 +84,22 @@ netsnmp_feature_child_of(usm_support, usm_all)
|
||||
|
||||
netsnmp_feature_require(usm_support)
|
||||
|
||||
+struct usmStateReference {
|
||||
+ char *usr_name;
|
||||
+ size_t usr_name_length;
|
||||
+ u_char *usr_engine_id;
|
||||
+ size_t usr_engine_id_length;
|
||||
+ oid *usr_auth_protocol;
|
||||
+ size_t usr_auth_protocol_length;
|
||||
+ u_char *usr_auth_key;
|
||||
+ size_t usr_auth_key_length;
|
||||
+ oid *usr_priv_protocol;
|
||||
+ size_t usr_priv_protocol_length;
|
||||
+ u_char *usr_priv_key;
|
||||
+ size_t usr_priv_key_length;
|
||||
+ u_int usr_sec_level;
|
||||
+};
|
||||
+
|
||||
oid usmNoAuthProtocol[10] = { NETSNMP_USMAUTH_BASE_OID,
|
||||
NETSNMP_USMAUTH_NOAUTH };
|
||||
#ifndef NETSNMP_DISABLE_MD5
|
||||
@ -1,161 +0,0 @@
|
||||
From 5f881d3bf24599b90d67a45cae7a3eb099cd71c9 Mon Sep 17 00:00:00 2001
|
||||
From: Bart Van Assche <bvanassche@acm.org>
|
||||
Date: Sat, 27 Jul 2019 19:34:09 -0700
|
||||
Subject: [PATCH] libsnmp, USM: Introduce a reference count in struct
|
||||
usmStateReference
|
||||
|
||||
This patch fixes https://sourceforge.net/p/net-snmp/bugs/2956/.
|
||||
---
|
||||
snmplib/snmp_client.c | 22 +++----------
|
||||
snmplib/snmpusm.c | 73 ++++++++++++++++++++++++++++---------------
|
||||
2 files changed, 53 insertions(+), 42 deletions(-)
|
||||
|
||||
diff --git a/snmplib/snmp_client.c b/snmplib/snmp_client.c
|
||||
index 2a46351..b2ea891 100644
|
||||
--- a/snmplib/snmp_client.c
|
||||
+++ b/snmplib/snmp_client.c
|
||||
@@ -402,27 +402,16 @@ _clone_pdu_header(netsnmp_pdu *pdu)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
- if (pdu->securityStateRef &&
|
||||
- pdu->command == SNMP_MSG_TRAP2) {
|
||||
-
|
||||
- ret = usm_clone_usmStateReference((struct usmStateReference *) pdu->securityStateRef,
|
||||
- (struct usmStateReference **) &newpdu->securityStateRef );
|
||||
-
|
||||
- if (ret)
|
||||
- {
|
||||
+ sptr = find_sec_mod(newpdu->securityModel);
|
||||
+ if (sptr && sptr->pdu_clone) {
|
||||
+ /* call security model if it needs to know about this */
|
||||
+ ret = sptr->pdu_clone(pdu, newpdu);
|
||||
+ if (ret) {
|
||||
snmp_free_pdu(newpdu);
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
- if ((sptr = find_sec_mod(newpdu->securityModel)) != NULL &&
|
||||
- sptr->pdu_clone != NULL) {
|
||||
- /*
|
||||
- * call security model if it needs to know about this
|
||||
- */
|
||||
- (*sptr->pdu_clone) (pdu, newpdu);
|
||||
- }
|
||||
-
|
||||
return newpdu;
|
||||
}
|
||||
|
||||
diff --git a/snmplib/snmpusm.c b/snmplib/snmpusm.c
|
||||
index c4e11b3..9e912c1 100644
|
||||
--- a/snmplib/snmpusm.c
|
||||
+++ b/snmplib/snmpusm.c
|
||||
@@ -85,6 +85,7 @@ netsnmp_feature_child_of(usm_support, usm_all)
|
||||
netsnmp_feature_require(usm_support)
|
||||
|
||||
struct usmStateReference {
|
||||
+ int refcnt;
|
||||
char *usr_name;
|
||||
size_t usr_name_length;
|
||||
u_char *usr_engine_id;
|
||||
@@ -301,43 +302,63 @@ free_enginetime_on_shutdown(int majorid, int minorid, void *serverarg,
|
||||
struct usmStateReference *
|
||||
usm_malloc_usmStateReference(void)
|
||||
{
|
||||
- struct usmStateReference *retval = (struct usmStateReference *)
|
||||
- calloc(1, sizeof(struct usmStateReference));
|
||||
+ struct usmStateReference *retval;
|
||||
+
|
||||
+ retval = calloc(1, sizeof(struct usmStateReference));
|
||||
+ if (retval)
|
||||
+ retval->refcnt = 1;
|
||||
|
||||
return retval;
|
||||
} /* end usm_malloc_usmStateReference() */
|
||||
|
||||
+static int
|
||||
+usm_clone(netsnmp_pdu *pdu, netsnmp_pdu *new_pdu)
|
||||
+{
|
||||
+ struct usmStateReference *ref = pdu->securityStateRef;
|
||||
+ struct usmStateReference **new_ref =
|
||||
+ (struct usmStateReference **)&new_pdu->securityStateRef;
|
||||
+ int ret = 0;
|
||||
+
|
||||
+ if (!ref)
|
||||
+ return ret;
|
||||
+
|
||||
+ if (pdu->command == SNMP_MSG_TRAP2) {
|
||||
+ netsnmp_assert(pdu->securityModel == SNMP_DEFAULT_SECMODEL);
|
||||
+ ret = usm_clone_usmStateReference(ref, new_ref);
|
||||
+ } else {
|
||||
+ netsnmp_assert(ref == *new_ref);
|
||||
+ ref->refcnt++;
|
||||
+ }
|
||||
+
|
||||
+ return ret;
|
||||
+}
|
||||
|
||||
void
|
||||
usm_free_usmStateReference(void *old)
|
||||
{
|
||||
- struct usmStateReference *old_ref = (struct usmStateReference *) old;
|
||||
-
|
||||
- if (old_ref) {
|
||||
-
|
||||
- if (old_ref->usr_name_length)
|
||||
- SNMP_FREE(old_ref->usr_name);
|
||||
- if (old_ref->usr_engine_id_length)
|
||||
- SNMP_FREE(old_ref->usr_engine_id);
|
||||
- if (old_ref->usr_auth_protocol_length)
|
||||
- SNMP_FREE(old_ref->usr_auth_protocol);
|
||||
- if (old_ref->usr_priv_protocol_length)
|
||||
- SNMP_FREE(old_ref->usr_priv_protocol);
|
||||
-
|
||||
- if (old_ref->usr_auth_key_length && old_ref->usr_auth_key) {
|
||||
- SNMP_ZERO(old_ref->usr_auth_key, old_ref->usr_auth_key_length);
|
||||
- SNMP_FREE(old_ref->usr_auth_key);
|
||||
- }
|
||||
- if (old_ref->usr_priv_key_length && old_ref->usr_priv_key) {
|
||||
- SNMP_ZERO(old_ref->usr_priv_key, old_ref->usr_priv_key_length);
|
||||
- SNMP_FREE(old_ref->usr_priv_key);
|
||||
- }
|
||||
+ struct usmStateReference *ref = old;
|
||||
+
|
||||
+ if (!ref)
|
||||
+ return;
|
||||
+
|
||||
+ if (--ref->refcnt > 0)
|
||||
+ return;
|
||||
|
||||
- SNMP_ZERO(old_ref, sizeof(*old_ref));
|
||||
- SNMP_FREE(old_ref);
|
||||
+ SNMP_FREE(ref->usr_name);
|
||||
+ SNMP_FREE(ref->usr_engine_id);
|
||||
+ SNMP_FREE(ref->usr_auth_protocol);
|
||||
+ SNMP_FREE(ref->usr_priv_protocol);
|
||||
|
||||
+ if (ref->usr_auth_key_length && ref->usr_auth_key) {
|
||||
+ SNMP_ZERO(ref->usr_auth_key, ref->usr_auth_key_length);
|
||||
+ SNMP_FREE(ref->usr_auth_key);
|
||||
+ }
|
||||
+ if (ref->usr_priv_key_length && ref->usr_priv_key) {
|
||||
+ SNMP_ZERO(ref->usr_priv_key, ref->usr_priv_key_length);
|
||||
+ SNMP_FREE(ref->usr_priv_key);
|
||||
}
|
||||
|
||||
+ SNMP_FREE(ref);
|
||||
} /* end usm_free_usmStateReference() */
|
||||
|
||||
struct usmUser *
|
||||
@@ -3332,6 +3353,7 @@ init_usm(void)
|
||||
def->encode_reverse = usm_secmod_rgenerate_out_msg;
|
||||
def->encode_forward = usm_secmod_generate_out_msg;
|
||||
def->decode = usm_secmod_process_in_msg;
|
||||
+ def->pdu_clone = usm_clone;
|
||||
def->pdu_free_state_ref = usm_free_usmStateReference;
|
||||
def->session_setup = usm_session_init;
|
||||
def->handle_report = usm_handle_report;
|
||||
--
|
||||
1.8.3.1
|
||||
|
||||
@ -1,106 +0,0 @@
|
||||
From 87bd90d04f20dd3f73e3e7e631a442ccd419b9d3 Mon Sep 17 00:00:00 2001
|
||||
From: Bart Van Assche <bvanassche@acm.org>
|
||||
Date: Tue, 13 Aug 2019 20:54:23 -0700
|
||||
Subject: [PATCH] libsnmp: Move the free_securityStateRef() call into
|
||||
snmp_free_pdu()
|
||||
|
||||
This patch fixes a memory leak that was introduced in commit 5f881d3bf245
|
||||
("libsnmp, USM: Introduce a reference count in struct usmStateReference").
|
||||
|
||||
This patch partially reverts commit adc9b71aba91 ("snmpd: Avoid that snmpv3
|
||||
bulkget errors result in a double free").
|
||||
|
||||
See also https://sourceforge.net/p/net-snmp/bugs/2938/.
|
||||
---
|
||||
agent/snmp_agent.c| 6 ------
|
||||
include/net-snmp/pdu_api.h | 2 --
|
||||
snmplib/snmp_api.c| 23 ++---------------------
|
||||
3 files changed, 2 insertions(+), 29 deletions(-)
|
||||
|
||||
diff --git a/agent/snmp_agent.c b/agent/snmp_agent.c
|
||||
index 0a1e263..25350e6 100644
|
||||
--- a/agent/snmp_agent.c
|
||||
+++ b/agent/snmp_agent.c
|
||||
@@ -1605,12 +1605,6 @@ free_agent_snmp_session(netsnmp_agent_session *asp)
|
||||
DEBUGMSGTL(("verbose:asp", "asp %p reqinfo %p freed\n",
|
||||
asp, asp->reqinfo));
|
||||
|
||||
- /* Clean up securityStateRef here to prevent a double free */
|
||||
- if (asp->orig_pdu)
|
||||
- snmp_free_securityStateRef(asp->orig_pdu);
|
||||
- if (asp->pdu)
|
||||
- snmp_free_securityStateRef(asp->pdu);
|
||||
-
|
||||
if (asp->orig_pdu)
|
||||
snmp_free_pdu(asp->orig_pdu);
|
||||
if (asp->pdu)
|
||||
diff --git a/include/net-snmp/pdu_api.h b/include/net-snmp/pdu_api.h
|
||||
index 270aff0..125595d 100644
|
||||
--- a/include/net-snmp/pdu_api.h
|
||||
+++ b/include/net-snmp/pdu_api.h
|
||||
@@ -19,8 +19,6 @@ NETSNMP_IMPORT
|
||||
netsnmp_pdu *snmp_fix_pdu( netsnmp_pdu *pdu, int idx);
|
||||
NETSNMP_IMPORT
|
||||
void snmp_free_pdu( netsnmp_pdu *pdu);
|
||||
-NETSNMP_IMPORT
|
||||
-void snmp_free_securityStateRef( netsnmp_pdu *pdu);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
diff --git a/snmplib/snmp_api.c b/snmplib/snmp_api.c
|
||||
index e14ae6f..3e57a55 100644
|
||||
--- a/snmplib/snmp_api.c
|
||||
+++ b/snmplib/snmp_api.c
|
||||
@@ -4033,17 +4033,6 @@ free_securityStateRef(netsnmp_pdu* pdu)
|
||||
pdu->securityStateRef = NULL;
|
||||
}
|
||||
|
||||
-/*
|
||||
- * This function is here to provide a separate call to
|
||||
- * free the securityStateRef memory. This is needed to prevent
|
||||
- * a double free if this memory is freed in snmp_free_pdu.
|
||||
- */
|
||||
-void
|
||||
-snmp_free_securityStateRef(netsnmp_pdu* pdu)
|
||||
-{
|
||||
- free_securityStateRef(pdu);
|
||||
-}
|
||||
-
|
||||
#define ERROR_STAT_LENGTH 11
|
||||
|
||||
int
|
||||
@@ -5470,6 +5459,8 @@ snmp_free_pdu(netsnmp_pdu *pdu)
|
||||
if (!pdu)
|
||||
return;
|
||||
|
||||
+ free_securityStateRef(pdu);
|
||||
+
|
||||
/*
|
||||
* If the command field is empty, that probably indicates
|
||||
* that this PDU structure has already been freed.
|
||||
@@ -5644,10 +5635,6 @@ _sess_process_packet_parse_pdu(void *sessp, netsnmp_session * sp,
|
||||
}
|
||||
|
||||
if (ret != SNMP_ERR_NOERROR) {
|
||||
- /*
|
||||
- * Call the security model to free any securityStateRef supplied w/ msg.
|
||||
- */
|
||||
- free_securityStateRef(pdu);
|
||||
snmp_free_pdu(pdu);
|
||||
return NULL;
|
||||
}
|
||||
@@ -5819,12 +5806,6 @@ _sess_process_packet_handle_pdu(void *sessp, netsnmp_session * sp,
|
||||
}
|
||||
}
|
||||
|
||||
- /*
|
||||
- * Call USM to free any securityStateRef supplied with the message.
|
||||
- */
|
||||
- if (pdu->command == SNMP_MSG_TRAP2)
|
||||
- free_securityStateRef(pdu);
|
||||
-
|
||||
if (!handled) {
|
||||
if (sp->flags & SNMP_FLAGS_SHARED_SOCKET)
|
||||
return -2;
|
||||
--
|
||||
1.8.3.1
|
||||
@ -1,354 +0,0 @@
|
||||
From 1d8240c3f9ca3137e105a981823fe530544792ed Mon Sep 17 00:00:00 2001
|
||||
From: Bart Van Assche <bvanassche@acm.org>
|
||||
Date: Wed, 22 May 2019 09:56:21 +0200
|
||||
Subject: [PATCH] CHANGES: snmpd: Stop reading and writing the mib_indexes/*
|
||||
files
|
||||
|
||||
https://github.com/net-snmp/net-snmp/4fd9a450444a434a993bc72f7c3486ccce41f602
|
||||
Caching directory contents is something the operating system should do
|
||||
and is not something Net-SNMP should do. Instead of storing a copy of
|
||||
the directory contents in ${tmp_dir}/mib_indexes/${n}, always scan a
|
||||
MIB directory.
|
||||
|
||||
---
|
||||
.gitignore | 1 -
|
||||
include/net-snmp/library/mib.h | 3 -
|
||||
include/net-snmp/library/parse.h | 2 +-
|
||||
snmplib/mib.c | 148 +--------------------------------------
|
||||
snmplib/parse.c | 56 +--------------
|
||||
5 files changed, 4 insertions(+), 206 deletions(-)
|
||||
|
||||
diff --git a/.gitignore b/.gitignore
|
||||
index 2d37bc6..94da568 100644
|
||||
--- a/.gitignore
|
||||
+++ b/.gitignore
|
||||
@@ -75,7 +75,6 @@ Makefile
|
||||
man/*.[1358]
|
||||
man/default_store.3.h
|
||||
man/manaliases
|
||||
-mibs/.index
|
||||
mk/
|
||||
module_tmp_header.h
|
||||
net-snmp-5*
|
||||
diff --git a/include/net-snmp/library/mib.h b/include/net-snmp/library/mib.h
|
||||
index ab36853..3e81634 100644
|
||||
--- a/include/net-snmp/library/mib.h
|
||||
+++ b/include/net-snmp/library/mib.h
|
||||
@@ -124,9 +124,6 @@ SOFTWARE.
|
||||
NETSNMP_IMPORT
|
||||
char *netsnmp_get_mib_directory(void);
|
||||
void netsnmp_fixup_mib_directory(void);
|
||||
- void netsnmp_mibindex_load( void );
|
||||
- char * netsnmp_mibindex_lookup( const char * );
|
||||
- FILE * netsnmp_mibindex_new( const char * );
|
||||
int sprint_realloc_description(u_char ** buf, size_t * buf_len,
|
||||
size_t * out_len, int allow_realloc,
|
||||
oid * objid, size_t objidlen, int width);
|
||||
diff --git a/include/net-snmp/library/parse.h b/include/net-snmp/library/parse.h
|
||||
index ce46ab9..7c33d3f 100644
|
||||
--- a/include/net-snmp/library/parse.h
|
||||
+++ b/include/net-snmp/library/parse.h
|
||||
@@ -201,7 +201,7 @@ SOFTWARE.
|
||||
#endif
|
||||
void netsnmp_init_mib_internals(void);
|
||||
void unload_all_mibs(void);
|
||||
- int add_mibfile(const char*, const char*, FILE *);
|
||||
+ int add_mibfile(const char*, const char*);
|
||||
int which_module(const char *);
|
||||
NETSNMP_IMPORT
|
||||
char *module_name(int, char *);
|
||||
diff --git a/snmplib/mib.c b/snmplib/mib.c
|
||||
index 1c875c0..30d6cde 100644
|
||||
--- a/snmplib/mib.c
|
||||
+++ b/snmplib/mib.c
|
||||
@@ -2717,7 +2717,6 @@ netsnmp_init_mib(void)
|
||||
env_var = strdup(netsnmp_get_mib_directory());
|
||||
if (!env_var)
|
||||
return;
|
||||
- netsnmp_mibindex_load();
|
||||
|
||||
DEBUGMSGTL(("init_mib",
|
||||
"Seen MIBDIRS: Looking in '%s' for mib dirs ...\n",
|
||||
@@ -2737,7 +2736,7 @@ netsnmp_init_mib(void)
|
||||
else
|
||||
entry = strtok_r(env_var, ENV_SEPARATOR, &st);
|
||||
while (entry) {
|
||||
- add_mibfile(entry, NULL, NULL);
|
||||
+ add_mibfile(entry, NULL);
|
||||
entry = strtok_r(NULL, ENV_SEPARATOR, &st);
|
||||
}
|
||||
}
|
||||
@@ -2888,142 +2887,6 @@ init_mib(void)
|
||||
#endif
|
||||
|
||||
|
||||
-/*
|
||||
- * Handle MIB indexes centrally
|
||||
- */
|
||||
-static int _mibindex = 0; /* Last index in use */
|
||||
-static int _mibindex_max = 0; /* Size of index array */
|
||||
-char **_mibindexes = NULL;
|
||||
-
|
||||
-int _mibindex_add( const char *dirname, int i );
|
||||
-void
|
||||
-netsnmp_mibindex_load( void )
|
||||
-{
|
||||
- DIR *dir;
|
||||
- struct dirent *file;
|
||||
- FILE *fp;
|
||||
- char tmpbuf[ 300];
|
||||
- char tmpbuf2[300];
|
||||
- int i;
|
||||
- char *cp;
|
||||
-
|
||||
- /*
|
||||
- * Open the MIB index directory, or create it (empty)
|
||||
- */
|
||||
- snprintf( tmpbuf, sizeof(tmpbuf), "%s/mib_indexes",
|
||||
- get_persistent_directory());
|
||||
- tmpbuf[sizeof(tmpbuf)-1] = 0;
|
||||
- dir = opendir( tmpbuf );
|
||||
- if ( dir == NULL ) {
|
||||
- DEBUGMSGTL(("mibindex", "load: (new)\n"));
|
||||
- mkdirhier( tmpbuf, NETSNMP_AGENT_DIRECTORY_MODE, 0);
|
||||
- return;
|
||||
- }
|
||||
-
|
||||
- /*
|
||||
- * Create a list of which directory each file refers to
|
||||
- */
|
||||
- while ((file = readdir( dir ))) {
|
||||
- if ( !isdigit((unsigned char)(file->d_name[0])))
|
||||
- continue;
|
||||
- i = atoi( file->d_name );
|
||||
-
|
||||
- snprintf( tmpbuf, sizeof(tmpbuf), "%s/mib_indexes/%d",
|
||||
- get_persistent_directory(), i );
|
||||
- tmpbuf[sizeof(tmpbuf)-1] = 0;
|
||||
- fp = fopen( tmpbuf, "r" );
|
||||
- if (!fp)
|
||||
- continue;
|
||||
- cp = fgets( tmpbuf2, sizeof(tmpbuf2), fp );
|
||||
- fclose( fp );
|
||||
- if ( !cp ) {
|
||||
- DEBUGMSGTL(("mibindex", "Empty MIB index (%d)\n", i));
|
||||
- continue;
|
||||
- }
|
||||
- if ( strncmp( tmpbuf2, "DIR ", 4 ) != 0 ) {
|
||||
- DEBUGMSGTL(("mibindex", "Malformed MIB index (%d)\n", i));
|
||||
- continue;
|
||||
- }
|
||||
- tmpbuf2[strlen(tmpbuf2)-1] = 0;
|
||||
- DEBUGMSGTL(("mibindex", "load: (%d) %s\n", i, tmpbuf2));
|
||||
- (void)_mibindex_add( tmpbuf2+4, i ); /* Skip 'DIR ' */
|
||||
- }
|
||||
- closedir( dir );
|
||||
-}
|
||||
-
|
||||
-char *
|
||||
-netsnmp_mibindex_lookup( const char *dirname )
|
||||
-{
|
||||
- int i;
|
||||
- static char tmpbuf[300];
|
||||
-
|
||||
- for (i=0; i<_mibindex; i++) {
|
||||
- if ( _mibindexes[i] &&
|
||||
- strcmp( _mibindexes[i], dirname ) == 0) {
|
||||
- snprintf(tmpbuf, sizeof(tmpbuf), "%s/mib_indexes/%d",
|
||||
- get_persistent_directory(), i);
|
||||
- tmpbuf[sizeof(tmpbuf)-1] = 0;
|
||||
- DEBUGMSGTL(("mibindex", "lookup: %s (%d) %s\n", dirname, i, tmpbuf ));
|
||||
- return tmpbuf;
|
||||
- }
|
||||
- }
|
||||
- DEBUGMSGTL(("mibindex", "lookup: (none)\n"));
|
||||
- return NULL;
|
||||
-}
|
||||
-
|
||||
-int
|
||||
-_mibindex_add( const char *dirname, int i )
|
||||
-{
|
||||
- const int old_mibindex_max = _mibindex_max;
|
||||
-
|
||||
- DEBUGMSGTL(("mibindex", "add: %s (%d)\n", dirname, i ));
|
||||
- if ( i == -1 )
|
||||
- i = _mibindex++;
|
||||
- if ( i >= _mibindex_max ) {
|
||||
- /*
|
||||
- * If the index array is full (or non-existent)
|
||||
- * then expand (or create) it
|
||||
- */
|
||||
- _mibindex_max = i + 10;
|
||||
- _mibindexes = realloc(_mibindexes,
|
||||
- _mibindex_max * sizeof(_mibindexes[0]));
|
||||
- netsnmp_assert(_mibindexes);
|
||||
- memset(_mibindexes + old_mibindex_max, 0,
|
||||
- (_mibindex_max - old_mibindex_max) * sizeof(_mibindexes[0]));
|
||||
- }
|
||||
-
|
||||
- _mibindexes[ i ] = strdup( dirname );
|
||||
- if ( i >= _mibindex )
|
||||
- _mibindex = i+1;
|
||||
-
|
||||
- DEBUGMSGTL(("mibindex", "add: %d/%d/%d\n", i, _mibindex, _mibindex_max ));
|
||||
- return i;
|
||||
-}
|
||||
-
|
||||
-FILE *
|
||||
-netsnmp_mibindex_new( const char *dirname )
|
||||
-{
|
||||
- FILE *fp;
|
||||
- char tmpbuf[300];
|
||||
- char *cp;
|
||||
- int i;
|
||||
-
|
||||
- cp = netsnmp_mibindex_lookup( dirname );
|
||||
- if (!cp) {
|
||||
- i = _mibindex_add( dirname, -1 );
|
||||
- snprintf( tmpbuf, sizeof(tmpbuf), "%s/mib_indexes/%d",
|
||||
- get_persistent_directory(), i );
|
||||
- tmpbuf[sizeof(tmpbuf)-1] = 0;
|
||||
- cp = tmpbuf;
|
||||
- }
|
||||
- DEBUGMSGTL(("mibindex", "new: %s (%s)\n", dirname, cp ));
|
||||
- fp = fopen( cp, "w" );
|
||||
- if (fp)
|
||||
- fprintf( fp, "DIR %s\n", dirname );
|
||||
- return fp;
|
||||
-}
|
||||
-
|
||||
-
|
||||
/**
|
||||
* Unloads all mibs.
|
||||
*/
|
||||
@@ -3038,15 +2901,6 @@ shutdown_mib(void)
|
||||
}
|
||||
tree_head = NULL;
|
||||
Mib = NULL;
|
||||
- if (_mibindexes) {
|
||||
- int i;
|
||||
- for (i = 0; i < _mibindex; ++i)
|
||||
- SNMP_FREE(_mibindexes[i]);
|
||||
- free(_mibindexes);
|
||||
- _mibindex = 0;
|
||||
- _mibindex_max = 0;
|
||||
- _mibindexes = NULL;
|
||||
- }
|
||||
if (Prefix != NULL && Prefix != &Standard_Prefix[0])
|
||||
SNMP_FREE(Prefix);
|
||||
if (Prefix)
|
||||
diff --git a/snmplib/parse.c b/snmplib/parse.c
|
||||
index 7678b35..0639112 100644
|
||||
--- a/snmplib/parse.c
|
||||
+++ b/snmplib/parse.c
|
||||
@@ -607,8 +607,6 @@ static int read_module_replacements(const char *);
|
||||
static int read_import_replacements(const char *,
|
||||
struct module_import *);
|
||||
|
||||
-static void new_module(const char *, const char *);
|
||||
-
|
||||
static struct node *merge_parse_objectid(struct node *, FILE *, char *);
|
||||
static struct index_list *getIndexes(FILE * fp, struct index_list **);
|
||||
static struct varbind_list *getVarbinds(FILE * fp, struct varbind_list **);
|
||||
@@ -4859,7 +4857,7 @@ snmp_get_token(FILE * fp, char *token, int maxtlen)
|
||||
#endif /* NETSNMP_FEATURE_REMOVE_PARSE_GET_TOKEN */
|
||||
|
||||
int
|
||||
-add_mibfile(const char* tmpstr, const char* d_name, FILE *ip )
|
||||
+add_mibfile(const char* tmpstr, const char* d_name)
|
||||
{
|
||||
FILE *fp;
|
||||
char token[MAXTOKEN], token2[MAXTOKEN];
|
||||
@@ -4884,8 +4882,6 @@ add_mibfile(const char* tmpstr, const char* d_name, FILE *ip )
|
||||
*/
|
||||
if (get_token(fp, token2, MAXTOKEN) == DEFINITIONS) {
|
||||
new_module(token, tmpstr);
|
||||
- if (ip)
|
||||
- fprintf(ip, "%s %s\n", token, d_name);
|
||||
fclose(fp);
|
||||
return 0;
|
||||
} else {
|
||||
@@ -4903,62 +4899,16 @@ add_mibfile(const char* tmpstr, const char* d_name, FILE *ip )
|
||||
int
|
||||
add_mibdir(const char *dirname)
|
||||
{
|
||||
- FILE *ip;
|
||||
DIR *dir, *dir2;
|
||||
const char *oldFile = File;
|
||||
struct dirent *file;
|
||||
char tmpstr[300];
|
||||
int count = 0;
|
||||
int fname_len = 0;
|
||||
-#if !(defined(WIN32) || defined(cygwin))
|
||||
- char *token;
|
||||
- char space;
|
||||
- char newline;
|
||||
- struct stat dir_stat, idx_stat;
|
||||
- char tmpstr1[300];
|
||||
-#endif
|
||||
|
||||
DEBUGMSGTL(("parse-mibs", "Scanning directory %s\n", dirname));
|
||||
-#if !(defined(WIN32) || defined(cygwin))
|
||||
- token = netsnmp_mibindex_lookup( dirname );
|
||||
- if (token && stat(token, &idx_stat) == 0 && stat(dirname, &dir_stat) == 0) {
|
||||
- if (dir_stat.st_mtime < idx_stat.st_mtime) {
|
||||
- DEBUGMSGTL(("parse-mibs", "The index is good\n"));
|
||||
- if ((ip = fopen(token, "r")) != NULL) {
|
||||
- fgets(tmpstr, sizeof(tmpstr), ip); /* Skip dir line */
|
||||
- while (fscanf(ip, "%127s%c%299[^\n]%c", token, &space, tmpstr,
|
||||
- &newline) == 4) {
|
||||
-
|
||||
- /*
|
||||
- * If an overflow of the token or tmpstr buffers has been
|
||||
- * found log a message and break out of the while loop,
|
||||
- * thus the rest of the file tokens will be ignored.
|
||||
- */
|
||||
- if (space != ' ' || newline != '\n') {
|
||||
- snmp_log(LOG_ERR,
|
||||
- "add_mibdir: strings scanned in from %s/%s " \
|
||||
- "are too large. count = %d\n ", dirname,
|
||||
- ".index", count);
|
||||
- break;
|
||||
- }
|
||||
-
|
||||
- snprintf(tmpstr1, sizeof(tmpstr1), "%s/%s", dirname, tmpstr);
|
||||
- tmpstr1[ sizeof(tmpstr1)-1 ] = 0;
|
||||
- new_module(token, tmpstr1);
|
||||
- count++;
|
||||
- }
|
||||
- fclose(ip);
|
||||
- return count;
|
||||
- } else
|
||||
- DEBUGMSGTL(("parse-mibs", "Can't read index\n"));
|
||||
- } else
|
||||
- DEBUGMSGTL(("parse-mibs", "Index outdated\n"));
|
||||
- } else
|
||||
- DEBUGMSGTL(("parse-mibs", "No index\n"));
|
||||
-#endif
|
||||
|
||||
if ((dir = opendir(dirname))) {
|
||||
- ip = netsnmp_mibindex_new( dirname );
|
||||
while ((file = readdir(dir))) {
|
||||
/*
|
||||
* Only parse file names that don't begin with a '.'
|
||||
@@ -4979,7 +4929,7 @@ add_mibdir(const char *dirname)
|
||||
*/
|
||||
closedir(dir2);
|
||||
} else {
|
||||
- if ( !add_mibfile( tmpstr, file->d_name, ip ))
|
||||
+ if ( !add_mibfile( tmpstr, file->d_name ))
|
||||
count++;
|
||||
}
|
||||
}
|
||||
@@ -4987,8 +4937,6 @@ add_mibdir(const char *dirname)
|
||||
}
|
||||
File = oldFile;
|
||||
closedir(dir);
|
||||
- if (ip)
|
||||
- fclose(ip);
|
||||
return (count);
|
||||
}
|
||||
else
|
||||
--
|
||||
1.8.3.1
|
||||
|
||||
@ -1,84 +0,0 @@
|
||||
From 77f6c60f57dba0aaea5d8ef1dd94bcd0c8e6d205 Mon Sep 17 00:00:00 2001
|
||||
From: Wes Hardaker <opensource@hardakers.net>
|
||||
Date: Thu, 23 Jul 2020 16:17:27 -0700
|
||||
Subject: [PATCH] make the extend mib read-only by default
|
||||
|
||||
---
|
||||
agent/mibgroup/agent/extend.c | 19 +++++++++++++------
|
||||
1 file changed, 13 insertions(+), 6 deletions(-)
|
||||
|
||||
diff --git a/agent/mibgroup/agent/extend.c b/agent/mibgroup/agent/extend.c
|
||||
index 5f8cedc..7bd2314 100644
|
||||
--- a/agent/mibgroup/agent/extend.c
|
||||
+++ b/agent/mibgroup/agent/extend.c
|
||||
@@ -16,6 +16,13 @@
|
||||
#define SHELLCOMMAND 3
|
||||
#endif
|
||||
|
||||
+/* This mib is potentially dangerous to turn on by default, since it
|
||||
+ * allows arbitrary commands to be set by anyone with SNMP WRITE
|
||||
+ * access to the MIB table. If all of your users are "root" level
|
||||
+ * users, then it may be safe to turn on. */
|
||||
+#define ENABLE_EXTEND_WRITE_ACCESS 0
|
||||
+
|
||||
+
|
||||
netsnmp_feature_require(extract_table_row_data)
|
||||
netsnmp_feature_require(table_data_delete_table)
|
||||
#ifndef NETSNMP_NO_WRITE_SUPPORT
|
||||
@@ -742,7 +749,7 @@ handle_nsExtendConfigTable(netsnmp_mib_handler *handler,
|
||||
*
|
||||
**********/
|
||||
|
||||
-#ifndef NETSNMP_NO_WRITE_SUPPORT
|
||||
+#if !defined(NETSNMP_NO_WRITE_SUPPORT) && ENABLE_EXTEND_WRITE_ACCESS
|
||||
case MODE_SET_RESERVE1:
|
||||
/*
|
||||
* Validate the new assignments
|
||||
@@ -1068,7 +1075,7 @@ handle_nsExtendConfigTable(netsnmp_mib_handler *handler,
|
||||
}
|
||||
}
|
||||
break;
|
||||
-#endif /* !NETSNMP_NO_WRITE_SUPPORT */
|
||||
+#endif /* !NETSNMP_NO_WRITE_SUPPORT and ENABLE_EXTEND_WRITE_ACCESS */
|
||||
|
||||
default:
|
||||
netsnmp_set_request_error(reqinfo, request, SNMP_ERR_GENERR);
|
||||
@@ -1076,7 +1083,7 @@ handle_nsExtendConfigTable(netsnmp_mib_handler *handler,
|
||||
}
|
||||
}
|
||||
|
||||
-#ifndef NETSNMP_NO_WRITE_SUPPORT
|
||||
+#if !defined(NETSNMP_NO_WRITE_SUPPORT) && ENABLE_EXTEND_WRITE_ACCESS
|
||||
/*
|
||||
* If we're marking a given row as active,
|
||||
* then we need to check that it's ready.
|
||||
@@ -1101,7 +1108,7 @@ handle_nsExtendConfigTable(netsnmp_mib_handler *handler,
|
||||
}
|
||||
}
|
||||
}
|
||||
-#endif /* !NETSNMP_NO_WRITE_SUPPORT */
|
||||
+#endif /* !NETSNMP_NO_WRITE_SUPPORT && ENABLE_EXTEND_WRITE_ACCESS */
|
||||
|
||||
return SNMP_ERR_NOERROR;
|
||||
}
|
||||
@@ -1590,7 +1597,7 @@ fixExec2Error(int action,
|
||||
idx = name[name_len-1] -1;
|
||||
exten = &compatability_entries[ idx ];
|
||||
|
||||
-#ifndef NETSNMP_NO_WRITE_SUPPORT
|
||||
+#if !defined(NETSNMP_NO_WRITE_SUPPORT) && ENABLE_EXTEND_WRITE_ACCESS
|
||||
switch (action) {
|
||||
case MODE_SET_RESERVE1:
|
||||
if (var_val_type != ASN_INTEGER) {
|
||||
@@ -1611,7 +1618,7 @@ fixExec2Error(int action,
|
||||
case MODE_SET_COMMIT:
|
||||
netsnmp_cache_check_and_reload( exten->efix_entry->cache );
|
||||
}
|
||||
-#endif /* !NETSNMP_NO_WRITE_SUPPORT */
|
||||
+#endif /* !NETSNMP_NO_WRITE_SUPPORT && ENABLE_EXTEND_WRITE_ACCESS */
|
||||
return SNMP_ERR_NOERROR;
|
||||
}
|
||||
#endif /* USING_UCD_SNMP_EXTENSIBLE_MODULE */
|
||||
--
|
||||
2.23.0
|
||||
|
||||
@ -1,72 +0,0 @@
|
||||
From 79857f794c1d2b17d058b949fc8b30632d8c4e40 Mon Sep 17 00:00:00 2001
|
||||
From: Bart Van Assche <bvanassche@acm.org>
|
||||
Date: Sat, 27 Apr 2019 21:12:55 -0700
|
||||
Subject: [PATCH] libsnmp, ASN parsing: Avoid triggering undefined shift-left
|
||||
behavior
|
||||
|
||||
A quote from https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=7199:
|
||||
|
||||
So this is a fun corner case of asn.1 integer parsing: the C standard says
|
||||
that shifting a negative number left has undefined behavior. The other
|
||||
obvious way to do this is to use the same code on an unsigned long, and
|
||||
then cast to long. The result of a cast to a signed value is
|
||||
implementation-defined. Linus Torvalds' argument on this is that there
|
||||
is no sensible way for the implementation to define it other than "copy
|
||||
the 2's complement bits".
|
||||
|
||||
Avoid triggering all these corner cases by using byte-copying instead of
|
||||
using shift operations.
|
||||
|
||||
Fixes: https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=7199
|
||||
---
|
||||
snmplib/asn1.c | 24 ++++++++++++++++--------
|
||||
1 file changed, 16 insertions(+), 8 deletions(-)
|
||||
|
||||
diff --git a/snmplib/asn1.c b/snmplib/asn1.c
|
||||
index 333870c95..fb672c5d5 100644
|
||||
--- a/snmplib/asn1.c
|
||||
+++ b/snmplib/asn1.c
|
||||
@@ -579,7 +579,11 @@ asn_parse_int(u_char * data,
|
||||
static const char *errpre = "parse int";
|
||||
register u_char *bufp = data;
|
||||
u_long asn_length;
|
||||
- register long value = 0;
|
||||
+ int i;
|
||||
+ union {
|
||||
+ long l;
|
||||
+ unsigned char b[sizeof(long)];
|
||||
+ } value;
|
||||
|
||||
if (NULL == data || NULL == datalength || NULL == type || NULL == intp) {
|
||||
ERROR_MSG("parse int: NULL pointer");
|
||||
@@ -615,19 +619,23 @@ asn_parse_int(u_char * data,
|
||||
}
|
||||
|
||||
*datalength -= (int) asn_length + (bufp - data);
|
||||
- if (*bufp & 0x80)
|
||||
- value = -1; /* integer is negative */
|
||||
|
||||
DEBUGDUMPSETUP("recv", data, bufp - data + asn_length);
|
||||
|
||||
- while (asn_length--)
|
||||
- value = (value << 8) | *bufp++;
|
||||
+ memset(&value.b, *bufp & 0x80 ? 0xff : 0, sizeof(value.b));
|
||||
+#ifdef WORDS_BIGENDIAN
|
||||
+ for (i = sizeof(long) - asn_length; asn_length--; i++)
|
||||
+ value.b[i] = *bufp++;
|
||||
+#else
|
||||
+ for (i = asn_length - 1; asn_length--; i--)
|
||||
+ value.b[i] = *bufp++;
|
||||
+#endif
|
||||
|
||||
- CHECK_OVERFLOW_S(value,1);
|
||||
+ CHECK_OVERFLOW_S(value.l, 1);
|
||||
|
||||
- DEBUGMSG(("dumpv_recv", " Integer:\t%ld (0x%.2lX)\n", value, value));
|
||||
+ DEBUGMSG(("dumpv_recv", " Integer:\t%ld (0x%.2lX)\n", value.l, value.l));
|
||||
|
||||
- *intp = value;
|
||||
+ *intp = value.l;
|
||||
return bufp;
|
||||
}
|
||||
|
||||
60
backport-Python-Fix-snmpwalk-with-UseNumeric-1.patch
Normal file
60
backport-Python-Fix-snmpwalk-with-UseNumeric-1.patch
Normal file
@ -0,0 +1,60 @@
|
||||
From 8c1dad23301692799749d75a3c039b8ae7c07f8e Mon Sep 17 00:00:00 2001
|
||||
From: Bart Van Assche <bvanassche@acm.org>
|
||||
Date: Wed, 9 Jun 2021 14:19:46 -0700
|
||||
Subject: [PATCH] Python: Fix snmpwalk with UseNumeric=1
|
||||
|
||||
Fixes: c744be5ffed6 ("Python: Introduce build_python_varbind()")
|
||||
Fixes: https://github.com/net-snmp/net-snmp/issues/303
|
||||
---
|
||||
python/netsnmp/client_intf.c | 9 ++++-----
|
||||
1 file changed, 4 insertions(+), 5 deletions(-)
|
||||
|
||||
diff --git a/python/netsnmp/client_intf.c b/python/netsnmp/client_intf.c
|
||||
index e5e7372303..94da39fe34 100644
|
||||
--- a/python/netsnmp/client_intf.c
|
||||
+++ b/python/netsnmp/client_intf.c
|
||||
@@ -1316,7 +1316,7 @@ netsnmp_delete_session(PyObject *self, PyObject *args)
|
||||
|
||||
static int build_python_varbind(PyObject *varbind, netsnmp_variable_list *vars,
|
||||
int varlist_ind, int sprintval_flag, int *len,
|
||||
- char **str_buf)
|
||||
+ char **str_buf, int getlabel_flag)
|
||||
{
|
||||
struct tree *tp;
|
||||
int type;
|
||||
@@ -1326,7 +1326,6 @@ static int build_python_varbind(PyObject *varbind, netsnmp_variable_list *vars,
|
||||
int buf_over = 0;
|
||||
const char *tag;
|
||||
const char *iid;
|
||||
- int getlabel_flag = NO_FLAGS;
|
||||
|
||||
if (!PyObject_HasAttrString(varbind, "tag"))
|
||||
return TYPE_OTHER;
|
||||
@@ -1523,7 +1522,7 @@ netsnmp_get_or_getnext(PyObject *self, PyObject *args, int pdu_type,
|
||||
|
||||
varbind = PySequence_GetItem(varlist, varlist_ind);
|
||||
type = build_python_varbind(varbind, vars, varlist_ind, sprintval_flag,
|
||||
- &len, &str_buf);
|
||||
+ &len, &str_buf, getlabel_flag);
|
||||
if (type != TYPE_OTHER) {
|
||||
/* save in return tuple as well */
|
||||
if ((type == SNMP_ENDOFMIBVIEW) ||
|
||||
@@ -1832,7 +1831,7 @@ netsnmp_walk(PyObject *self, PyObject *args)
|
||||
|
||||
varbind = py_netsnmp_construct_varbind();
|
||||
if (varbind && build_python_varbind(varbind, vars, varlist_ind,
|
||||
- sprintval_flag, &len, &str_buf) !=
|
||||
+ sprintval_flag, &len, &str_buf, getlabel_flag) !=
|
||||
TYPE_OTHER) {
|
||||
const int hex = is_hex(str_buf, len);
|
||||
|
||||
@@ -2055,7 +2054,7 @@ netsnmp_getbulk(PyObject *self, PyObject *args)
|
||||
|
||||
varbind = py_netsnmp_construct_varbind();
|
||||
if (varbind && build_python_varbind(varbind, vars, varbind_ind,
|
||||
- sprintval_flag, &len, &str_buf) != TYPE_OTHER) {
|
||||
+ sprintval_flag, &len, &str_buf, getlabel_flag) != TYPE_OTHER) {
|
||||
const int hex = is_hex(str_buf, len);
|
||||
|
||||
/* push varbind onto varbinds */
|
||||
|
||||
@ -1,43 +0,0 @@
|
||||
From e34f0793b641998eb4f9bedb4f7929bb0e3051b8 Mon Sep 17 00:00:00 2001
|
||||
From: Bart Van Assche <bvanassche@acm.org>
|
||||
Date: Sun, 6 Sep 2020 15:13:58 -0700
|
||||
Subject: [PATCH] libsnmp: Allocate the module import list on the heap
|
||||
|
||||
Since that list occupies 8 KiB, allocate it on the heap instead of on the
|
||||
stack.
|
||||
---
|
||||
snmplib/parse.c | 5 ++++-
|
||||
1 file changed, 4 insertions(+), 1 deletion(-)
|
||||
|
||||
diff --git a/snmplib/parse.c b/snmplib/parse.c
|
||||
index 27b37a1..e1609cc 100644
|
||||
--- a/snmplib/parse.c
|
||||
+++ b/snmplib/parse.c
|
||||
@@ -3637,13 +3637,15 @@ parse_imports(FILE * fp)
|
||||
char token[MAXTOKEN];
|
||||
char modbuf[256];
|
||||
#define MAX_IMPORTS 512
|
||||
- struct module_import import_list[MAX_IMPORTS];
|
||||
+ struct module_import *import_list;
|
||||
int this_module;
|
||||
struct module *mp;
|
||||
|
||||
int import_count = 0; /* Total number of imported descriptors */
|
||||
int i = 0, old_i; /* index of first import from each module */
|
||||
|
||||
+ import_list = malloc(MAX_IMPORTS * sizeof(*import_list));
|
||||
+
|
||||
type = get_token(fp, token, MAXTOKEN);
|
||||
|
||||
/*
|
||||
@@ -3732,6 +3734,7 @@ parse_imports(FILE * fp)
|
||||
print_module_not_found(module_name(current_module, modbuf));
|
||||
|
||||
out:
|
||||
+ free(import_list);
|
||||
return;
|
||||
}
|
||||
|
||||
--
|
||||
1.8.3.1
|
||||
|
||||
@ -1,30 +0,0 @@
|
||||
From 893b9baa6ae81a877e76842c29a637eeb2cbd0e2 Mon Sep 17 00:00:00 2001
|
||||
From: =?UTF-8?q?Guido=20J=C3=A4kel?= <g.jaekel@dnb.de>
|
||||
Date: Thu, 3 Sep 2020 17:03:33 +0200
|
||||
Subject: [PATCH] libsnmp: Increase MAX_IMPORTS
|
||||
|
||||
Today, I stepped into an well-known old issue
|
||||
(https://sourceforge.net/p/net-snmp/mailman/message/16927159/) using MIBs
|
||||
for a CISCO device.
|
||||
|
||||
[bvanassche: edited commit message]
|
||||
---
|
||||
snmplib/parse.c | 2 +-
|
||||
1 file changed, 1 insertion(+), 1 deletion(-)
|
||||
|
||||
diff --git a/snmplib/parse.c b/snmplib/parse.c
|
||||
index ac5a36d..96588a4 100644
|
||||
--- a/snmplib/parse.c
|
||||
+++ b/snmplib/parse.c
|
||||
@@ -3636,7 +3636,7 @@ parse_imports(FILE * fp)
|
||||
register int type;
|
||||
char token[MAXTOKEN];
|
||||
char modbuf[256];
|
||||
-#define MAX_IMPORTS 256
|
||||
+#define MAX_IMPORTS 512
|
||||
struct module_import import_list[MAX_IMPORTS];
|
||||
int this_module;
|
||||
struct module *mp;
|
||||
--
|
||||
1.8.3.1
|
||||
|
||||
@ -1,77 +0,0 @@
|
||||
From ed4c8e85cb44e84ada5b8d2ff58e903de7ede737 Mon Sep 17 00:00:00 2001
|
||||
From: Bart Van Assche <bvanassche@acm.org>
|
||||
Date: Sun, 6 Sep 2020 15:12:48 -0700
|
||||
Subject: [PATCH] libsnmp: Rework parse_imports()
|
||||
|
||||
Do not cast pointers passed to free(). Reduce the number of return
|
||||
statements in this function to one. Surround multiline statements with
|
||||
braces.
|
||||
---
|
||||
snmplib/parse.c | 17 ++++++++++-------
|
||||
1 file changed, 10 insertions(+), 7 deletions(-)
|
||||
|
||||
diff --git a/snmplib/parse.c b/snmplib/parse.c
|
||||
index 96588a4..27b37a1 100644
|
||||
--- a/snmplib/parse.c
|
||||
+++ b/snmplib/parse.c
|
||||
@@ -3656,7 +3656,7 @@ parse_imports(FILE * fp)
|
||||
do {
|
||||
type = get_token(fp, token, MAXTOKEN);
|
||||
} while (type != SEMI && type != ENDOFFILE);
|
||||
- return;
|
||||
+ goto out;
|
||||
}
|
||||
import_list[import_count++].label = strdup(token);
|
||||
} else if (type == FROM) {
|
||||
@@ -3693,10 +3693,10 @@ parse_imports(FILE * fp)
|
||||
* Save the import information
|
||||
* in the global module table
|
||||
*/
|
||||
- for (mp = module_head; mp; mp = mp->next)
|
||||
+ for (mp = module_head; mp; mp = mp->next) {
|
||||
if (mp->modid == current_module) {
|
||||
if (import_count == 0)
|
||||
- return;
|
||||
+ goto out;
|
||||
if (mp->imports && (mp->imports != root_imports)) {
|
||||
/*
|
||||
* this can happen if all modules are in one source file.
|
||||
@@ -3706,14 +3706,14 @@ parse_imports(FILE * fp)
|
||||
"#### freeing Module %d '%s' %d\n",
|
||||
mp->modid, mp->imports[i].label,
|
||||
mp->imports[i].modid));
|
||||
- free((char *) mp->imports[i].label);
|
||||
+ free(mp->imports[i].label);
|
||||
}
|
||||
- free((char *) mp->imports);
|
||||
+ free(mp->imports);
|
||||
}
|
||||
mp->imports = (struct module_import *)
|
||||
calloc(import_count, sizeof(struct module_import));
|
||||
if (mp->imports == NULL)
|
||||
- return;
|
||||
+ goto out;
|
||||
for (i = 0; i < import_count; ++i) {
|
||||
mp->imports[i].label = import_list[i].label;
|
||||
mp->imports[i].modid = import_list[i].modid;
|
||||
@@ -3722,13 +3722,16 @@ parse_imports(FILE * fp)
|
||||
mp->imports[i].label, mp->imports[i].modid));
|
||||
}
|
||||
mp->no_imports = import_count;
|
||||
- return;
|
||||
+ goto out;
|
||||
}
|
||||
+ }
|
||||
|
||||
/*
|
||||
* Shouldn't get this far
|
||||
*/
|
||||
print_module_not_found(module_name(current_module, modbuf));
|
||||
+
|
||||
+out:
|
||||
return;
|
||||
}
|
||||
|
||||
--
|
||||
1.8.3.1
|
||||
|
||||
14
backport-net-snmp-5.7.3-iterator-fix.patch
Normal file
14
backport-net-snmp-5.7.3-iterator-fix.patch
Normal file
@ -0,0 +1,14 @@
|
||||
diff -urNp old/agent/mibgroup/host/data_access/swrun.c new/agent/mibgroup/host/data_access/swrun.c
|
||||
--- old/agent/mibgroup/host/data_access/swrun.c 2017-07-18 09:44:00.626109526 +0200
|
||||
+++ new/agent/mibgroup/host/data_access/swrun.c 2017-07-19 15:27:50.452255836 +0200
|
||||
@@ -102,6 +102,10 @@ swrun_count_processes_by_name( char *nam
|
||||
return 0; /* or -1 */
|
||||
|
||||
it = CONTAINER_ITERATOR( swrun_container );
|
||||
+ if((entry = (netsnmp_swrun_entry*)ITERATOR_FIRST( it )) != NULL) {
|
||||
+ if (0 == strcmp( entry->hrSWRunName, name ))
|
||||
+ i++;
|
||||
+ }
|
||||
while ((entry = (netsnmp_swrun_entry*)ITERATOR_NEXT( it )) != NULL) {
|
||||
if (0 == strcmp( entry->hrSWRunName, name ))
|
||||
i++;
|
||||
11
backport-net-snmp-5.8-duplicate-ipAddress.patch
Normal file
11
backport-net-snmp-5.8-duplicate-ipAddress.patch
Normal file
@ -0,0 +1,11 @@
|
||||
diff -urNp a/agent/mibgroup/ip-mib/data_access/ipaddress_common.c b/agent/mibgroup/ip-mib/data_access/ipaddress_common.c
|
||||
--- a/agent/mibgroup/ip-mib/data_access/ipaddress_common.c 2020-06-10 13:27:03.213904398 +0200
|
||||
+++ b/agent/mibgroup/ip-mib/data_access/ipaddress_common.c 2020-06-10 13:28:41.025863050 +0200
|
||||
@@ -121,6 +121,7 @@ _remove_duplicates(netsnmp_container *co
|
||||
for (entry = ITERATOR_FIRST(it); entry; entry = ITERATOR_NEXT(it)) {
|
||||
if (prev_entry && _access_ipaddress_entry_compare_addr(prev_entry, entry) == 0) {
|
||||
/* 'entry' is duplicate of the previous one -> delete it */
|
||||
+ NETSNMP_LOGONCE((LOG_ERR, "Duplicate IPv4 address detected, some interfaces may not be visible in IP-MIB\n"));
|
||||
netsnmp_access_ipaddress_entry_free(entry);
|
||||
} else {
|
||||
CONTAINER_INSERT(ret, entry);
|
||||
12
backport-net-snmp-5.8-expand-SNMPCONFPATH.patch
Normal file
12
backport-net-snmp-5.8-expand-SNMPCONFPATH.patch
Normal file
@ -0,0 +1,12 @@
|
||||
diff -ruNp a/snmplib/read_config.c b/snmplib/read_config.c
|
||||
--- a/snmplib/read_config.c 2020-06-10 09:51:57.184786510 +0200
|
||||
+++ b/snmplib/read_config.c 2020-06-10 09:53:13.257507112 +0200
|
||||
@@ -1642,7 +1642,7 @@ snmp_save_persistent(const char *type)
|
||||
* save a warning header to the top of the new file
|
||||
*/
|
||||
snprintf(fileold, sizeof(fileold),
|
||||
- "%s%s# Please save normal configuration tokens for %s in SNMPCONFPATH/%s.conf.\n# Only \"createUser\" tokens should be placed here by %s administrators.\n%s",
|
||||
+ "%s%s# Please save normal configuration tokens for %s in /etc/snmp/%s.conf.\n# Only \"createUser\" tokens should be placed here by %s administrators.\n%s",
|
||||
"#\n# net-snmp (or ucd-snmp) persistent data file.\n#\n############################################################################\n# STOP STOP STOP STOP STOP STOP STOP STOP STOP \n",
|
||||
"#\n# **** DO NOT EDIT THIS FILE ****\n#\n# STOP STOP STOP STOP STOP STOP STOP STOP STOP \n############################################################################\n#\n# DO NOT STORE CONFIGURATION ENTRIES HERE.\n",
|
||||
type, type, type,
|
||||
82
backport-net-snmp-5.8-ipAddress-faster-load.patch
Normal file
82
backport-net-snmp-5.8-ipAddress-faster-load.patch
Normal file
@ -0,0 +1,82 @@
|
||||
diff -urNp a/agent/mibgroup/mibII/ipAddr.c b/agent/mibgroup/mibII/ipAddr.c
|
||||
--- a/agent/mibgroup/mibII/ipAddr.c 2020-06-10 14:14:30.113696471 +0200
|
||||
+++ b/agent/mibgroup/mibII/ipAddr.c 2020-06-10 14:27:15.345354018 +0200
|
||||
@@ -495,14 +495,16 @@ Address_Scan_Next(Index, Retin_ifaddr)
|
||||
}
|
||||
|
||||
#elif defined(linux)
|
||||
+#include <errno.h>
|
||||
static struct ifreq *ifr;
|
||||
static int ifr_counter;
|
||||
|
||||
static void
|
||||
Address_Scan_Init(void)
|
||||
{
|
||||
- int num_interfaces = 0;
|
||||
+ int i;
|
||||
int fd;
|
||||
+ int lastlen = 0;
|
||||
|
||||
/* get info about all interfaces */
|
||||
|
||||
@@ -510,28 +512,45 @@ Address_Scan_Init(void)
|
||||
SNMP_FREE(ifc.ifc_buf);
|
||||
ifr_counter = 0;
|
||||
|
||||
- do
|
||||
- {
|
||||
if ((fd = socket(AF_INET, SOCK_DGRAM, 0)) < 0)
|
||||
{
|
||||
DEBUGMSGTL(("snmpd", "socket open failure in Address_Scan_Init\n"));
|
||||
return;
|
||||
}
|
||||
- num_interfaces += 16;
|
||||
|
||||
- ifc.ifc_len = sizeof(struct ifreq) * num_interfaces;
|
||||
- ifc.ifc_buf = (char*) realloc(ifc.ifc_buf, ifc.ifc_len);
|
||||
-
|
||||
- if (ioctl(fd, SIOCGIFCONF, &ifc) < 0)
|
||||
- {
|
||||
- ifr=NULL;
|
||||
- close(fd);
|
||||
- return;
|
||||
- }
|
||||
- close(fd);
|
||||
+ /*
|
||||
+ * Cope with lots of interfaces and brokenness of ioctl SIOCGIFCONF
|
||||
+ * on some platforms; see W. R. Stevens, ``Unix Network Programming
|
||||
+ * Volume I'', p.435...
|
||||
+ */
|
||||
+
|
||||
+ for (i = 8;; i *= 2) {
|
||||
+ ifc.ifc_len = sizeof(struct ifreq) * i;
|
||||
+ ifc.ifc_req = calloc(i, sizeof(struct ifreq));
|
||||
+
|
||||
+ if (ioctl(fd, SIOCGIFCONF, &ifc) < 0) {
|
||||
+ if (errno != EINVAL || lastlen != 0) {
|
||||
+ /*
|
||||
+ * Something has gone genuinely wrong...
|
||||
+ */
|
||||
+ snmp_log(LOG_ERR, "bad rc from ioctl, errno %d", errno);
|
||||
+ SNMP_FREE(ifc.ifc_buf);
|
||||
+ close(fd);
|
||||
+ return;
|
||||
+ }
|
||||
+ } else {
|
||||
+ if (ifc.ifc_len == lastlen) {
|
||||
+ /*
|
||||
+ * The length is the same as the last time; we're done...
|
||||
+ */
|
||||
+ break;
|
||||
+ }
|
||||
+ lastlen = ifc.ifc_len;
|
||||
+ }
|
||||
+ free(ifc.ifc_buf); /* no SNMP_FREE, getting ready to reassign */
|
||||
}
|
||||
- while (ifc.ifc_len >= (sizeof(struct ifreq) * num_interfaces));
|
||||
-
|
||||
+
|
||||
+ close(fd);
|
||||
ifr = ifc.ifc_req;
|
||||
}
|
||||
|
||||
36
backport-net-snmp-5.8-man-page.patch
Normal file
36
backport-net-snmp-5.8-man-page.patch
Normal file
@ -0,0 +1,36 @@
|
||||
diff -urNp a/man/net-snmp-create-v3-user.1.def b/man/net-snmp-create-v3-user.1.def
|
||||
--- a/man/net-snmp-create-v3-user.1.def 2020-06-10 13:43:18.443070961 +0200
|
||||
+++ b/man/net-snmp-create-v3-user.1.def 2020-06-10 13:49:25.975363441 +0200
|
||||
@@ -3,7 +3,7 @@
|
||||
net-snmp-create-v3-user \- create a SNMPv3 user in net-snmp configuration file
|
||||
.SH SYNOPSIS
|
||||
.PP
|
||||
-.B net-snmp-create-v3-user [-ro] [-a authpass] [-x privpass] [-X DES|AES]
|
||||
+.B net-snmp-create-v3-user [-ro] [-A authpass] [-a MD5|SHA] [-X privpass] [-x DES|AES]
|
||||
.B [username]
|
||||
.SH DESCRIPTION
|
||||
.PP
|
||||
@@ -16,13 +16,16 @@ new user in net-snmp configuration file
|
||||
displays the net-snmp version number
|
||||
.TP
|
||||
\fB\-ro\fR
|
||||
-create an user with read-only permissions
|
||||
+creates a user with read-only permissions
|
||||
.TP
|
||||
-\fB\-a authpass\fR
|
||||
-specify authentication password
|
||||
+\fB\-A authpass\fR
|
||||
+specifies the authentication password
|
||||
.TP
|
||||
-\fB\-x privpass\fR
|
||||
-specify encryption password
|
||||
+\fB\-a MD5|SHA\fR
|
||||
+specifies the authentication password hashing algorithm
|
||||
.TP
|
||||
-\fB\-X DES|AES\fR
|
||||
-specify encryption algorithm
|
||||
+\fB\-X privpass\fR
|
||||
+specifies the encryption password
|
||||
+.TP
|
||||
+\fB\-x DES|AES\fR
|
||||
+specifies the encryption algorithm
|
||||
26
backport-net-snmp-5.8-rpm-memory-leak.patch
Normal file
26
backport-net-snmp-5.8-rpm-memory-leak.patch
Normal file
@ -0,0 +1,26 @@
|
||||
diff -urNp a/agent/mibgroup/host/data_access/swinst_rpm.c b/agent/mibgroup/host/data_access/swinst_rpm.c
|
||||
--- a/agent/mibgroup/host/data_access/swinst_rpm.c 2020-06-10 14:32:43.330486233 +0200
|
||||
+++ b/agent/mibgroup/host/data_access/swinst_rpm.c 2020-06-10 14:35:46.672298741 +0200
|
||||
@@ -75,6 +75,9 @@ netsnmp_swinst_arch_init(void)
|
||||
snprintf( pkg_directory, SNMP_MAXPATH, "%s/Packages", dbpath );
|
||||
SNMP_FREE(rpmdbpath);
|
||||
dbpath = NULL;
|
||||
+#ifdef HAVE_RPMGETPATH
|
||||
+ rpmFreeRpmrc();
|
||||
+#endif
|
||||
if (-1 == stat( pkg_directory, &stat_buf )) {
|
||||
snmp_log(LOG_ERR, "Can't find directory of RPM packages");
|
||||
pkg_directory[0] = '\0';
|
||||
diff -urNp a/agent/mibgroup/host/hr_swinst.c b/agent/mibgroup/host/hr_swinst.c
|
||||
--- a/agent/mibgroup/host/hr_swinst.c 2020-06-10 14:32:43.325486184 +0200
|
||||
+++ b/agent/mibgroup/host/hr_swinst.c 2020-06-10 14:36:44.423872418 +0200
|
||||
@@ -231,6 +231,9 @@ init_hr_swinst(void)
|
||||
snprintf(path, sizeof(path), "%s/packages.rpm", swi->swi_dbpath);
|
||||
path[ sizeof(path)-1 ] = 0;
|
||||
swi->swi_directory = strdup(path);
|
||||
+#ifdef HAVE_RPMGETPATH
|
||||
+ rpmFreeRpmrc();
|
||||
+#endif
|
||||
}
|
||||
#else
|
||||
# ifdef _PATH_HRSW_directory
|
||||
18
backport-net-snmp-5.9-aes-config.patch
Normal file
18
backport-net-snmp-5.9-aes-config.patch
Normal file
@ -0,0 +1,18 @@
|
||||
diff --git a/net-snmp-create-v3-user.in b/net-snmp-create-v3-user.in
|
||||
index afd6fa4..07c26fe 100644
|
||||
--- a/net-snmp-create-v3-user.in
|
||||
+++ b/net-snmp-create-v3-user.in
|
||||
@@ -58,11 +58,11 @@ case $1 in
|
||||
exit 1
|
||||
fi
|
||||
case $1 in
|
||||
- DES|AES|AES128)
|
||||
+ DES|AES|AES128|AES192|AES256)
|
||||
Xalgorithm=$1
|
||||
shift
|
||||
;;
|
||||
- des|aes|aes128)
|
||||
+ des|aes|aes128|aes192|aes256)
|
||||
Xalgorithm=$(echo "$1" | tr a-z A-Z)
|
||||
shift
|
||||
;;
|
||||
46
backport-net-snmp-5.9-autofs-skip.patch
Normal file
46
backport-net-snmp-5.9-autofs-skip.patch
Normal file
@ -0,0 +1,46 @@
|
||||
diff --git a/agent/mibgroup/host/hr_filesys.c b/agent/mibgroup/host/hr_filesys.c
|
||||
index 4f78df3..fd25b3f 100644
|
||||
--- a/agent/mibgroup/host/hr_filesys.c
|
||||
+++ b/agent/mibgroup/host/hr_filesys.c
|
||||
@@ -704,6 +704,7 @@ static const char *HRFS_ignores[] = {
|
||||
"shm",
|
||||
"sockfs",
|
||||
"sysfs",
|
||||
+ "tmpfs",
|
||||
"usbdevfs",
|
||||
"usbfs",
|
||||
#endif
|
||||
diff --git a/agent/mibgroup/host/hr_storage.c b/agent/mibgroup/host/hr_storage.c
|
||||
index 6b459ec..f7a376b 100644
|
||||
--- a/agent/mibgroup/host/hr_storage.c
|
||||
+++ b/agent/mibgroup/host/hr_storage.c
|
||||
@@ -540,9 +540,10 @@ really_try_next:
|
||||
|
||||
store_idx = name[ HRSTORE_ENTRY_NAME_LENGTH ];
|
||||
if (store_idx > NETSNMP_MEM_TYPE_MAX ) {
|
||||
- if ( netsnmp_ds_get_boolean(NETSNMP_DS_APPLICATION_ID,
|
||||
+ if ( (netsnmp_ds_get_boolean(NETSNMP_DS_APPLICATION_ID,
|
||||
NETSNMP_DS_AGENT_SKIPNFSINHOSTRESOURCES) &&
|
||||
- Check_HR_FileSys_NFS())
|
||||
+ Check_HR_FileSys_NFS()) ||
|
||||
+ Check_HR_FileSys_AutoFs())
|
||||
return NULL; /* or goto try_next; */
|
||||
if (Check_HR_FileSys_AutoFs())
|
||||
return NULL;
|
||||
diff --git a/agent/mibgroup/host/hrh_storage.c b/agent/mibgroup/host/hrh_storage.c
|
||||
index 8967d35..9bf2659 100644
|
||||
--- a/agent/mibgroup/host/hrh_storage.c
|
||||
+++ b/agent/mibgroup/host/hrh_storage.c
|
||||
@@ -366,9 +366,10 @@ really_try_next:
|
||||
store_idx = name[ HRSTORE_ENTRY_NAME_LENGTH ];
|
||||
if (HRFS_entry &&
|
||||
store_idx > NETSNMP_MEM_TYPE_MAX &&
|
||||
- netsnmp_ds_get_boolean(NETSNMP_DS_APPLICATION_ID,
|
||||
+ ((netsnmp_ds_get_boolean(NETSNMP_DS_APPLICATION_ID,
|
||||
NETSNMP_DS_AGENT_SKIPNFSINHOSTRESOURCES) &&
|
||||
- Check_HR_FileSys_NFS())
|
||||
+ Check_HR_FileSys_NFS()) ||
|
||||
+ Check_HR_FileSys_AutoFs()))
|
||||
return NULL;
|
||||
if (HRFS_entry && Check_HR_FileSys_AutoFs())
|
||||
return NULL;
|
||||
36
backport-net-snmp-5.9-cflags.patch
Normal file
36
backport-net-snmp-5.9-cflags.patch
Normal file
@ -0,0 +1,36 @@
|
||||
diff -urNp a/net-snmp-config.in b/net-snmp-config.in
|
||||
--- a/net-snmp-config.in 2018-07-18 13:43:12.264426052 +0200
|
||||
+++ b/net-snmp-config.in 2018-07-18 13:52:06.917089518 +0200
|
||||
@@ -140,10 +140,10 @@ else
|
||||
;;
|
||||
#################################################### compile
|
||||
--base-cflags)
|
||||
- echo @CFLAGS@ @CPPFLAGS@ -I${NSC_INCLUDEDIR}
|
||||
+ echo -I${NSC_INCLUDEDIR}
|
||||
;;
|
||||
--cflags|--cf*)
|
||||
- echo @CFLAGS@ @DEVFLAGS@ @CPPFLAGS@ -I. -I${NSC_INCLUDEDIR}
|
||||
+ echo @DEVFLAGS@ -I. -I${NSC_INCLUDEDIR}
|
||||
;;
|
||||
--srcdir)
|
||||
echo $NSC_SRCDIR
|
||||
diff -urNp a/perl/Makefile.PL b/perl/Makefile.PL
|
||||
--- a/perl/Makefile.PL 2020-08-26 08:32:52.498909823 +0200
|
||||
+++ b/perl/Makefile.PL 2020-08-26 09:30:45.584951552 +0200
|
||||
@@ -1,3 +1,4 @@
|
||||
+use lib '.';
|
||||
use strict;
|
||||
use warnings;
|
||||
use ExtUtils::MakeMaker;
|
||||
diff -urNp a/perl/MakefileSubs.pm b/perl/MakefileSubs.pm
|
||||
--- a/perl/MakefileSubs.pm 2020-08-26 08:32:52.498909823 +0200
|
||||
+++ b/perl/MakefileSubs.pm 2020-08-26 08:36:44.097218448 +0200
|
||||
@@ -116,7 +116,7 @@ sub AddCommonParams {
|
||||
append($Params->{'CCFLAGS'}, $cflags);
|
||||
append($Params->{'CCFLAGS'}, $Config{'ccflags'});
|
||||
# Suppress known Perl header shortcomings.
|
||||
- $Params->{'CCFLAGS'} =~ s/ -W(cast-qual|write-strings)//g;
|
||||
+ $Params->{'CCFLAGS'} =~ s/ -W(inline|strict-prototypes|write-strings|cast-qual|no-char-subscripts)//g;
|
||||
append($Params->{'CCFLAGS'}, '-Wformat');
|
||||
}
|
||||
}
|
||||
22
backport-net-snmp-5.9-coverity.patch
Normal file
22
backport-net-snmp-5.9-coverity.patch
Normal file
@ -0,0 +1,22 @@
|
||||
diff --git a/agent/mibgroup/disman/event/mteTrigger.c b/agent/mibgroup/disman/event/mteTrigger.c
|
||||
index e9a8831..5a1d8e7 100644
|
||||
--- a/agent/mibgroup/disman/event/mteTrigger.c
|
||||
+++ b/agent/mibgroup/disman/event/mteTrigger.c
|
||||
@@ -1012,7 +1012,7 @@ mteTrigger_run( unsigned int reg, void *clientarg)
|
||||
* Similarly, if no fallEvent is configured,
|
||||
* there's no point in trying to fire it either.
|
||||
*/
|
||||
- if (entry->mteTThRiseEvent[0] != '\0' ) {
|
||||
+ if (entry->mteTThFallEvent[0] != '\0' ) {
|
||||
entry->mteTriggerXOwner = entry->mteTThObjOwner;
|
||||
entry->mteTriggerXObjects = entry->mteTThObjects;
|
||||
entry->mteTriggerFired = vp1;
|
||||
@@ -1105,7 +1105,7 @@ mteTrigger_run( unsigned int reg, void *clientarg)
|
||||
* Similarly, if no fallEvent is configured,
|
||||
* there's no point in trying to fire it either.
|
||||
*/
|
||||
- if (entry->mteTThDRiseEvent[0] != '\0' ) {
|
||||
+ if (entry->mteTThDFallEvent[0] != '\0' ) {
|
||||
entry->mteTriggerXOwner = entry->mteTThObjOwner;
|
||||
entry->mteTriggerXObjects = entry->mteTThObjects;
|
||||
entry->mteTriggerFired = vp1;
|
||||
24
backport-net-snmp-5.9-dir-fix.patch
Normal file
24
backport-net-snmp-5.9-dir-fix.patch
Normal file
@ -0,0 +1,24 @@
|
||||
diff --git a/net-snmp-create-v3-user.in b/net-snmp-create-v3-user.in
|
||||
index 452c269..afd6fa4 100644
|
||||
--- a/net-snmp-create-v3-user.in
|
||||
+++ b/net-snmp-create-v3-user.in
|
||||
@@ -16,6 +16,10 @@ Xalgorithm="DES"
|
||||
token=rwuser
|
||||
|
||||
while test "x$done" = "x" -a "x$1" != "x" -a "x$usage" != "xyes"; do
|
||||
+case "$1" in
|
||||
+ -*=*) optarg=`echo "$1" | sed 's/[-_a-zA-Z0-9]*=//'` ;;
|
||||
+ *) optarg= ;;
|
||||
+esac
|
||||
|
||||
unset shifted
|
||||
case $1 in
|
||||
@@ -136,7 +140,7 @@ fi
|
||||
echo "$line" >> "$outfile"
|
||||
# Avoid that configure complains that this script ignores @datarootdir@
|
||||
echo "@datarootdir@" >/dev/null
|
||||
-outfile="@datadir@/snmp/snmpd.conf"
|
||||
+outfile="/etc/snmp/snmpd.conf"
|
||||
line="$token $user"
|
||||
echo "adding the following line to $outfile:"
|
||||
echo " $line"
|
||||
179
backport-net-snmp-5.9-dskTable-dynamic.patch
Normal file
179
backport-net-snmp-5.9-dskTable-dynamic.patch
Normal file
@ -0,0 +1,179 @@
|
||||
diff -urNp a/agent/mibgroup/ucd-snmp/disk.c b/agent/mibgroup/ucd-snmp/disk.c
|
||||
--- a/agent/mibgroup/ucd-snmp/disk.c 2021-05-26 08:56:39.678900275 +0200
|
||||
+++ b/agent/mibgroup/ucd-snmp/disk.c 2021-05-26 09:09:32.308731157 +0200
|
||||
@@ -153,9 +153,10 @@ static void disk_free_config(void)
|
||||
static void disk_parse_config(const char *, char *);
|
||||
static void disk_parse_config_all(const char *, char *);
|
||||
#if HAVE_FSTAB_H || HAVE_GETMNTENT || HAVE_STATFS
|
||||
-static void find_and_add_allDisks(int minpercent);
|
||||
+static void refresh_disk_table(int addNewDisks, int minpercent);
|
||||
static void add_device(char *path, char *device,
|
||||
- int minspace, int minpercent, int override);
|
||||
+ int minspace, int minpercent, int addNewDisks,
|
||||
+ int override);
|
||||
static void modify_disk_parameters(int index, int minspace,
|
||||
int minpercent);
|
||||
static int disk_exists(char *path);
|
||||
@@ -167,6 +168,7 @@ struct diskpart {
|
||||
char path[STRMAX];
|
||||
int minimumspace;
|
||||
int minpercent;
|
||||
+ int alive;
|
||||
};
|
||||
|
||||
#define MAX_INT_32 0x7fffffff
|
||||
@@ -174,6 +176,7 @@ struct diskpart {
|
||||
|
||||
unsigned int numdisks;
|
||||
int allDisksIncluded = 0;
|
||||
+int allDisksMinPercent = 0;
|
||||
unsigned int maxdisks = 0;
|
||||
struct diskpart *disks;
|
||||
|
||||
@@ -238,6 +241,7 @@ init_disk(void)
|
||||
disk_free_config,
|
||||
"minpercent%");
|
||||
allDisksIncluded = 0;
|
||||
+ allDisksMinPercent = 0;
|
||||
}
|
||||
|
||||
static void
|
||||
@@ -253,6 +257,7 @@ disk_free_config(void)
|
||||
disks[i].minpercent = -1;
|
||||
}
|
||||
allDisksIncluded = 0;
|
||||
+ allDisksMinPercent = 0;
|
||||
}
|
||||
|
||||
static void
|
||||
@@ -313,7 +318,7 @@ disk_parse_config(const char *token, cha
|
||||
* check if the disk already exists, if so then modify its
|
||||
* parameters. if it does not exist then add it
|
||||
*/
|
||||
- add_device(path, find_device(path), minspace, minpercent, 1);
|
||||
+ add_device(path, find_device(path), minspace, minpercent, 1, 1);
|
||||
#endif /* HAVE_FSTAB_H || HAVE_GETMNTENT || HAVE_STATFS */
|
||||
}
|
||||
|
||||
@@ -372,7 +377,7 @@ disk_parse_config_all(const char *token,
|
||||
|
||||
#if HAVE_FSTAB_H || HAVE_GETMNTENT || HAVE_STATFS
|
||||
static void
|
||||
-add_device(char *path, char *device, int minspace, int minpercent, int override)
|
||||
+add_device(char *path, char *device, int minspace, int minpercent, int addNewDisks, int override)
|
||||
{
|
||||
int index;
|
||||
|
||||
@@ -402,10 +407,16 @@ add_device(char *path, char *device, int
|
||||
}
|
||||
|
||||
index = disk_exists(path);
|
||||
- if((index != -1) && (index < maxdisks) && (override==1)) {
|
||||
- modify_disk_parameters(index, minspace, minpercent);
|
||||
+ if((index != -1) && (index < maxdisks)) {
|
||||
+ /* the path is already in the table */
|
||||
+ disks[index].alive = 1;
|
||||
+ /* -> update its device */
|
||||
+ strlcpy(disks[index].device, device, sizeof(disks[index].device));
|
||||
+ if (override == 1) {
|
||||
+ modify_disk_parameters(index, minspace, minpercent);
|
||||
+ }
|
||||
}
|
||||
- else if(index == -1){
|
||||
+ else if(index == -1 && addNewDisks){
|
||||
/* add if and only if the device was found */
|
||||
if(device[0] != 0) {
|
||||
/* The following buffers are cleared above, no need to add '\0' */
|
||||
@@ -413,6 +424,7 @@ add_device(char *path, char *device, int
|
||||
strlcpy(disks[numdisks].device, device, sizeof(disks[numdisks].device));
|
||||
disks[numdisks].minimumspace = minspace;
|
||||
disks[numdisks].minpercent = minpercent;
|
||||
+ disks[numdisks].alive = 1;
|
||||
numdisks++;
|
||||
}
|
||||
else {
|
||||
@@ -420,6 +432,7 @@ add_device(char *path, char *device, int
|
||||
disks[numdisks].minpercent = -1;
|
||||
disks[numdisks].path[0] = 0;
|
||||
disks[numdisks].device[0] = 0;
|
||||
+ disks[numdisks].alive = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -444,7 +457,7 @@ int disk_exists(char *path)
|
||||
}
|
||||
|
||||
static void
|
||||
-find_and_add_allDisks(int minpercent)
|
||||
+refresh_disk_table(int addNewDisks, int minpercent)
|
||||
{
|
||||
#if HAVE_GETMNTENT
|
||||
#if HAVE_SYS_MNTTAB_H
|
||||
@@ -480,7 +493,7 @@ find_and_add_allDisks(int minpercent)
|
||||
return;
|
||||
}
|
||||
while (mntfp && NULL != (mntent = getmntent(mntfp))) {
|
||||
- add_device(mntent->mnt_dir, mntent->mnt_fsname, -1, minpercent, 0);
|
||||
+ add_device(mntent->mnt_dir, mntent->mnt_fsname, -1, minpercent, addNewDisks, 0);
|
||||
dummy = 1;
|
||||
}
|
||||
if (mntfp)
|
||||
@@ -497,7 +510,7 @@ find_and_add_allDisks(int minpercent)
|
||||
return;
|
||||
}
|
||||
while ((i = getmntent(mntfp, &mnttab)) == 0) {
|
||||
- add_device(mnttab.mnt_mountp, mnttab.mnt_special, -1, minpercent, 0);
|
||||
+ add_device(mnttab.mnt_mountp, mnttab.mnt_special, -1, minpercent, addNewDisks, 0);
|
||||
dummy = 1;
|
||||
}
|
||||
fclose(mntfp);
|
||||
@@ -514,13 +527,13 @@ find_and_add_allDisks(int minpercent)
|
||||
mntsize = getmntinfo(&mntbuf, MNT_NOWAIT);
|
||||
for (i = 0; i < mntsize; i++) {
|
||||
add_device(mntbuf[i].f_mntonname, mntbuf[i].f_mntfromname, -1,
|
||||
- minpercent, 0);
|
||||
+ minpercent, addNewDisks, 0);
|
||||
}
|
||||
}
|
||||
#elif HAVE_FSTAB_H
|
||||
setfsent(); /* open /etc/fstab */
|
||||
while((fstab1 = getfsent()) != NULL) {
|
||||
- add_device(fstab1->fs_file, fstab1->fs_spec, -1, minpercent, 0);
|
||||
+ add_device(fstab1->fs_file, fstab1->fs_spec, -1, minpercent, addNewDisks, 0);
|
||||
dummy = 1;
|
||||
}
|
||||
endfsent(); /* close /etc/fstab */
|
||||
@@ -535,7 +548,7 @@ find_and_add_allDisks(int minpercent)
|
||||
* statfs we default to the root partition "/"
|
||||
*/
|
||||
if (statfs("/", &statf) == 0) {
|
||||
- add_device("/", statf.f_mntfromname, -1, minpercent, 0);
|
||||
+ add_device("/", statf.f_mntfromname, -1, minpercent, addNewDisks, 0);
|
||||
}
|
||||
#endif
|
||||
else {
|
||||
@@ -694,6 +707,10 @@ fill_dsk_entry(int disknum, struct dsk_e
|
||||
#endif
|
||||
#endif
|
||||
|
||||
+ if (disks[disknum].alive == 0){
|
||||
+ return -1;
|
||||
+ }
|
||||
+
|
||||
entry->dskPercentInode = -1;
|
||||
|
||||
#if defined(HAVE_STATVFS) || defined(HAVE_STATFS)
|
||||
@@ -825,6 +842,13 @@ var_extensible_disk(struct variable *vp,
|
||||
static char *errmsg;
|
||||
static char empty_str[1];
|
||||
|
||||
+ int i;
|
||||
+ for (i = 0; i < numdisks; i++){
|
||||
+ disks[i].alive = 0;
|
||||
+ }
|
||||
+ /* dynamically add new disks + update alive flag */
|
||||
+ refresh_disk_table(allDisksIncluded, allDisksMinPercent);
|
||||
+
|
||||
tryAgain:
|
||||
if (header_simple_table
|
||||
(vp, name, length, exact, var_len, write_method, numdisks))
|
||||
@ -1,12 +1,13 @@
|
||||
diff -urNp a/apps/Makefile.in b/apps/Makefile.in
|
||||
--- a/apps/Makefile.in 2018-07-18 15:39:28.069251000 +0200
|
||||
+++ b/apps/Makefile.in 2018-07-18 15:54:52.261943123 +0200
|
||||
@@ -230,7 +230,7 @@ snmppcap$(EXEEXT): snmppcap.$(OSUFFIX
|
||||
diff --git a/apps/Makefile.in b/apps/Makefile.in
|
||||
index d4529d3..175242b 100644
|
||||
--- a/apps/Makefile.in
|
||||
+++ b/apps/Makefile.in
|
||||
@@ -237,7 +237,7 @@ snmppcap$(EXEEXT): snmppcap.$(OSUFFIX) $(USELIBS)
|
||||
$(LINK) ${CFLAGS} -o $@ snmppcap.$(OSUFFIX) ${LDFLAGS} ${LIBS} -lpcap
|
||||
|
||||
libnetsnmptrapd.$(LIB_EXTENSION)$(LIB_VERSION): $(LLIBTRAPD_OBJS)
|
||||
- $(LIB_LD_CMD) $@ ${LLIBTRAPD_OBJS} $(MIBLIB) $(USELIBS) $(PERLLDOPTS_FOR_LIBS) $(LIB_LD_LIBS)
|
||||
+ $(LIB_LD_CMD) $@ ${LLIBTRAPD_OBJS} $(MIBLIB) $(USELIBS) $(PERLLDOPTS_FOR_LIBS) $(LIB_LD_LIBS) $(MYSQL_LIB)
|
||||
- $(LIB_LD_CMD) $@ ${LLIBTRAPD_OBJS} $(MIBLIB) $(USELIBS) $(PERLLDOPTS_FOR_LIBS) $(LDFLAGS)
|
||||
+ $(LIB_LD_CMD) $@ ${LLIBTRAPD_OBJS} $(MIBLIB) $(USELIBS) $(PERLLDOPTS_FOR_LIBS) $(LIB_LD_LIBS) $(MYSQL_LIBS)
|
||||
$(RANLIB) $@
|
||||
|
||||
snmpinforminstall:
|
||||
28
backport-net-snmp-5.9-memory-reporting.patch
Normal file
28
backport-net-snmp-5.9-memory-reporting.patch
Normal file
@ -0,0 +1,28 @@
|
||||
diff --git a/agent/mibgroup/hardware/memory/memory_linux.c b/agent/mibgroup/hardware/memory/memory_linux.c
|
||||
index 6d5e86c..68b55d2 100644
|
||||
--- a/agent/mibgroup/hardware/memory/memory_linux.c
|
||||
+++ b/agent/mibgroup/hardware/memory/memory_linux.c
|
||||
@@ -123,6 +123,13 @@ int netsnmp_mem_arch_load( netsnmp_cache *cache, void *magic ) {
|
||||
if (first)
|
||||
snmp_log(LOG_ERR, "No SwapTotal line in /proc/meminfo\n");
|
||||
}
|
||||
+ b = strstr(buff, "SReclaimable: ");
|
||||
+ if (b)
|
||||
+ sscanf(b, "SReclaimable: %lu", &sreclaimable);
|
||||
+ else {
|
||||
+ if (first)
|
||||
+ snmp_log(LOG_ERR, "No SReclaimable line in /proc/meminfo\n");
|
||||
+ }
|
||||
b = strstr(buff, "SwapFree: ");
|
||||
if (b)
|
||||
sscanf(b, "SwapFree: %lu", &swapfree);
|
||||
@@ -130,9 +137,6 @@ int netsnmp_mem_arch_load( netsnmp_cache *cache, void *magic ) {
|
||||
if (first)
|
||||
snmp_log(LOG_ERR, "No SwapFree line in /proc/meminfo\n");
|
||||
}
|
||||
- b = strstr(buff, "SReclaimable: ");
|
||||
- if (b)
|
||||
- sscanf(b, "SReclaimable: %lu", &sreclaimable);
|
||||
first = 0;
|
||||
|
||||
|
||||
@ -1,6 +1,7 @@
|
||||
diff -urNp a/man/netsnmp_config_api.3.def b/man/netsnmp_config_api.3.def
|
||||
--- a/man/netsnmp_config_api.3.def 2018-07-18 11:18:06.196792766 +0200
|
||||
+++ b/man/netsnmp_config_api.3.def 2018-07-18 11:20:04.631679886 +0200
|
||||
diff --git a/man/netsnmp_config_api.3.def b/man/netsnmp_config_api.3.def
|
||||
index 90b20d9..bd5abe1 100644
|
||||
--- a/man/netsnmp_config_api.3.def
|
||||
+++ b/man/netsnmp_config_api.3.def
|
||||
@@ -295,7 +295,7 @@ for one particular machine.
|
||||
.PP
|
||||
The default list of directories to search is \fC SYSCONFDIR/snmp\fP,
|
||||
@ -10,7 +11,7 @@ diff -urNp a/man/netsnmp_config_api.3.def b/man/netsnmp_config_api.3.def
|
||||
followed by \fC $HOME/.snmp\fP.
|
||||
This list can be changed by setting the environmental variable
|
||||
.I SNMPCONFPATH
|
||||
@@ -367,7 +367,7 @@ A colon separated list of directories to
|
||||
@@ -367,7 +367,7 @@ A colon separated list of directories to search for configuration
|
||||
files in.
|
||||
Default:
|
||||
.br
|
||||
@ -19,10 +20,11 @@ diff -urNp a/man/netsnmp_config_api.3.def b/man/netsnmp_config_api.3.def
|
||||
.SH "SEE ALSO"
|
||||
netsnmp_mib_api(3), snmp_api(3)
|
||||
.\" Local Variables:
|
||||
diff -urNp a/man/snmp_config.5.def b/man/snmp_config.5.def
|
||||
--- a/man/snmp_config.5.def 2018-07-18 11:18:06.194792767 +0200
|
||||
+++ b/man/snmp_config.5.def 2018-07-18 11:20:56.423626117 +0200
|
||||
@@ -10,7 +10,7 @@ First off, there are numerous places tha
|
||||
diff --git a/man/snmp_config.5.def b/man/snmp_config.5.def
|
||||
index fd30873..c3437d6 100644
|
||||
--- a/man/snmp_config.5.def
|
||||
+++ b/man/snmp_config.5.def
|
||||
@@ -10,7 +10,7 @@ First off, there are numerous places that configuration files can be
|
||||
found and read from. By default, the applications look for
|
||||
configuration files in the following 4 directories, in order:
|
||||
SYSCONFDIR/snmp,
|
||||
@ -31,10 +33,11 @@ diff -urNp a/man/snmp_config.5.def b/man/snmp_config.5.def
|
||||
directories, it looks for files snmp.conf, snmpd.conf and/or
|
||||
snmptrapd.conf, as well as snmp.local.conf, snmpd.local.conf
|
||||
and/or snmptrapd.local.conf. *.local.conf are always
|
||||
diff -urNp a/man/snmpd.conf.5.def b/man/snmpd.conf.5.def
|
||||
--- a/man/snmpd.conf.5.def 2018-07-18 11:18:06.196792766 +0200
|
||||
+++ b/man/snmpd.conf.5.def 2018-07-18 11:21:44.263574388 +0200
|
||||
@@ -1559,7 +1559,7 @@ filename), and call the initialisation r
|
||||
diff --git a/man/snmpd.conf.5.def b/man/snmpd.conf.5.def
|
||||
index 7ce8a46..a4000f9 100644
|
||||
--- a/man/snmpd.conf.5.def
|
||||
+++ b/man/snmpd.conf.5.def
|
||||
@@ -1593,7 +1593,7 @@ filename), and call the initialisation routine \fIinit_NAME\fR.
|
||||
.RS
|
||||
.IP "Note:"
|
||||
If the specified PATH is not a fully qualified filename, it will
|
||||
@ -1,7 +1,8 @@
|
||||
diff -up net-snmp-5.7.2/agent/Makefile.in.pie net-snmp-5.7.2/agent/Makefile.in
|
||||
--- net-snmp-5.7.2/agent/Makefile.in.pie 2012-10-10 00:28:58.000000000 +0200
|
||||
+++ net-snmp-5.7.2/agent/Makefile.in 2012-10-18 09:45:13.298613099 +0200
|
||||
@@ -294,7 +294,7 @@ getmibstat.o: mibgroup/kernel_sunos5.c
|
||||
diff --git a/agent/Makefile.in b/agent/Makefile.in
|
||||
index b5d692d..1a30209 100644
|
||||
--- a/agent/Makefile.in
|
||||
+++ b/agent/Makefile.in
|
||||
@@ -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)
|
||||
@ -9,11 +10,12 @@ diff -up net-snmp-5.7.2/agent/Makefile.in.pie net-snmp-5.7.2/agent/Makefile.in
|
||||
+ $(LINK) $(CFLAGS) -o $@ -pie ${LAGENTOBJS} ${LDFLAGS} ${OUR_AGENT_LIBS}
|
||||
|
||||
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@
|
||||
diff -up net-snmp-5.7.2/apps/Makefile.in.pie net-snmp-5.7.2/apps/Makefile.in
|
||||
--- net-snmp-5.7.2/apps/Makefile.in.pie 2012-10-10 00:28:58.000000000 +0200
|
||||
+++ net-snmp-5.7.2/apps/Makefile.in 2012-10-18 09:44:27.827774580 +0200
|
||||
@@ -170,7 +170,7 @@ snmptest$(EXEEXT): snmptest.$(OSUFFIX
|
||||
$(LIB_LD_CMD) $(AGENTLIB) ${LLIBAGENTOBJS} $(USELIBS) ${LAGENTLIBS} @LD_NO_UNDEFINED@ $(LDFLAGS) $(PERLLDOPTS_FOR_LIBS) @AGENTLIBS@
|
||||
diff --git a/apps/Makefile.in b/apps/Makefile.in
|
||||
index 43f3b9c..d4529d3 100644
|
||||
--- a/apps/Makefile.in
|
||||
+++ b/apps/Makefile.in
|
||||
@@ -190,7 +190,7 @@ snmptest$(EXEEXT): snmptest.$(OSUFFIX) $(USELIBS)
|
||||
$(LINK) ${CFLAGS} -o $@ snmptest.$(OSUFFIX) ${LDFLAGS} ${LIBS}
|
||||
|
||||
snmptrapd$(EXEEXT): $(TRAPD_OBJECTS) $(USETRAPLIBS) $(INSTALLLIBS)
|
||||
38
backport-net-snmp-5.9-python3.patch
Normal file
38
backport-net-snmp-5.9-python3.patch
Normal file
@ -0,0 +1,38 @@
|
||||
diff --git a/Makefile.in b/Makefile.in
|
||||
index 912f6b2..862fb5f 100644
|
||||
--- a/Makefile.in
|
||||
+++ b/Makefile.in
|
||||
@@ -227,7 +227,7 @@ perlcleanfeatures:
|
||||
|
||||
# python specific build rules
|
||||
#
|
||||
-PYMAKE=$(PYTHON) setup.py $(PYTHONARGS)
|
||||
+PYMAKE=/usr/bin/python3 setup.py $(PYTHONARGS)
|
||||
pythonmodules: subdirs
|
||||
@(dir=`pwd`; cd python; $(PYMAKE) build --basedir=$$dir) ; \
|
||||
if test $$? != 0 ; then \
|
||||
diff --git a/python/netsnmp/client.py b/python/netsnmp/client.py
|
||||
index daf11a4..3a30a64 100644
|
||||
--- a/python/netsnmp/client.py
|
||||
+++ b/python/netsnmp/client.py
|
||||
@@ -56,7 +56,7 @@ class Varbind(object):
|
||||
def __init__(self, tag=None, iid=None, val=None, type_arg=None):
|
||||
self.tag = STR(tag)
|
||||
self.iid = STR(iid)
|
||||
- self.val = STR(val)
|
||||
+ self.val = val
|
||||
self.type = STR(type_arg)
|
||||
# parse iid out of tag if needed
|
||||
if iid is None and tag is not None:
|
||||
@@ -66,7 +66,10 @@ class Varbind(object):
|
||||
(self.tag, self.iid) = match.group(1, 2)
|
||||
|
||||
def __setattr__(self, name, val):
|
||||
- self.__dict__[name] = STR(val)
|
||||
+ if name == 'val':
|
||||
+ self.__dict__[name] = val
|
||||
+ else:
|
||||
+ self.__dict__[name] = STR(val)
|
||||
|
||||
def __str__(self):
|
||||
return obj_to_str(self)
|
||||
110
backport-net-snmp-5.9-test-debug.patch
Normal file
110
backport-net-snmp-5.9-test-debug.patch
Normal file
@ -0,0 +1,110 @@
|
||||
diff --git a/testing/fulltests/default/T070com2sec_simple b/testing/fulltests/default/T070com2sec_simple
|
||||
index 6c07f74..7df0b51 100644
|
||||
--- a/testing/fulltests/default/T070com2sec_simple
|
||||
+++ b/testing/fulltests/default/T070com2sec_simple
|
||||
@@ -134,34 +134,30 @@ SAVECHECKAGENT '<"c406a", 255.255.255.255/255.255.255.255> => "t406a"'
|
||||
SAVECHECKAGENT 'line 30: Error:' # msg from h_strerror so it varies
|
||||
SAVECHECKAGENT 'line 31: Error:' # msg from h_strerror so it varies
|
||||
|
||||
-if false; then
|
||||
- # The two tests below have been disabled because these rely on resolving a
|
||||
- # domain name into a local IP address. Such DNS replies are filtered out by
|
||||
- # many security devices because to avoid DNS rebinding attacks. See also
|
||||
- # https://en.wikipedia.org/wiki/DNS_rebinding.
|
||||
-
|
||||
- CHECKAGENT '<"c408a"'
|
||||
- if [ "$snmp_last_test_result" -eq 0 ] ; then
|
||||
- CHECKAGENT 'line 32: Error:'
|
||||
- if [ "$snmp_last_test_result" -ne 1 ] ; then
|
||||
- return_value=1
|
||||
- FINISHED
|
||||
- fi
|
||||
- elif [ "$snmp_last_test_result" -ne 1 ] ; then
|
||||
+FINISHED
|
||||
+
|
||||
+# don't test the rest, it depends on DNS, which is not available in Koji
|
||||
+
|
||||
+CHECKAGENT '<"c408a"'
|
||||
+if [ "$snmp_last_test_result" -eq 0 ] ; then
|
||||
+ CHECKAGENT 'line 32: Error:'
|
||||
+ if [ "$snmp_last_test_result" -ne 1 ] ; then
|
||||
return_value=1
|
||||
FINISHED
|
||||
fi
|
||||
+elif [ "$snmp_last_test_result" -ne 1 ] ; then
|
||||
+ return_value=1
|
||||
+ FINISHED
|
||||
+fi
|
||||
|
||||
- CHECKAGENT '<"c408b"'
|
||||
- if [ "$snmp_last_test_result" -eq 0 ] ; then
|
||||
- CHECKAGENT 'line 33: Error:'
|
||||
- if [ "$snmp_last_test_result" -ne 1 ] ; then
|
||||
- return_value=1
|
||||
- fi
|
||||
- elif [ "$snmp_last_test_result" -ne 1 ] ; then
|
||||
+CHECKAGENT '<"c408b"'
|
||||
+if [ "$snmp_last_test_result" -eq 0 ] ; then
|
||||
+ CHECKAGENT 'line 33: Error:'
|
||||
+ if [ "$snmp_last_test_result" -ne 1 ] ; then
|
||||
return_value=1
|
||||
fi
|
||||
-
|
||||
+elif [ "$snmp_last_test_result" -ne 1 ] ; then
|
||||
+ return_value=1
|
||||
fi
|
||||
|
||||
FINISHED
|
||||
diff --git a/testing/fulltests/default/T071com2sec6_simple b/testing/fulltests/default/T071com2sec6_simple
|
||||
index 76da70b..bc2d432 100644
|
||||
--- a/testing/fulltests/default/T071com2sec6_simple
|
||||
+++ b/testing/fulltests/default/T071com2sec6_simple
|
||||
@@ -132,30 +132,27 @@ SAVECHECKAGENT '<"c606a", ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff/ffff:ffff:ffff
|
||||
SAVECHECKAGENT 'line 27: Error:'
|
||||
SAVECHECKAGENT 'line 28: Error:'
|
||||
|
||||
-if false; then
|
||||
- # The two tests below have been disabled because these rely on resolving a
|
||||
- # domain name into a local IP address. Such DNS replies are filtered out by
|
||||
- # many security devices because to avoid DNS rebinding attacks. See also
|
||||
- # https://en.wikipedia.org/wiki/DNS_rebinding.
|
||||
-
|
||||
- # 608
|
||||
- CHECKAGENT '<"c608a"'
|
||||
- if [ "$snmp_last_test_result" -eq 0 ] ; then
|
||||
- CHECKAGENT 'line 29: Error:'
|
||||
- errnum=`expr $errnum - 1`
|
||||
- if [ "$snmp_last_test_result" -ne 1 ] ; then
|
||||
- FINISHED
|
||||
- fi
|
||||
- elif [ "$snmp_last_test_result" -ne 1 ] ; then
|
||||
+FINISHED
|
||||
+
|
||||
+# don't test the rest, it depends on DNS, which is not available in Koji
|
||||
+
|
||||
+# 608
|
||||
+CHECKAGENT '<"c608a"'
|
||||
+if [ "$snmp_last_test_result" -eq 0 ] ; then
|
||||
+ CHECKAGENT 'line 29: Error:'
|
||||
+ errnum=`expr $errnum - 1`
|
||||
+ if [ "$snmp_last_test_result" -ne 1 ] ; then
|
||||
FINISHED
|
||||
fi
|
||||
+elif [ "$snmp_last_test_result" -ne 1 ] ; then
|
||||
+ FINISHED
|
||||
+fi
|
||||
|
||||
- CHECKAGENTCOUNT atleastone '<"c608b"'
|
||||
- if [ "$snmp_last_test_result" -eq 0 ] ; then
|
||||
- CHECKAGENT 'line 30: Error:'
|
||||
- if [ "$snmp_last_test_result" -eq 1 ] ; then
|
||||
- errnum=`expr $errnum - 1`
|
||||
- fi
|
||||
+CHECKAGENTCOUNT atleastone '<"c608b"'
|
||||
+if [ "$snmp_last_test_result" -eq 0 ] ; then
|
||||
+ CHECKAGENT 'line 30: Error:'
|
||||
+ if [ "$snmp_last_test_result" -eq 1 ] ; then
|
||||
+ errnum=`expr $errnum - 1`
|
||||
fi
|
||||
fi
|
||||
|
||||
12
backport-net-snmp-5.9-usage-exit.patch
Normal file
12
backport-net-snmp-5.9-usage-exit.patch
Normal file
@ -0,0 +1,12 @@
|
||||
diff --git a/agent/snmpd.c b/agent/snmpd.c
|
||||
index ae73eda..f01b890 100644
|
||||
--- a/agent/snmpd.c
|
||||
+++ b/agent/snmpd.c
|
||||
@@ -289,6 +289,7 @@ usage(char *prog)
|
||||
" -S d|i|0-7\t\tuse -Ls <facility> instead\n"
|
||||
"\n"
|
||||
);
|
||||
+ exit(1);
|
||||
}
|
||||
|
||||
static void
|
||||
@ -1,10 +0,0 @@
|
||||
926223 - net-snmp: Does not support aarch64 in f19 and rawhide
|
||||
|
||||
Update autoconf version to make the test suite happy.
|
||||
|
||||
diff -up net-snmp-5.7.2/dist/autoconf-version.autoreconf net-snmp-5.7.2/dist/autoconf-version
|
||||
--- net-snmp-5.7.2/dist/autoconf-version.autoreconf 2013-03-25 13:00:15.002745347 +0100
|
||||
+++ net-snmp-5.7.2/dist/autoconf-version 2013-03-25 13:00:17.207736442 +0100
|
||||
@@ -1 +1 @@
|
||||
-2.68
|
||||
+2.69
|
||||
@ -1,14 +0,0 @@
|
||||
diff -urNp old/agent/mibgroup/host/data_access/swrun.c new/agent/mibgroup/host/data_access/swrun.c
|
||||
--- old/agent/mibgroup/host/data_access/swrun.c 2018-03-26 09:00:39.932335587 +0200
|
||||
+++ new/agent/mibgroup/host/data_access/swrun.c 2018-03-26 09:03:00.845876681 +0200
|
||||
@@ -102,7 +102,9 @@ swrun_count_processes_by_name( char *nam
|
||||
return 0; /* or -1 */
|
||||
|
||||
it = CONTAINER_ITERATOR( swrun_container );
|
||||
- while ((entry = (netsnmp_swrun_entry*)ITERATOR_NEXT( it )) != NULL) {
|
||||
+ for (entry = (netsnmp_swrun_entry*)ITERATOR_FIRST( it );
|
||||
+ entry;
|
||||
+ entry = (netsnmp_swrun_entry*)ITERATOR_NEXT( it )) {
|
||||
if (0 == strcmp( entry->hrSWRunName, name ))
|
||||
i++;
|
||||
}
|
||||
@ -1,12 +0,0 @@
|
||||
diff -urNp a/agent/mibgroup/agentx/master.c b/agent/mibgroup/agentx/master.c
|
||||
--- a/agent/mibgroup/agentx/master.c 2018-07-18 12:13:49.953014652 +0200
|
||||
+++ b/agent/mibgroup/agentx/master.c 2018-07-18 12:20:23.537626773 +0200
|
||||
@@ -221,7 +221,7 @@ agentx_got_response(int operation,
|
||||
/* response is too late, free the cache */
|
||||
if (magic)
|
||||
netsnmp_free_delegated_cache((netsnmp_delegated_cache*) magic);
|
||||
- return 0;
|
||||
+ return 1;
|
||||
}
|
||||
requests = cache->requests;
|
||||
|
||||
@ -1,199 +0,0 @@
|
||||
diff -urNp b/agent/mibgroup/hardware/fsys/fsys_mntctl.c net-snmp-5.8/agent/mibgroup/hardware/fsys/fsys_mntctl.c
|
||||
--- b/agent/mibgroup/hardware/fsys/fsys_mntctl.c 2018-07-18 16:12:20.674499629 +0200
|
||||
+++ net-snmp-5.8/agent/mibgroup/hardware/fsys/fsys_mntctl.c 2018-07-18 16:15:46.782859398 +0200
|
||||
@@ -43,8 +43,9 @@ _fsys_type( int type)
|
||||
|
||||
case MNT_NFS:
|
||||
case MNT_NFS3:
|
||||
- case MNT_AUTOFS:
|
||||
return NETSNMP_FS_TYPE_NFS;
|
||||
+ case MNT_AUTOFS:
|
||||
+ return NETSNMP_FS_TYPE_AUTOFS;
|
||||
|
||||
/*
|
||||
* The following code covers selected filesystems
|
||||
@@ -156,10 +157,12 @@ netsnmp_fsys_arch_load( void )
|
||||
|
||||
/*
|
||||
* Optionally skip retrieving statistics for remote mounts
|
||||
+ * AUTOFS is skipped by default
|
||||
*/
|
||||
- if ( (entry->flags & NETSNMP_FS_FLAG_REMOTE) &&
|
||||
+ if ( ((entry->flags & NETSNMP_FS_FLAG_REMOTE) &&
|
||||
netsnmp_ds_get_boolean(NETSNMP_DS_APPLICATION_ID,
|
||||
- NETSNMP_DS_AGENT_SKIPNFSINHOSTRESOURCES))
|
||||
+ NETSNMP_DS_AGENT_SKIPNFSINHOSTRESOURCES)) ||
|
||||
+ entry->type == (NETSNMP_FS_TYPE_AUTOFS))
|
||||
continue;
|
||||
|
||||
if ( statfs( entry->path, &stat_buf ) < 0 ) {
|
||||
diff -urNp b/agent/mibgroup/hardware/fsys/fsys_mntent.c net-snmp-5.8/agent/mibgroup/hardware/fsys/fsys_mntent.c
|
||||
--- b/agent/mibgroup/hardware/fsys/fsys_mntent.c 2018-07-18 16:12:20.674499629 +0200
|
||||
+++ net-snmp-5.8/agent/mibgroup/hardware/fsys/fsys_mntent.c 2018-07-18 16:15:46.782859398 +0200
|
||||
@@ -150,6 +150,13 @@ _fsys_type( char *typename )
|
||||
!strcmp(typename, MNTTYPE_LOFS))
|
||||
return NETSNMP_FS_TYPE_OTHER;
|
||||
|
||||
+ /* Detection of AUTOFS.
|
||||
+ * This file system will be ignored by default
|
||||
+ */
|
||||
+ else if ( !strcmp(typename, MNTTYPE_AUTOFS))
|
||||
+ return NETSNMP_FS_TYPE_AUTOFS;
|
||||
+
|
||||
+
|
||||
/*
|
||||
* All other types are silently skipped
|
||||
*/
|
||||
@@ -239,6 +246,10 @@ netsnmp_fsys_arch_load( void )
|
||||
NETSNMP_DS_AGENT_SKIPNFSINHOSTRESOURCES))
|
||||
continue;
|
||||
|
||||
+ /* Skip AUTOFS enteries */
|
||||
+ if ( entry->type == (NETSNMP_FS_TYPE_AUTOFS))
|
||||
+ continue;
|
||||
+
|
||||
#ifdef irix6
|
||||
if ( NSFS_STATFS( entry->path, &stat_buf, sizeof(struct statfs), 0) < 0 )
|
||||
#else
|
||||
diff -urNp b/agent/mibgroup/hardware/fsys/mnttypes.h net-snmp-5.8/agent/mibgroup/hardware/fsys/mnttypes.h
|
||||
--- b/agent/mibgroup/hardware/fsys/mnttypes.h 2018-07-18 16:12:20.674499629 +0200
|
||||
+++ net-snmp-5.8/agent/mibgroup/hardware/fsys/mnttypes.h 2018-07-18 16:15:46.782859398 +0200
|
||||
@@ -165,6 +165,9 @@
|
||||
#ifndef MNTTYPE_APP
|
||||
#define MNTTYPE_APP "app"
|
||||
#endif
|
||||
+#ifndef MNTTYPE_AUTOFS
|
||||
+#define MNTTYPE_AUTOFS "autofs"
|
||||
+#endif
|
||||
#ifndef MNTTYPE_DEVPTS
|
||||
#define MNTTYPE_DEVPTS "devpts"
|
||||
#endif
|
||||
diff -urNp b/agent/mibgroup/host/hr_filesys.c net-snmp-5.8/agent/mibgroup/host/hr_filesys.c
|
||||
--- b/agent/mibgroup/host/hr_filesys.c 2018-07-18 16:12:20.668499652 +0200
|
||||
+++ net-snmp-5.8/agent/mibgroup/host/hr_filesys.c 2018-07-18 16:15:46.783859399 +0200
|
||||
@@ -834,6 +834,27 @@ Check_HR_FileSys_NFS (void)
|
||||
return 0; /* no NFS file system */
|
||||
}
|
||||
|
||||
+/* This function checks whether current file system is an AutoFs
|
||||
+ * HRFS_entry must be valid prior to calling this function
|
||||
+ * return 1 if AutoFs, 0 otherwise
|
||||
+ */
|
||||
+int
|
||||
+Check_HR_FileSys_AutoFs (void)
|
||||
+{
|
||||
+#if HAVE_GETFSSTAT
|
||||
+ if ( HRFS_entry->HRFS_type != NULL &&
|
||||
+#if defined(MNTTYPE_AUTOFS)
|
||||
+ !strcmp( HRFS_entry->HRFS_type, MNTTYPE_AUTOFS)
|
||||
+#else
|
||||
+ !strcmp( HRFS_entry->HRFS_type, "autofs")
|
||||
+#endif
|
||||
+ )
|
||||
+#endif /* HAVE_GETFSSTAT */
|
||||
+ return 1; /* AUTOFS */
|
||||
+
|
||||
+ return 0; /* no AUTOFS */
|
||||
+}
|
||||
+
|
||||
void
|
||||
End_HR_FileSys(void)
|
||||
{
|
||||
diff -urNp b/agent/mibgroup/host/hr_filesys.h net-snmp-5.8/agent/mibgroup/host/hr_filesys.h
|
||||
--- b/agent/mibgroup/host/hr_filesys.h 2018-07-18 16:12:20.669499648 +0200
|
||||
+++ net-snmp-5.8/agent/mibgroup/host/hr_filesys.h 2018-07-18 16:15:46.784859400 +0200
|
||||
@@ -10,6 +10,7 @@ extern void Init_HR_FileSys(void);
|
||||
extern FindVarMethod var_hrfilesys;
|
||||
extern int Get_Next_HR_FileSys(void);
|
||||
extern int Check_HR_FileSys_NFS(void);
|
||||
+extern int Check_HR_FileSys_AutoFs(void);
|
||||
|
||||
extern int Get_FSIndex(char *);
|
||||
extern long Get_FSSize(char *); /* Temporary */
|
||||
diff -urNp b/agent/mibgroup/host/hrh_filesys.c net-snmp-5.8/agent/mibgroup/host/hrh_filesys.c
|
||||
--- b/agent/mibgroup/host/hrh_filesys.c 2018-07-18 16:12:20.668499652 +0200
|
||||
+++ net-snmp-5.8/agent/mibgroup/host/hrh_filesys.c 2018-07-18 16:15:46.785859402 +0200
|
||||
@@ -429,3 +429,9 @@ Check_HR_FileSys_NFS (void)
|
||||
{
|
||||
return (HRFS_entry->flags & NETSNMP_FS_FLAG_REMOTE) ? 1 : 0;
|
||||
}
|
||||
+
|
||||
+int
|
||||
+Check_HR_FileSys_AutoFs (void)
|
||||
+{
|
||||
+ return (HRFS_entry->type == (NETSNMP_FS_TYPE_AUTOFS)) ? 1 : 0;
|
||||
+}
|
||||
diff -urNp b/agent/mibgroup/host/hrh_filesys.h net-snmp-5.8/agent/mibgroup/host/hrh_filesys.h
|
||||
--- b/agent/mibgroup/host/hrh_filesys.h 2018-07-18 16:12:20.669499648 +0200
|
||||
+++ net-snmp-5.8/agent/mibgroup/host/hrh_filesys.h 2018-07-18 16:15:46.785859402 +0200
|
||||
@@ -10,6 +10,7 @@ extern void Init_HR_FileSys(void);
|
||||
extern FindVarMethod var_hrhfilesys;
|
||||
extern int Get_Next_HR_FileSys(void);
|
||||
extern int Check_HR_FileSys_NFS(void);
|
||||
+extern int Check_HR_FileSys_AutoFs(void);
|
||||
|
||||
extern int Get_FSIndex(char *);
|
||||
extern long Get_FSSize(char *); /* Temporary */
|
||||
diff -urNp b/agent/mibgroup/host/hrh_storage.c net-snmp-5.8/agent/mibgroup/host/hrh_storage.c
|
||||
--- b/agent/mibgroup/host/hrh_storage.c 2018-07-18 16:12:20.668499652 +0200
|
||||
+++ net-snmp-5.8/agent/mibgroup/host/hrh_storage.c 2018-07-18 16:15:46.786859402 +0200
|
||||
@@ -367,9 +367,10 @@ really_try_next:
|
||||
store_idx = name[ HRSTORE_ENTRY_NAME_LENGTH ];
|
||||
if (HRFS_entry &&
|
||||
store_idx > NETSNMP_MEM_TYPE_MAX &&
|
||||
- netsnmp_ds_get_boolean(NETSNMP_DS_APPLICATION_ID,
|
||||
+ ((netsnmp_ds_get_boolean(NETSNMP_DS_APPLICATION_ID,
|
||||
NETSNMP_DS_AGENT_SKIPNFSINHOSTRESOURCES) &&
|
||||
- Check_HR_FileSys_NFS())
|
||||
+ Check_HR_FileSys_NFS()) ||
|
||||
+ Check_HR_FileSys_AutoFs()))
|
||||
return NULL;
|
||||
if (store_idx <= NETSNMP_MEM_TYPE_MAX ) {
|
||||
mem = (netsnmp_memory_info*)ptr;
|
||||
@@ -508,7 +509,8 @@ Get_Next_HR_Store(void)
|
||||
if (HRS_index >= 0) {
|
||||
if (!(netsnmp_ds_get_boolean(NETSNMP_DS_APPLICATION_ID,
|
||||
NETSNMP_DS_AGENT_SKIPNFSINHOSTRESOURCES) &&
|
||||
- Check_HR_FileSys_NFS())) {
|
||||
+ Check_HR_FileSys_NFS()) &&
|
||||
+ !Check_HR_FileSys_AutoFs()) {
|
||||
return HRS_index + NETSNMP_MEM_TYPE_MAX;
|
||||
}
|
||||
} else {
|
||||
diff -urNp b/agent/mibgroup/host/hr_storage.c net-snmp-5.8/agent/mibgroup/host/hr_storage.c
|
||||
--- b/agent/mibgroup/host/hr_storage.c 2018-07-18 16:12:20.670499644 +0200
|
||||
+++ net-snmp-5.8/agent/mibgroup/host/hr_storage.c 2018-07-18 16:15:46.786859402 +0200
|
||||
@@ -540,9 +540,10 @@ really_try_next:
|
||||
|
||||
store_idx = name[ HRSTORE_ENTRY_NAME_LENGTH ];
|
||||
if (store_idx > NETSNMP_MEM_TYPE_MAX ) {
|
||||
- if ( netsnmp_ds_get_boolean(NETSNMP_DS_APPLICATION_ID,
|
||||
+ if ( (netsnmp_ds_get_boolean(NETSNMP_DS_APPLICATION_ID,
|
||||
NETSNMP_DS_AGENT_SKIPNFSINHOSTRESOURCES) &&
|
||||
- Check_HR_FileSys_NFS())
|
||||
+ Check_HR_FileSys_NFS()) ||
|
||||
+ Check_HR_FileSys_AutoFs())
|
||||
return NULL; /* or goto try_next; */
|
||||
if (HRFS_statfs(HRFS_entry->HRFS_mount, &stat_buf) < 0) {
|
||||
snmp_log_perror(HRFS_entry->HRFS_mount);
|
||||
@@ -683,7 +684,8 @@ Get_Next_HR_Store(void)
|
||||
if (HRS_index >= 0) {
|
||||
if (!(netsnmp_ds_get_boolean(NETSNMP_DS_APPLICATION_ID,
|
||||
NETSNMP_DS_AGENT_SKIPNFSINHOSTRESOURCES) &&
|
||||
- Check_HR_FileSys_NFS())) {
|
||||
+ Check_HR_FileSys_NFS()) &&
|
||||
+ !Check_HR_FileSys_AutoFs()) {
|
||||
return HRS_index + NETSNMP_MEM_TYPE_MAX;
|
||||
}
|
||||
} else {
|
||||
diff -urNp b/include/net-snmp/agent/hardware/fsys.h net-snmp-5.8/include/net-snmp/agent/hardware/fsys.h
|
||||
--- b/include/net-snmp/agent/hardware/fsys.h 2018-07-18 16:12:20.649499726 +0200
|
||||
+++ net-snmp-5.8/include/net-snmp/agent/hardware/fsys.h 2018-07-18 16:19:33.994918912 +0200
|
||||
@@ -41,6 +41,7 @@ typedef struct netsnmp_fsys_info_s netsn
|
||||
#define NETSNMP_FS_TYPE_SYSFS (4 | _NETSNMP_FS_TYPE_LOCAL | _NETSNMP_FS_TYPE_SKIP_BIT)
|
||||
#define NETSNMP_FS_TYPE_TMPFS (5 | _NETSNMP_FS_TYPE_LOCAL)
|
||||
#define NETSNMP_FS_TYPE_USBFS (6 | _NETSNMP_FS_TYPE_LOCAL)
|
||||
+#define NETSNMP_FS_TYPE_AUTOFS (7 | _NETSNMP_FS_TYPE_LOCAL | _NETSNMP_FS_TYPE_SKIP_BIT)
|
||||
|
||||
#define NETSNMP_FS_FLAG_ACTIVE 0x01
|
||||
#define NETSNMP_FS_FLAG_REMOTE 0x02
|
||||
@ -1,112 +0,0 @@
|
||||
diff -urNp a/net-snmp-config.in b/net-snmp-config.in
|
||||
--- a/net-snmp-config.in 2018-07-18 13:43:12.264426052 +0200
|
||||
+++ b/net-snmp-config.in 2018-07-18 13:52:06.917089518 +0200
|
||||
@@ -140,10 +140,10 @@ else
|
||||
;;
|
||||
#################################################### compile
|
||||
--base-cflags)
|
||||
- echo @CFLAGS@ @CPPFLAGS@ -I${NSC_INCLUDEDIR}
|
||||
+ echo -I${NSC_INCLUDEDIR}
|
||||
;;
|
||||
--cflags|--cf*)
|
||||
- echo @CFLAGS@ @DEVFLAGS@ @CPPFLAGS@ -I. -I${NSC_INCLUDEDIR}
|
||||
+ echo @DEVFLAGS@ -I. -I${NSC_INCLUDEDIR}
|
||||
;;
|
||||
--srcdir)
|
||||
echo $NSC_SRCDIR
|
||||
diff -urNp a/perl/agent/default_store/Makefile.PL b/perl/agent/default_store/Makefile.PL
|
||||
--- a/perl/agent/default_store/Makefile.PL 2018-07-18 13:43:12.170426290 +0200
|
||||
+++ b/perl/agent/default_store/Makefile.PL 2018-07-18 13:51:31.812176486 +0200
|
||||
@@ -83,7 +83,7 @@ sub AgentDefaultStoreInitMakeParams {
|
||||
" " . $Params{'LIBS'};
|
||||
$Params{'CCFLAGS'} = "-I../../../include " . $Params{'CCFLAGS'};
|
||||
}
|
||||
- $Params{'CCFLAGS'} =~ s/ -W(all|inline|strict-prototypes|write-strings|cast-qual|no-char-subscripts)//g; # ignore developer warnings
|
||||
+ $Params{'CCFLAGS'} =~ s/ -W(inline|strict-prototypes|write-strings|cast-qual|no-char-subscripts)//g; # ignore developer warnings
|
||||
$Params{'CCFLAGS'} .= ' -Wformat';
|
||||
if ($Params{'LIBS'} eq "" || $Params{'CCFLAGS'} eq "") {
|
||||
die "You need to install net-snmp first (I can't find net-snmp-config)";
|
||||
diff -urNp a/perl/agent/Makefile.PL b/perl/agent/Makefile.PL
|
||||
--- a/perl/agent/Makefile.PL 2018-07-18 13:43:12.169426292 +0200
|
||||
+++ b/perl/agent/Makefile.PL 2018-07-18 13:52:53.884973275 +0200
|
||||
@@ -98,7 +98,7 @@ sub AgentInitMakeParams {
|
||||
$Params{'LIBS'} = `$opts->{'nsconfig'} --libdir` . $Params{'LIBS'};
|
||||
# $Params{'PREREQ_PM'} = {'NetSNMP::OID' => '0.1'};
|
||||
}
|
||||
- $Params{'CCFLAGS'} =~ s/ -W(all|inline|strict-prototypes|write-strings|cast-qual|no-char-subscripts)//g; # ignore developer warnings
|
||||
+ $Params{'CCFLAGS'} =~ s/ -W(inline|strict-prototypes|write-strings|cast-qual|no-char-subscripts)//g; # ignore developer warnings
|
||||
$Params{'CCFLAGS'} .= ' -Wformat';
|
||||
if ($Params{'LIBS'} eq "" || $Params{'CCFLAGS'} eq "") {
|
||||
die "You need to install net-snmp first (I can't find net-snmp-config)";
|
||||
diff -urNp a/perl/agent/Support/Makefile.PL b/perl/agent/Support/Makefile.PL
|
||||
--- a/perl/agent/Support/Makefile.PL 2018-07-18 13:43:12.169426292 +0200
|
||||
+++ b/perl/agent/Support/Makefile.PL 2018-07-18 13:53:11.414929921 +0200
|
||||
@@ -90,7 +90,7 @@ sub SupportInitMakeParams {
|
||||
" " . $Params{'LIBS'};
|
||||
$Params{'CCFLAGS'} = "-I../../include " . $Params{'CCFLAGS'};
|
||||
}
|
||||
- $Params{'CCFLAGS'} =~ s/ -W(all|inline|strict-prototypes|write-strings|cast-qual|no-char-subscripts)//g; # ignore developer warnings
|
||||
+ $Params{'CCFLAGS'} =~ s/ -W(inline|strict-prototypes|write-strings|cast-qual|no-char-subscripts)//g; # ignore developer warnings
|
||||
$Params{'CCFLAGS'} .= ' -Wformat';
|
||||
if ($Params{'LIBS'} eq "" || $Params{'CCFLAGS'} eq "") {
|
||||
die "You need to install net-snmp first (I can't find net-snmp-config)";
|
||||
diff -urNp a/perl/ASN/Makefile.PL b/perl/ASN/Makefile.PL
|
||||
--- a/perl/ASN/Makefile.PL 2018-07-18 13:43:12.171426287 +0200
|
||||
+++ b/perl/ASN/Makefile.PL 2018-07-18 13:53:46.652842822 +0200
|
||||
@@ -93,7 +93,7 @@ sub AsnInitMakeParams {
|
||||
" " . $Params{'LIBS'};
|
||||
$Params{'CCFLAGS'} = "-I../../include " . $Params{'CCFLAGS'};
|
||||
}
|
||||
- $Params{'CCFLAGS'} =~ s/ -W(all|inline|strict-prototypes|write-strings|cast-qual|no-char-subscripts)//g; # ignore developer warnings
|
||||
+ $Params{'CCFLAGS'} =~ s/ -W(inline|strict-prototypes|write-strings|cast-qual|no-char-subscripts)//g; # ignore developer warnings
|
||||
$Params{'CCFLAGS'} .= ' -Wformat';
|
||||
if ($Params{'LIBS'} eq "" || $Params{'CCFLAGS'} eq "") {
|
||||
die "You need to install net-snmp first (I can't find net-snmp-config)";
|
||||
diff -urNp a/perl/default_store/Makefile.PL b/perl/default_store/Makefile.PL
|
||||
--- a/perl/default_store/Makefile.PL 2018-07-18 13:43:12.175426277 +0200
|
||||
+++ b/perl/default_store/Makefile.PL 2018-07-18 13:54:20.814758441 +0200
|
||||
@@ -83,7 +83,7 @@ sub DefaultStoreInitMakeParams {
|
||||
" " . $Params{'LIBS'};
|
||||
$Params{'CCFLAGS'} = "-I../../include " . $Params{'CCFLAGS'};
|
||||
}
|
||||
- $Params{'CCFLAGS'} =~ s/ -W(all|inline|strict-prototypes|write-strings|cast-qual|no-char-subscripts)//g; # ignore developer warnings
|
||||
+ $Params{'CCFLAGS'} =~ s/ -W(inline|strict-prototypes|write-strings|cast-qual|no-char-subscripts)//g; # ignore developer warnings
|
||||
$Params{'CCFLAGS'} .= ' -Wformat';
|
||||
if ($Params{'LIBS'} eq "" || $Params{'CCFLAGS'} eq "") {
|
||||
die "You need to install net-snmp first (I can't find net-snmp-config)";
|
||||
diff -urNp a/perl/OID/Makefile.PL b/perl/OID/Makefile.PL
|
||||
--- a/perl/OID/Makefile.PL 2018-07-18 13:43:12.175426277 +0200
|
||||
+++ b/perl/OID/Makefile.PL 2018-07-18 13:54:43.348702811 +0200
|
||||
@@ -90,7 +90,7 @@ sub OidInitMakeParams {
|
||||
# } else {
|
||||
# $Params{'PREREQ_PM'} = {'SNMP' => '5.0'};
|
||||
}
|
||||
- $Params{'CCFLAGS'} =~ s/ -W(all|inline|strict-prototypes|write-strings|cast-qual|no-char-subscripts)//g; # ignore developer warnings
|
||||
+ $Params{'CCFLAGS'} =~ s/ -W(inline|strict-prototypes|write-strings|cast-qual|no-char-subscripts)//g; # ignore developer warnings
|
||||
$Params{'CCFLAGS'} .= ' -Wformat';
|
||||
if ($Params{'LIBS'} eq "" || $Params{'CCFLAGS'} eq "") {
|
||||
die "You need to install net-snmp first (I can't find net-snmp-config)";
|
||||
diff -urNp a/perl/SNMP/Makefile.PL b/perl/SNMP/Makefile.PL
|
||||
--- a/perl/SNMP/Makefile.PL 2018-07-18 13:43:12.173426282 +0200
|
||||
+++ b/perl/SNMP/Makefile.PL 2018-07-18 13:55:07.220643903 +0200
|
||||
@@ -103,7 +103,7 @@ sub SnmpInitMakeParams {
|
||||
# } else {
|
||||
# $Params{'PREREQ_PM'} = { 'NetSNMP::default_store' => 0.01 };
|
||||
}
|
||||
- $Params{'CCFLAGS'} =~ s/ -W(all|inline|strict-prototypes|write-strings|cast-qual|no-char-subscripts)//g; # ignore developer warnings
|
||||
+ $Params{'CCFLAGS'} =~ s/ -W(inline|strict-prototypes|write-strings|cast-qual|no-char-subscripts)//g; # ignore developer warnings
|
||||
$Params{'CCFLAGS'} .= ' -Wformat';
|
||||
if (!$ENV{'NETSNMP_PREFIX'}) {
|
||||
$prefix = `$opts->{'nsconfig'} --prefix`;
|
||||
diff -urNp a/perl/TrapReceiver/Makefile.PL b/perl/TrapReceiver/Makefile.PL
|
||||
--- a/perl/TrapReceiver/Makefile.PL 2018-07-18 13:43:12.172426285 +0200
|
||||
+++ b/perl/TrapReceiver/Makefile.PL 2018-07-18 13:55:43.100647233 +0200
|
||||
@@ -132,7 +132,7 @@ sub TrapReceiverInitMakeParams {
|
||||
$Params{'LIBS'} = `$opts->{'nsconfig'} --libdir` . " $Params{'LIBS'}";
|
||||
}
|
||||
|
||||
- $Params{'CCFLAGS'} =~ s/ -W(all|inline|strict-prototypes|write-strings|cast-qual|no-char-subscripts)//g; # ignore developer warnings
|
||||
+ $Params{'CCFLAGS'} =~ s/ -W(inline|strict-prototypes|write-strings|cast-qual|no-char-subscripts)//g; # ignore developer warnings
|
||||
$Params{'CCFLAGS'} .= ' -Wformat';
|
||||
if ($Params{'CCFLAGS'} eq "") {
|
||||
die "You need to install net-snmp first (I can't find net-snmp-config)";
|
||||
@ -1,12 +0,0 @@
|
||||
diff -urNp a/net-snmp-create-v3-user.in b/net-snmp-create-v3-user.in
|
||||
--- a/net-snmp-create-v3-user.in 2018-07-18 11:11:53.227015237 +0200
|
||||
+++ b/net-snmp-create-v3-user.in 2018-07-18 11:12:13.375010176 +0200
|
||||
@@ -137,7 +137,7 @@ fi
|
||||
echo $line >> $outfile
|
||||
prefix="@prefix@"
|
||||
datarootdir="@datarootdir@"
|
||||
-outfile="@datadir@/snmp/snmpd.conf"
|
||||
+outfile="/etc/snmp/snmpd.conf"
|
||||
line="$token $user"
|
||||
echo "adding the following line to $outfile:"
|
||||
echo " " $line
|
||||
@ -1,720 +0,0 @@
|
||||
diff -urNp a/configure b/configure
|
||||
--- a/configure 2018-07-18 17:11:53.178147565 +0200
|
||||
+++ b/configure 2018-07-18 17:14:01.254774416 +0200
|
||||
@@ -7742,8 +7742,8 @@ $as_echo "no" >&6; }
|
||||
fi
|
||||
|
||||
|
||||
-# Extract the first word of "python", so it can be a program name with args.
|
||||
-set dummy python; ac_word=$2
|
||||
+# Extract the first word of "python3", so it can be a program name with args.
|
||||
+set dummy python3; ac_word=$2
|
||||
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
|
||||
$as_echo_n "checking for $ac_word... " >&6; }
|
||||
if ${ac_cv_path_PYTHONPROG+:} false; then :
|
||||
diff -urNp a/configure.d/config_os_progs b/configure.d/config_os_progs
|
||||
--- a/configure.d/config_os_progs 2018-07-18 17:11:53.197147510 +0200
|
||||
+++ b/configure.d/config_os_progs 2018-07-18 17:14:29.963690646 +0200
|
||||
@@ -57,7 +57,7 @@ AC_PATH_PROG(AUTOCONF, autoconf, [:
|
||||
AC_PATH_PROG(AUTOHEADER, autoheader, [:])
|
||||
AC_PATH_PROG([PERLPROG], perl)
|
||||
AC_PATH_PROG([PSPROG], ps)
|
||||
-AC_PATH_PROG([PYTHONPROG],python)
|
||||
+AC_PATH_PROG([PYTHONPROG],python3)
|
||||
|
||||
AC_PATH_PROG([UNAMEPROG], uname)
|
||||
AC_DEFINE_UNQUOTED(UNAMEPROG,"$UNAMEPROG", [Where is the uname command])
|
||||
diff -urNp a/Makefile.in b/Makefile.in
|
||||
--- a/Makefile.in 2018-07-18 17:11:53.175147574 +0200
|
||||
+++ b/Makefile.in 2018-07-18 17:16:21.331365317 +0200
|
||||
@@ -226,7 +226,7 @@ perlcleanfeatures:
|
||||
|
||||
# python specific build rules
|
||||
#
|
||||
-PYMAKE=$(PYTHON) setup.py $(PYTHONARGS)
|
||||
+PYMAKE=/usr/bin/python3 setup.py $(PYTHONARGS)
|
||||
pythonmodules: subdirs
|
||||
@(dir=`pwd`; cd python; $(PYMAKE) build --basedir=$$dir) ; \
|
||||
if test $$? != 0 ; then \
|
||||
diff -urNp a/python/netsnmp/client_intf.c b/python/netsnmp/client_intf.c
|
||||
--- a/python/netsnmp/client_intf.c 2018-07-18 17:11:53.262147321 +0200
|
||||
+++ b/python/netsnmp/client_intf.c 2018-07-18 17:33:16.495712833 +0200
|
||||
@@ -1,11 +1,5 @@
|
||||
#include <Python.h>
|
||||
|
||||
-#if PY_VERSION_HEX < 0x02050000
|
||||
-typedef int Py_ssize_t;
|
||||
-#define PY_SSIZE_T_MAX INT_MAX
|
||||
-#define PY_SSIZE_T_MIN INT_MIN
|
||||
-#endif
|
||||
-
|
||||
#include <net-snmp/net-snmp-config.h>
|
||||
#include <net-snmp/net-snmp-includes.h>
|
||||
#include <sys/types.h>
|
||||
@@ -852,8 +846,40 @@ py_netsnmp_attr_string(PyObject *obj, ch
|
||||
if (obj && attr_name && PyObject_HasAttrString(obj, attr_name)) {
|
||||
PyObject *attr = PyObject_GetAttrString(obj, attr_name);
|
||||
if (attr) {
|
||||
+ *val = PyUnicode_AsUTF8AndSize(attr, len);
|
||||
+ Py_DECREF(attr);
|
||||
+ return 0;
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ return -1;
|
||||
+}
|
||||
+
|
||||
+static int
|
||||
+py_netsnmp_attr_set_bytes(PyObject *obj, char *attr_name,
|
||||
+ char *val, size_t len)
|
||||
+{
|
||||
+ int ret = -1;
|
||||
+ if (obj && attr_name) {
|
||||
+ PyObject* val_obj = (val ?
|
||||
+ PyBytes_FromStringAndSize(val, len) :
|
||||
+ Py_BuildValue(""));
|
||||
+ ret = PyObject_SetAttrString(obj, attr_name, val_obj);
|
||||
+ Py_DECREF(val_obj);
|
||||
+ }
|
||||
+ return ret;
|
||||
+}
|
||||
+
|
||||
+static int
|
||||
+py_netsnmp_attr_bytes(PyObject *obj, char * attr_name, char **val,
|
||||
+ Py_ssize_t *len)
|
||||
+{
|
||||
+ *val = NULL;
|
||||
+ if (obj && attr_name && PyObject_HasAttrString(obj, attr_name)) {
|
||||
+ PyObject *attr = PyObject_GetAttrString(obj, attr_name);
|
||||
+ if (attr) {
|
||||
int retval;
|
||||
- retval = PyString_AsStringAndSize(attr, val, len);
|
||||
+ retval = PyBytes_AsStringAndSize(attr, val, len);
|
||||
Py_DECREF(attr);
|
||||
return retval;
|
||||
}
|
||||
@@ -870,7 +896,7 @@ 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) {
|
||||
- val = PyInt_AsLong(attr);
|
||||
+ val = PyLong_AsLong(attr);
|
||||
Py_DECREF(attr);
|
||||
}
|
||||
}
|
||||
@@ -955,13 +981,13 @@ __py_netsnmp_update_session_errors(PyObj
|
||||
|
||||
py_netsnmp_attr_set_string(session, "ErrorStr", err_str, STRLEN(err_str));
|
||||
|
||||
- tmp_for_conversion = PyInt_FromLong(err_num);
|
||||
+ tmp_for_conversion = PyLong_FromLong(err_num);
|
||||
if (!tmp_for_conversion)
|
||||
return; /* nothing better to do? */
|
||||
PyObject_SetAttrString(session, "ErrorNum", tmp_for_conversion);
|
||||
Py_DECREF(tmp_for_conversion);
|
||||
|
||||
- tmp_for_conversion = PyInt_FromLong(err_ind);
|
||||
+ tmp_for_conversion = PyLong_FromLong(err_ind);
|
||||
if (!tmp_for_conversion)
|
||||
return; /* nothing better to do? */
|
||||
PyObject_SetAttrString(session, "ErrorInd", tmp_for_conversion);
|
||||
@@ -1323,7 +1349,7 @@ netsnmp_get(PyObject *self, PyObject *ar
|
||||
|
||||
ss = (SnmpSession *)py_netsnmp_attr_void_ptr(session, "sess_ptr");
|
||||
|
||||
- if (py_netsnmp_attr_string(session, "ErrorStr", &tmpstr, &tmplen) < 0) {
|
||||
+ if (py_netsnmp_attr_bytes(session, "ErrorStr", &tmpstr, &tmplen) < 0) {
|
||||
goto done;
|
||||
}
|
||||
|
||||
@@ -2015,7 +2041,7 @@ netsnmp_walk(PyObject *self, PyObject *a
|
||||
vars, tp, type, sprintval_flag);
|
||||
str_buf[len] = '\0';
|
||||
|
||||
- py_netsnmp_attr_set_string(varbind, "val", (char *) str_buf,
|
||||
+ py_netsnmp_attr_set_bytes(varbind, "val", (char *) str_buf,
|
||||
len);
|
||||
|
||||
/* push the varbind onto the return varbinds */
|
||||
@@ -2266,7 +2292,7 @@ netsnmp_getbulk(PyObject *self, PyObject
|
||||
|
||||
__get_type_str(type, type_str);
|
||||
|
||||
- py_netsnmp_attr_set_string(varbind, "type", type_str,
|
||||
+ py_netsnmp_attr_set_bytes(varbind, "type", type_str,
|
||||
strlen(type_str));
|
||||
|
||||
len = __snprint_value((char **)&str_buf, &str_buf_len,
|
||||
@@ -2409,7 +2435,7 @@ netsnmp_set(PyObject *self, PyObject *ar
|
||||
}
|
||||
}
|
||||
|
||||
- if (py_netsnmp_attr_string(varbind, "val", &val, &tmplen) < 0) {
|
||||
+ if (py_netsnmp_attr_bytes(varbind, "val", &val, &tmplen) < 0) {
|
||||
snmp_free_pdu(pdu);
|
||||
goto done;
|
||||
}
|
||||
@@ -2467,7 +2493,6 @@ netsnmp_set(PyObject *self, PyObject *ar
|
||||
return (ret ? ret : Py_BuildValue(""));
|
||||
}
|
||||
|
||||
-
|
||||
static PyMethodDef ClientMethods[] = {
|
||||
{"session", netsnmp_create_session, METH_VARARGS,
|
||||
"create a netsnmp session."},
|
||||
@@ -2490,10 +2515,23 @@ static PyMethodDef ClientMethods[] = {
|
||||
{NULL, NULL, 0, NULL} /* Sentinel */
|
||||
};
|
||||
|
||||
+static struct PyModuleDef ModuleDefinition = {
|
||||
+ PyModuleDef_HEAD_INIT,
|
||||
+ "client_intf",
|
||||
+ NULL,
|
||||
+ -1,
|
||||
+ ClientMethods,
|
||||
+ NULL,
|
||||
+ NULL,
|
||||
+ NULL,
|
||||
+ NULL
|
||||
+};
|
||||
+
|
||||
PyMODINIT_FUNC
|
||||
-initclient_intf(void)
|
||||
+PyInit_client_intf(void)
|
||||
{
|
||||
- (void) Py_InitModule("client_intf", ClientMethods);
|
||||
+ PyObject *module = PyModule_Create(&ModuleDefinition);
|
||||
+ return module;
|
||||
}
|
||||
|
||||
|
||||
diff -urNp a/python/netsnmp/client.py b/python/netsnmp/client.py
|
||||
--- a/python/netsnmp/client.py 2018-07-18 17:11:53.262147321 +0200
|
||||
+++ b/python/netsnmp/client.py 2018-07-18 17:37:10.489221397 +0200
|
||||
@@ -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):
|
||||
@@ -55,7 +55,7 @@ class Varbind(object):
|
||||
def __init__(self, tag=None, iid=None, val=None, type_arg=None):
|
||||
self.tag = STR(tag)
|
||||
self.iid = STR(iid)
|
||||
- self.val = STR(val)
|
||||
+ self.val = val
|
||||
self.type = STR(type_arg)
|
||||
# parse iid out of tag if needed
|
||||
if iid is None and tag is not None:
|
||||
@@ -65,7 +65,10 @@ class Varbind(object):
|
||||
(self.tag, self.iid) = match.group(1, 2)
|
||||
|
||||
def __setattr__(self, name, val):
|
||||
- self.__dict__[name] = STR(val)
|
||||
+ if name == 'val':
|
||||
+ self.__dict__[name] = val
|
||||
+ else:
|
||||
+ self.__dict__[name] = STR(val)
|
||||
|
||||
def __str__(self):
|
||||
return obj_to_str(self)
|
||||
@@ -132,7 +135,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 -urNp a/python/netsnmp/__init__.py b/python/netsnmp/__init__.py
|
||||
--- a/python/netsnmp/__init__.py 2018-07-18 17:11:53.262147321 +0200
|
||||
+++ b/python/netsnmp/__init__.py 2018-07-18 17:37:32.553172525 +0200
|
||||
@@ -1 +1 @@
|
||||
-from client import *
|
||||
+from .client import *
|
||||
diff -urNp a/python/netsnmp/tests/test.py b/python/netsnmp/tests/test.py
|
||||
--- a/python/netsnmp/tests/test.py 2018-07-18 17:11:53.263147318 +0200
|
||||
+++ b/python/netsnmp/tests/test.py 2018-07-18 17:38:21.272063355 +0200
|
||||
@@ -12,7 +12,7 @@ def snmp_dest(**kwargs):
|
||||
'DestHost': 'localhost:' + os.environ.get("SNMP_SNMPD_PORT", 161),
|
||||
'Community': 'public',
|
||||
}
|
||||
- for key, value in kwargs.iteritems():
|
||||
+ for key, value in kwargs.items():
|
||||
dest[key] = value
|
||||
return dest
|
||||
|
||||
@@ -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 -urNp a/python/setup.py b/python/setup.py
|
||||
--- a/python/setup.py 2018-07-18 17:11:53.262147321 +0200
|
||||
+++ b/python/setup.py 2018-07-18 17:40:36.922751382 +0200
|
||||
@@ -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) #tabs
|
||||
intree=1
|
||||
|
||||
if intree:
|
||||
@ -1,30 +0,0 @@
|
||||
Don't check tests which depend on DNS - it's disabled in Koji
|
||||
|
||||
diff -urNp a/testing/fulltests/default/T070com2sec_simple b/testing/fulltests/default/T070com2sec_simple
|
||||
--- a/testing/fulltests/default/T070com2sec_simple 2018-07-18 11:52:56.081185545 +0200
|
||||
+++ b/testing/fulltests/default/T070com2sec_simple 2018-07-18 11:54:18.843968880 +0200
|
||||
@@ -134,6 +134,10 @@ SAVECHECKAGENT '<"c406a", 255.255.255.25
|
||||
SAVECHECKAGENT 'line 30: Error:' # msg from h_strerror so it varies
|
||||
SAVECHECKAGENT 'line 31: Error:' # msg from h_strerror so it varies
|
||||
|
||||
+FINISHED
|
||||
+
|
||||
+# don't test the rest, it depends on DNS, which is not available in Koji
|
||||
+
|
||||
CHECKAGENT '<"c408a"'
|
||||
if [ "$snmp_last_test_result" -eq 0 ] ; then
|
||||
CHECKAGENT 'line 32: Error:'
|
||||
diff -urNp a/testing/fulltests/default/T071com2sec6_simple b/testing/fulltests/default/T071com2sec6_simple
|
||||
--- a/testing/fulltests/default/T071com2sec6_simple 2018-07-18 11:52:56.080185548 +0200
|
||||
+++ b/testing/fulltests/default/T071com2sec6_simple 2018-07-18 11:55:17.779818732 +0200
|
||||
@@ -132,6 +132,10 @@ SAVECHECKAGENT '<"c606a", ffff:ffff:ffff
|
||||
SAVECHECKAGENT 'line 27: Error:'
|
||||
SAVECHECKAGENT 'line 28: Error:'
|
||||
|
||||
+FINISHED
|
||||
+
|
||||
+# don't test the rest, it depends on DNS, which is not available in Koji
|
||||
+
|
||||
# 608
|
||||
CHECKAGENT '<"c608a"'
|
||||
if [ "$snmp_last_test_result" -eq 0 ] ; then
|
||||
Binary file not shown.
BIN
net-snmp-5.9.1.tar.gz
Normal file
BIN
net-snmp-5.9.1.tar.gz
Normal file
Binary file not shown.
@ -2,8 +2,8 @@
|
||||
%global multilib_arches x86_64 aarch64
|
||||
|
||||
Name: net-snmp
|
||||
Version: 5.8
|
||||
Release: 15
|
||||
Version: 5.9.1
|
||||
Release: 1
|
||||
Epoch: 1
|
||||
Summary: SNMP Daemon
|
||||
License: BSD
|
||||
@ -19,41 +19,37 @@ Source7: net-snmp-tmpfs.conf
|
||||
Source8: snmpd.service
|
||||
Source9: snmptrapd.service
|
||||
Source10: IETF-MIB-LICENSE.txt
|
||||
Patch1: net-snmp-5.7.2-pie.patch
|
||||
Patch2: net-snmp-5.8-dir-fix.patch
|
||||
Patch3: net-snmp-5.8-multilib.patch
|
||||
Patch4: net-snmp-5.8-test-debug.patch
|
||||
Patch5: net-snmp-5.7.2-autoreconf.patch
|
||||
Patch6: net-snmp-5.8-agentx-disconnect-crash.patch
|
||||
Patch7: net-snmp-5.7.2-cert-path.patch
|
||||
Patch8: net-snmp-5.8-cflags.patch
|
||||
Patch9: net-snmp-5.8-Remove-U64-typedef.patch
|
||||
Patch10: net-snmp-5.8-libnetsnmptrapd-against-MYSQL_LIBS.patch
|
||||
Patch11: net-snmp-5.7.3-iterator-fix.patch
|
||||
Patch12: net-snmp-5.8-autofs-skip.patch
|
||||
Patch13: net-snmp-5.8-modern-rpm-api.patch
|
||||
Patch14: net-snmp-5.8-python3.patch
|
||||
|
||||
Patch15: avoid-triggering-undefined-shift-left.patch
|
||||
Patch16: CVE-2019-20892-1.patch
|
||||
Patch17: CVE-2019-20892-2.patch
|
||||
Patch18: CVE-2019-20892-3.patch
|
||||
Patch19: CVE-2019-20892-4.patch
|
||||
Patch20: CVE-2019-20892-5.patch
|
||||
Patch21: CVE-2019-20892-6.patch
|
||||
Patch22: CVE-2020-15862.patch
|
||||
Patch23: CVE-2020-15861.patch
|
||||
Patch1: backport-net-snmp-5.9-pie.patch
|
||||
Patch2: backport-net-snmp-5.9-dir-fix.patch
|
||||
Patch3: backport-net-snmp-5.9-multilib.patch
|
||||
Patch4: backport-net-snmp-5.9-test-debug.patch
|
||||
Patch5: backport-net-snmp-5.7.2-cert-path.patch
|
||||
Patch6: backport-net-snmp-5.9-cflags.patch
|
||||
Patch7: backport-net-snmp-5.8-Remove-U64-typedef.patch
|
||||
Patch8: backport-net-snmp-5.9-libnetsnmptrapd-against-MYSQL_LIBS.patch
|
||||
Patch9: backport-net-snmp-5.7.3-iterator-fix.patch
|
||||
Patch10: backport-net-snmp-5.9-autofs-skip.patch
|
||||
Patch12: backport-net-snmp-5.9-usage-exit.patch
|
||||
Patch13: backport-net-snmp-5.9-coverity.patch
|
||||
Patch15: backport-net-snmp-5.9-dskTable-dynamic.patch
|
||||
Patch16: backport-net-snmp-5.8-expand-SNMPCONFPATH.patch
|
||||
Patch17: backport-net-snmp-5.8-duplicate-ipAddress.patch
|
||||
Patch18: backport-net-snmp-5.9-memory-reporting.patch
|
||||
Patch19: backport-net-snmp-5.8-man-page.patch
|
||||
Patch20: backport-net-snmp-5.8-ipAddress-faster-load.patch
|
||||
Patch21: backport-net-snmp-5.8-rpm-memory-leak.patch
|
||||
Patch22: backport-net-snmp-5.9-aes-config.patch
|
||||
Patch23: backport-net-snmp-5.8-modern-rpm-api.patch
|
||||
Patch24: backport-net-snmp-5.9-python3.patch
|
||||
Patch25: backport-libsnmp-Fix-more-undefined-behavior-in-asn_build_int.patch
|
||||
Patch26: backport-libsnmp-Fix-undefined-behavior-in-asn_build_int.patch
|
||||
Patch27: backport-libsnmp-Rework-parse_imports.patch
|
||||
Patch28: backport-libsnmp-Increase-MAX_IMPORTS.patch
|
||||
Patch29: backport-libsnmp-Allocate-the-module-import-list-on-the-heap.patch
|
||||
Patch30: backport-libsnmp-Fix-a-memory-leak-in-a-MIB-parser-error-path.patch
|
||||
Patch31: backport-libsnmp-Fix-the-getoid-error-path.patch
|
||||
Patch32: backport-Python-Fix-snmpwalk-with-UseNumeric-1.patch
|
||||
|
||||
%{?systemd_requires}
|
||||
BuildRequires: systemd gcc openssl-devel bzip2-devel elfutils-devel libselinux-devel
|
||||
BuildRequires: elfutils-libelf-devel rpm-devel perl-devel perl(ExtUtils::Embed) procps
|
||||
BuildRequires: elfutils-libelf-devel rpm-devel perl-devel perl(ExtUtils::Embed) procps pcre-devel
|
||||
BuildRequires: python3-devel python3-setuptools chrpath mariadb-connector-c-devel net-tools
|
||||
BuildRequires: perl(TAP::Harness) lm_sensors-devel autoconf automake
|
||||
Requires: perl(:MODULE_COMPAT_%(eval "`%{__perl} -V:version`"; echo $version))
|
||||
@ -208,9 +204,8 @@ for file in README COPYING; do
|
||||
iconv -f 8859_1 -t UTF-8 <$file >$file.utf8
|
||||
mv $file.utf8 $file
|
||||
done
|
||||
chmod 644 local/passtest local/ipf-mod.pl
|
||||
mkdir -p %{buildroot}/usr/include/net-snmp/agent/util_funcs
|
||||
install -m 644 agent/mibgroup/util_funcs/*.h %{buildroot}/usr/include/net-snmp/agent/util_funcs
|
||||
chmod 644 local/ipf-mod.pl
|
||||
chmod 755 local/passtest
|
||||
|
||||
mkdir -p %{buildroot}/%{_tmpfilesdir}
|
||||
install -m 644 %SOURCE7 %{buildroot}/%{_tmpfilesdir}/net-snmp.conf
|
||||
@ -274,9 +269,9 @@ LD_LIBRARY_PATH=%{buildroot}/%{_libdir} make test
|
||||
%files devel
|
||||
%attr(0644,root,root)
|
||||
%attr(0755,root,root) %{_bindir}/net-snmp-config*
|
||||
%{_includedir}/net-snmp/*
|
||||
%{_includedir}/ucd-snmp/*.h
|
||||
%{_includedir}/*
|
||||
%{_libdir}/libnet*.so
|
||||
%{_libdir}/pkgconfig/*
|
||||
|
||||
%files perl
|
||||
%{_bindir}/mib2c*
|
||||
@ -300,7 +295,7 @@ LD_LIBRARY_PATH=%{buildroot}/%{_libdir} make test
|
||||
|
||||
%files -n python3-net-snmp
|
||||
%doc README
|
||||
%{_libdir}/python%{python3_version}/site-packages/*
|
||||
%{python3_sitearch}/*
|
||||
|
||||
%files help
|
||||
%doc ChangeLog.trimmed EXAMPLE.conf FAQ NEWS TODO README.snmpv3
|
||||
@ -329,6 +324,12 @@ LD_LIBRARY_PATH=%{buildroot}/%{_libdir} make test
|
||||
%{_mandir}/man1/fixproc*
|
||||
|
||||
%changelog
|
||||
* Thu Dec 16 2021 gaihuiying <gaihuiying1@huawei.com> - 5.9.1-1
|
||||
- Type:requirement
|
||||
- CVE:NA
|
||||
- SUG:NA
|
||||
- DESC:update net-snmp to 5.9.1
|
||||
|
||||
* Fri Sep 17 2021 gaihuiying <gaihuiying1@huawei.com> - 5.8-15
|
||||
- Type:bugfix
|
||||
- CVE:NA
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user