scotty-2.0.2: bugs in configuring an SNMP session

Robert Premuz (rpremuz@srce.hr)
Sat, 13 Apr 1996 17:15:21 +0200 (MET DST)

Hello everybody,

This is a report of two bugs in scotty-2.0.2 regarding configuring an
SNMP session. They appear in the following Scotty commands (as
described in the scotty(1) man page):

snmp session [options] --> configures a session at its creation
snmp# configure [options] --> configures a created session

The both commands may use aliases for configuration options. The
aliases are defined using:

snmp alias [name [options]]

In fact, I would prefer to describe this command as

snmp alias [name [option_list]]

because the configuration options which define an alias must be
specified as a Tcl list, while the configuration options for the 'snmp
session' and 'snmp# configure' commands must be specified as separated
arguments.

Now, the bugs. First, the -community option forces configuring an
SNMPv1 session, but the community may also be used in an SNMPv2C
session.

The second bug appears in case a wrong configuration option is
specified after an alias. The current configuration options appear in
front of the error message regarding the wrong option.

It seems to me that the ConfigSession() function in
scotty-2.0.2/snmp/snmpTcl.c file is responsible for the bug and I
suggest the following patch (which is the output of
'diff -c snmpTcl.c.orig snmpTcl.c'):

------------------------------cut-here--------------------------------
*** snmpTcl.c.orig Sat Apr 6 09:30:00 1996
--- snmpTcl.c Sat Apr 13 16:47:50 1996
***************
*** 815,820 ****
--- 815,825 ----
if (code != TCL_OK) {
return code;
}
+
+ /* Clear the result of the above recursive call to ConfigSession()
+ */
+ Tcl_ResetResult (interp);
+
continue;
}

***************
*** 950,956 ****
*/

if (!strncmp (*argv, "-community", len)) {
- session->version = SNMPv1;
if (--argc <= 0 || **++argv == '-') {
Tcl_SetResult (interp, "community string missing", TCL_STATIC);
return TCL_ERROR;
--- 955,960 ----
***************
*** 1202,1208 ****
*/

if (! strncmp (*argv, "-version", len)) {
- int num;
if (--argc <= 0 || **++argv == '-') {
Tcl_SetResult (interp, "missing version parameter",
TCL_STATIC);
--- 1206,1211 ----
------------------------------cut-here--------------------------------

Run the example script at the end of the message before and after
applying the patch to experience the bugs.

Regards,
v
-- rpr. : Robert B. Premuz
Internet: rpremuz@malik.srce.hr * Voice at home: +385 (0)1 687564

P.S. Strange heavy snowing here in the northern part of Croatia this
mid-April.

------------------------------cut-here--------------------------------
#!/usr/local/bin/scotty -f
#
# show bugs in configuring an SNMP session

set sess1 [snmp session -version SNMPv2C -community A]
puts [$sess1 configure]

set sess2 [snmp session -community A -version SNMPv2C]
puts [$sess2 configure]

snmp alias options1 {-version SNMPv2C -community A}
set sess1 [snmp session -alias options1]
puts [$sess1 configure]

snmp alias options2 {-community A -version SNMPv2C}
set sess2 [snmp session -alias options2]
puts [$sess2 configure]

$sess1 configure -version SNMPv2C -community A
puts [$sess1 configure]

$sess2 configure -community A -version SNMPv2C
puts [$sess2 configure]

$sess1 configure -alias options1
puts [$sess1 configure]

$sess2 configure -alias options2
puts [$sess2 configure]

puts ""
if [catch {$sess1 configure -port 777 -alias options1 -timeout 10 -port X}] {
puts "Error: $errorInfo"
}

puts ""
if [catch {$sess1 configure -port 777 -port X -alias options1 -timeout 10}] {
puts "Error: $errorInfo"
}

exit
------------------------------cut-here--------------------------------