| 1 |
#!/bin/sh |
| 2 |
|
| 3 |
. ../support/simple_eval_tools.sh |
| 4 |
|
| 5 |
HEADER SNMPv3 exactEngineID change and SIGHUP |
| 6 |
|
| 7 |
SKIPIF NETSNMP_DISABLE_SET_SUPPORT |
| 8 |
SKIPIF NETSNMP_NO_WRITE_SUPPORT |
| 9 |
SKIPIFNOT USING_SNMPV3_USMUSER_MODULE |
| 10 |
SKIPIFNOT NETSNMP_CAN_DO_CRYPTO |
| 11 |
SKIPIFNOT NETSNMP_ENABLE_SCAPI_AUTHPRIV |
| 12 |
|
| 13 |
# |
| 14 |
# Begin test |
| 15 |
# |
| 16 |
|
| 17 |
# standard SNMPv3 USM agent configuration |
| 18 |
DEFSECURITYLEVEL=authPriv |
| 19 |
. ./Sv3usmconfigagent |
| 20 |
|
| 21 |
# test user |
| 22 |
NEWUSER=newtestuser |
| 23 |
NEWAUTHPASS=newauthpass |
| 24 |
NEWPRIVPASS=newprivpass |
| 25 |
|
| 26 |
#The "exactEngineID" |
| 27 |
AGENT_ENGINEID=0x8000b85c03049081004b00 |
| 28 |
AGENT_ENGINEID_NEW=0x8000b85c03049081004b01 |
| 29 |
|
| 30 |
#Add user in snmpd.conf and start the agent |
| 31 |
|
| 32 |
CONFIGAGENT exactEngineID $AGENT_ENGINEID |
| 33 |
CONFIGAGENT createUser $NEWUSER $DEFAUTHTYPE $NEWAUTHPASS $DEFPRIVTYPE $NEWPRIVPASS |
| 34 |
CONFIGAGENT rouser $NEWUSER priv |
| 35 |
|
| 36 |
# Start the agent |
| 37 |
STARTAGENT |
| 38 |
|
| 39 |
#Perform snmpget with the configured 'exactEngineID' |
| 40 |
CAPTURE "snmpget -On $SNMP_FLAGS -v 3 -u $NEWUSER -l ap -a $DEFAUTHTYPE \ |
| 41 |
-A $NEWAUTHPASS -x $DEFPRIVTYPE -X $NEWPRIVPASS -e $AGENT_ENGINEID \ |
| 42 |
$SNMP_TRANSPORT_SPEC:$SNMP_TEST_DEST$SNMP_SNMPD_PORT 1.3.6.1.6.3.10.2.1.1.0" |
| 43 |
CHECKORDIE ".1.3.6.1.6.3.10.2.1.1.0 = Hex-STRING: 80 00 B8 5C 03 04 90 81 00 4B 00" |
| 44 |
|
| 45 |
#Remove the old exactEngineID i.e $AGENT_ENGINEID |
| 46 |
sed '/exactEngineID/d' $SNMP_CONFIG_FILE >$SNMP_CONFIG_FILE.new |
| 47 |
mv $SNMP_CONFIG_FILE.new $SNMP_CONFIG_FILE |
| 48 |
|
| 49 |
#Modify the 'exactEngineID' to a new value |
| 50 |
CONFIGAGENT exactEngineID $AGENT_ENGINEID_NEW |
| 51 |
|
| 52 |
#Send SIGHUP and validate the snmpget with the modified and the old 'exactEngineID' |
| 53 |
if ISDEFINED HAVE_SIGHUP; then |
| 54 |
|
| 55 |
HUPAGENT |
| 56 |
DELAY |
| 57 |
|
| 58 |
#Validate snmpget with MODIFIED 'exactEngineID' |
| 59 |
CAPTURE "snmpget -On $SNMP_FLAGS -v 3 -u $NEWUSER -l ap -a $DEFAUTHTYPE \ |
| 60 |
-A $NEWAUTHPASS -x $DEFPRIVTYPE -X $NEWPRIVPASS -e $AGENT_ENGINEID_NEW \ |
| 61 |
$SNMP_TRANSPORT_SPEC:$SNMP_TEST_DEST$SNMP_SNMPD_PORT 1.3.6.1.6.3.10.2.1.1.0" |
| 62 |
CHECKORDIE ".1.3.6.1.6.3.10.2.1.1.0 = Hex-STRING: 80 00 B8 5C 03 04 90 81 00 4B 01" |
| 63 |
|
| 64 |
#Validate snmpget with OLD 'exactEngineID' |
| 65 |
#snmpget should timeout with OLD enginID. |
| 66 |
CAPTURE "snmpget -On $SNMP_FLAGS -v 3 -u $NEWUSER -l ap -a $DEFAUTHTYPE \ |
| 67 |
-A $NEWAUTHPASS -x $DEFPRIVTYPE -X $NEWPRIVPASS -e $AGENT_ENGINEID \ |
| 68 |
$SNMP_TRANSPORT_SPEC:$SNMP_TEST_DEST$SNMP_SNMPD_PORT 1.3.6.1.6.3.10.2.1.1.0" |
| 69 |
CHECKORDIE "Timeout" |
| 70 |
fi |
| 71 |
|
| 72 |
## stop agent and finish |
| 73 |
STOPAGENT |
| 74 |
FINISHED |