Fixed: [Trying to change the "config false" node through snmpset](https://github.com/clicon/clixon/issues/377)

* Fixed by returning `SNMP_ERR_NOTWRITABLE` when trying to reserve object
This commit is contained in:
Olof hagsand 2022-10-09 11:59:26 +02:00
parent d2c3b903f1
commit aff69127b6
3 changed files with 13 additions and 0 deletions

View file

@ -78,6 +78,8 @@ Developers may need to change their code
### Corrected Bugs ### Corrected Bugs
* Fixed: [Trying to change the "config false" node through snmpset](https://github.com/clicon/clixon/issues/377)
* Fixed by returning `SNMP_ERR_NOTWRITABLE` when trying to reserve object
* Fixed: [Non-obvious behavior of clixon_snmp after snmpset command when transaction validation returns an error](https://github.com/clicon/clixon/issues/375) * Fixed: [Non-obvious behavior of clixon_snmp after snmpset command when transaction validation returns an error](https://github.com/clicon/clixon/issues/375)
* Fixed: [clixon_snmp module crashes on snmpwalk command](https://github.com/clicon/clixon/issues/378) * Fixed: [clixon_snmp module crashes on snmpwalk command](https://github.com/clicon/clixon/issues/378)
* Fixed: [unneeded trailing zero character on SNMP strings](https://github.com/clicon/clixon/issues/367) * Fixed: [unneeded trailing zero character on SNMP strings](https://github.com/clicon/clixon/issues/367)

View file

@ -731,6 +731,10 @@ clixon_snmp_scalar_handler1(netsnmp_mib_handler *handler,
case MODE_GETNEXT: /* 161 */ case MODE_GETNEXT: /* 161 */
break; break;
case MODE_SET_RESERVE1: /* 0 */ case MODE_SET_RESERVE1: /* 0 */
if (!yang_config_ancestor(sh->sh_ys)){
retval = SNMP_ERR_NOTWRITABLE;
goto done;;
}
/* Translate from YANG ys leaf type to SNMP asn1.1 type ids (not value), also cvtype */ /* Translate from YANG ys leaf type to SNMP asn1.1 type ids (not value), also cvtype */
if (type_yang2asn1(sh->sh_ys, &asn1_type, 0) < 0) if (type_yang2asn1(sh->sh_ys, &asn1_type, 0) < 0)
goto done; goto done;
@ -1289,6 +1293,10 @@ clixon_snmp_table_handler1(netsnmp_mib_handler *handler,
} }
break; break;
case MODE_SET_RESERVE1: // 0 case MODE_SET_RESERVE1: // 0
if (!yang_config_ancestor(sh->sh_ys)){
retval = SNMP_ERR_NOTWRITABLE;
goto done;;
}
// Check types: compare type in requestvb to yang type (or do later) // Check types: compare type in requestvb to yang type (or do later)
break; break;
case MODE_SET_RESERVE2: // 1 case MODE_SET_RESERVE2: // 1

View file

@ -290,6 +290,9 @@ expectpart "$($snmpget $OID19)" 0 "$OID19 = Hex-STRING: 74 65 73 74 00"
new "Test SNMP getnext netSnmpHostName" new "Test SNMP getnext netSnmpHostName"
expectpart "$($snmpgetnext $OID19)" 0 "$OID20 = INTEGER: 1" expectpart "$($snmpgetnext $OID19)" 0 "$OID20 = INTEGER: 1"
new "Negative test: Try to set object"
expectpart "$($snmpset $OID1 i 4 2> /dev/null)" 2 "^$"
new "Cleaning up" new "Cleaning up"
testexit testexit