- Decouple snmp-mibs from net-snmp version to allow major version upgrade (bsc#1196955). - Fix LFH violation during v3 user creation (bsc#1181591). Add net-snmp-5.9.1-fix-create-v3-user-outfile.patch - Fix subagent crash at save_set_var() (bsc#1178021). Add net-snmp-5.9.1-subagent-set-response.patch - Fix missing sysconfig files creation (bsc#1108471). - Rename patches to version number 5.9.1: delete: * net-snmp-5.8-socket-path.patch * net-snmp-5.8-testing-empty-arptable.patch * net-snmp-5.8-pie.patch * net-snmp-5.8-net-snmp-config-headercheck.patch * net-snmp-5.8-perl-tk-warning.patch * net-snmp-5.8-velocity-mib.patch * net-snmp-5.8-snmpstatus-suppress-output.patch * net-snmp-5.8-fix-Makefile.PL.patch * net-snmp-5.8-modern-rpm-api.patch add: * net-snmp-5.9.1-socket-path.patch * net-snmp-5.9.1-testing-empty-arptable.patch * net-snmp-5.9.1-pie.patch * net-snmp-5.9.1-net-snmp-config-headercheck.patch * net-snmp-5.9.1-perl-tk-warning.patch * net-snmp-5.9.1-velocity-mib.patch * net-snmp-5.9.1-snmpstatus-suppress-output.patch * net-snmp-5.9.1-fix-Makefile.PL.patch * net-snmp-5.9.1-modern-rpm-api.patch OBS-URL: https://build.opensuse.org/request/show/966059 OBS-URL: https://build.opensuse.org/package/show/network:utilities/net-snmp?expand=0&rev=42
188 lines
6.9 KiB
Diff
188 lines
6.9 KiB
Diff
diff -Nurp net-snmp-5.9.1-orig/agent/mibgroup/agentx/subagent.c net-snmp-5.9.1/agent/mibgroup/agentx/subagent.c
|
|
--- net-snmp-5.9.1-orig/agent/mibgroup/agentx/subagent.c 2021-05-26 00:19:35.000000000 +0200
|
|
+++ net-snmp-5.9.1/agent/mibgroup/agentx/subagent.c 2022-03-09 16:44:30.609053225 +0100
|
|
@@ -80,6 +80,7 @@ typedef struct _net_snmpsubagent_magic_s
|
|
struct agent_netsnmp_set_info {
|
|
int transID;
|
|
int mode;
|
|
+ int req_pending;
|
|
int errstat;
|
|
time_t uptime;
|
|
netsnmp_session *sess;
|
|
@@ -190,6 +191,7 @@ save_set_vars(netsnmp_session * ss, nets
|
|
ptr->sess = ss;
|
|
ptr->mode = SNMP_MSG_INTERNAL_SET_RESERVE1;
|
|
ptr->uptime = netsnmp_get_agent_uptime();
|
|
+ ptr->req_pending = 0;
|
|
|
|
ptr->var_list = snmp_clone_varbind(pdu->variables);
|
|
if (ptr->var_list == NULL) {
|
|
@@ -204,6 +206,18 @@ save_set_vars(netsnmp_session * ss, nets
|
|
}
|
|
|
|
struct agent_netsnmp_set_info *
|
|
+pending_trans_set_info(netsnmp_session * sess, netsnmp_pdu *pdu)
|
|
+{
|
|
+ struct agent_netsnmp_set_info *ptr;
|
|
+
|
|
+ for (ptr = Sets; ptr != NULL; ptr = ptr->next)
|
|
+ if (ptr->sess == sess && ptr->transID == pdu->transid)
|
|
+ break;
|
|
+
|
|
+ return ptr;
|
|
+}
|
|
+
|
|
+struct agent_netsnmp_set_info *
|
|
restore_set_vars(netsnmp_session * sess, netsnmp_pdu *pdu)
|
|
{
|
|
struct agent_netsnmp_set_info *ptr;
|
|
@@ -413,6 +427,14 @@ handle_agentx_packet(int operation, nets
|
|
* XXXWWW we have to map this twice to both RESERVE1 and RESERVE2
|
|
*/
|
|
DEBUGMSGTL(("agentx/subagent", " -> testset\n"));
|
|
+ asi = pending_trans_set_info(session, pdu);
|
|
+ if (asi) {
|
|
+ DEBUGMSGTL(("agentx/subagent",
|
|
+ "dropping testset retry for transid 0x%x in mode %d\n",
|
|
+ (unsigned)pdu->transid, asi->mode));
|
|
+ //SNMP_FREE(retmagic); XXX necessary?
|
|
+ return 1;
|
|
+ }
|
|
asi = save_set_vars(session, pdu);
|
|
if (asi == NULL) {
|
|
SNMP_FREE(smagic);
|
|
@@ -434,6 +456,13 @@ handle_agentx_packet(int operation, nets
|
|
send_agentx_error(session, pdu, AGENTX_ERR_PROCESSING_ERROR, 0);
|
|
return 1;
|
|
}
|
|
+ if (asi->req_pending) {
|
|
+ DEBUGMSGTL(("agentx/subagent",
|
|
+ "dropping commitset - request pending for transid 0x%x in mode %d\n",
|
|
+ (unsigned)pdu->transid, asi->mode));
|
|
+ //SNMP_FREE(retmagic); XXX necessary?
|
|
+ return 1;
|
|
+ }
|
|
if (asi->mode != SNMP_MSG_INTERNAL_SET_RESERVE2) {
|
|
SNMP_FREE(smagic);
|
|
snmp_log(LOG_WARNING,
|
|
@@ -456,6 +485,13 @@ handle_agentx_packet(int operation, nets
|
|
send_agentx_error(session, pdu, AGENTX_ERR_PROCESSING_ERROR, 0);
|
|
return 1;
|
|
}
|
|
+ if (asi->req_pending) {
|
|
+ DEBUGMSGTL(("agentx/subagent",
|
|
+ "dropping cleanupset - request pending for transid 0x%x in mode %d\n",
|
|
+ (unsigned)pdu->transid, asi->mode));
|
|
+ //SNMP_FREE(retmagic); XXX necessary?
|
|
+ return 1;
|
|
+ }
|
|
if (asi->mode == SNMP_MSG_INTERNAL_SET_RESERVE1 ||
|
|
asi->mode == SNMP_MSG_INTERNAL_SET_RESERVE2) {
|
|
asi->mode = pdu->command = SNMP_MSG_INTERNAL_SET_FREE;
|
|
@@ -481,6 +517,13 @@ handle_agentx_packet(int operation, nets
|
|
send_agentx_error(session, pdu, AGENTX_ERR_PROCESSING_ERROR, 0);
|
|
return 1;
|
|
}
|
|
+ if (asi->req_pending) {
|
|
+ DEBUGMSGTL(("agentx/subagent",
|
|
+ "dropping undoset - request pending for transid 0x%x in mode %d\n",
|
|
+ (unsigned)pdu->transid, asi->mode));
|
|
+ //SNMP_FREE(retmagic); XXX necessary?
|
|
+ return 1;
|
|
+ }
|
|
asi->mode = pdu->command = SNMP_MSG_INTERNAL_SET_UNDO;
|
|
mycallback = handle_subagent_set_response;
|
|
retmagic = asi;
|
|
@@ -516,6 +559,8 @@ handle_agentx_packet(int operation, nets
|
|
retmagic);
|
|
if (result == 0) {
|
|
snmp_free_pdu( internal_pdu );
|
|
+ } else if (asi) {
|
|
+ asi->req_pending = 1;
|
|
}
|
|
return 1;
|
|
}
|
|
@@ -637,6 +682,7 @@ handle_subagent_set_response(int op, net
|
|
{
|
|
netsnmp_session *retsess;
|
|
struct agent_netsnmp_set_info *asi;
|
|
+ int new_mode;
|
|
int result;
|
|
|
|
if (op != NETSNMP_CALLBACK_OP_RECEIVED_MESSAGE || magic == NULL) {
|
|
@@ -645,15 +691,63 @@ handle_subagent_set_response(int op, net
|
|
|
|
DEBUGMSGTL(("agentx/subagent",
|
|
"handling agentx subagent set response (mode=%d,req=0x%x,"
|
|
- "trans=0x%x,sess=0x%x)\n",
|
|
+ "trans=0x%x,sess=0x%x,magic=%p)\n",
|
|
(unsigned)pdu->command, (unsigned)pdu->reqid,
|
|
- (unsigned)pdu->transid, (unsigned)pdu->sessid));
|
|
+ (unsigned)pdu->transid, (unsigned)pdu->sessid,
|
|
+ magic));
|
|
+
|
|
pdu = snmp_clone_pdu(pdu);
|
|
if (!pdu)
|
|
return 1;
|
|
|
|
asi = (struct agent_netsnmp_set_info *) magic;
|
|
+
|
|
+ DEBUGMSGTL(("agentx/subagent",
|
|
+ "set response in mode %d (errstat %d, req_pending %d)\n",
|
|
+ asi->mode, pdu->errstat, asi->req_pending));
|
|
+
|
|
+ asi->req_pending = 0;
|
|
retsess = asi->sess;
|
|
+
|
|
+ if (!snmp_sess_pointer(retsess) || retsess->sessid != pdu->sessid) {
|
|
+ DEBUGMSGTL(("agentx/subagent",
|
|
+ "session id 0x%x gone for set response (transid 0x%x, reqid 0x%x)\n",
|
|
+ (unsigned)pdu->sessid, (unsigned)pdu->transid, (unsigned)pdu->reqid));
|
|
+
|
|
+ result = 0;
|
|
+
|
|
+ if (!pdu->errstat) {
|
|
+ switch (asi->mode) {
|
|
+ case SNMP_MSG_INTERNAL_SET_RESERVE1:
|
|
+ case SNMP_MSG_INTERNAL_SET_RESERVE2:
|
|
+ new_mode = SNMP_MSG_INTERNAL_SET_FREE;
|
|
+ break;
|
|
+
|
|
+ case SNMP_MSG_INTERNAL_SET_ACTION:
|
|
+ new_mode = SNMP_MSG_INTERNAL_SET_UNDO;
|
|
+ break;
|
|
+
|
|
+ default:
|
|
+ new_mode = 0;
|
|
+ }
|
|
+
|
|
+ if (new_mode) {
|
|
+ asi->mode = pdu->command = new_mode;
|
|
+ result = snmp_async_send(agentx_callback_sess, pdu,
|
|
+ handle_subagent_set_response, asi);
|
|
+ }
|
|
+ }
|
|
+
|
|
+ if (result == 0) {
|
|
+ /* don't need to (or cannot) FREE/UNDO */
|
|
+ free_set_vars(retsess, pdu);
|
|
+ snmp_free_pdu(pdu);
|
|
+ } else {
|
|
+ asi->req_pending = 1;
|
|
+ }
|
|
+ return 1;
|
|
+ }
|
|
+
|
|
asi->errstat = pdu->errstat;
|
|
|
|
if (asi->mode == SNMP_MSG_INTERNAL_SET_RESERVE1) {
|
|
@@ -669,6 +763,8 @@ handle_subagent_set_response(int op, net
|
|
handle_subagent_set_response, asi);
|
|
if (result == 0) {
|
|
snmp_free_pdu( pdu );
|
|
+ } else {
|
|
+ asi->req_pending = 1;
|
|
}
|
|
DEBUGMSGTL(("agentx/subagent",
|
|
" going from RESERVE1 -> RESERVE2\n"));
|