[rancid] clogin bug in $prompt matching, does not work well IOS XR

Kristian Larsson kristian at spritelink.net
Tue Jan 20 17:33:01 UTC 2009


Hello!

I have found what I believe is a bug in clogin.

When using clogin to automatically send commands
and retrieve its output from an IOS XR device the
prompt is not correctly parsed.

When clogin first logs in, it sends a simple
carriage return (\n) to the router to be able to
determine the prompt. Here's an strace of that..

recvfrom(3, "RP/0/RP1/CPU0:AMS-CORE-1#", 6938, 0, NULL, NULL) = 25
write(1, "RP/0/RP1/CPU0:AMS-CORE-1#", 25) = 25
read(0, "\r", 8177)                     = 1
sendto(3, "\r\0", 2, 0, NULL, 0)        = 2
recvfrom(3, "\r\n\rRP/0/RP1/CPU0:AMS-CORE-1#", 6913, 0, NULL, NULL) = 28
write(1, "\r\n\rRP/0/RP1/CPU0:AMS-CORE-1#", 28) = 28

So far, everything is fine and dandy. The router
is obviously called ams-core-1 and it has the 
prompt RP/0/RP1/CPU0:AMS-CORE-1# which clogin
correctly identifies.
Here comes the next part, clogin sends 'terminal
length 0'...

read(0, "terminal length 0\r", 8176)    = 18
sendto(3, "terminal length 0\r\0", 19, 0, NULL, 0) = 19
recvfrom(3, "terminal\rRP/0/RP1/CPU0:AMS-CORE-1#terminal length\rRP/0/RP1/CPU0:AMS-CORE-1#terminal length 0\r\n\r", 6885, 0, NULL, NULL) = 95

So it reads 'terminal length 0' from clogin, sends
it to the CRS and then receives the output.

Now, IOS XR does one thing a tad differently than
IOS, it has command completion on the space key
as well as on the tab key. My guess is that this 
mechanism forces the IOS XR CLI to redraw the line
each and every time a space is entered. 
If we examine the recvfrom line

recvfrom(3, "terminal\rRP/0/RP1/CPU0:AMS-CORE-1#terminal length\rRP/0/RP1/CPU0:AMS-CORE-1#terminal length 0\r\n\r", 6885, 0, NULL, NULL) = 95

we see that "terminal" is first echoed back to
the client. Then, as a space was entered, IOS XR
does a carriage return and redraws the entire line
starting with the prompt and filling up with 
"terminal length" and the same thing over again to
"terminal length 0".

As clogin merely looks for $prompt which is 
'RP/0/RP1/CPU0:AMS-CORE-1#', it will get a match 
several times over and is thus unable to interpret
the situation correctly.

I've tried modifying clogin in several ways
 - adding \n to prompt or several of the places 
where $prompt is used and so forth but so far 
without much luck. My TCL-fu is not strong enough.

Could some TCL guru have a look at this? I could
probably arrange access to an IOS XR device for 
testing.

Oh, I'm running clogin version 2.3.2a9

Kind regards,
   Kristian.

-- 
Kristian Larsson                                        KLL-RIPE
Network Engineer / Internet Core        Tele2 / SWIPnet [AS1257]
+46 704 910401			              kll at spritelink.net


More information about the Rancid-discuss mailing list