[rancid] #' in my login banner

heasley heas at shrubbery.net
Wed Dec 11 18:51:36 UTC 2013


Wed, Dec 11, 2013 at 07:14:12PM +0100, Per-Olof Olsson:
> Hello
> 
> 
> 
> 
> On 12/11/2013 06:51 PM, Alan McKinnon wrote:
> > I see no-one has responded with an answer to your question.
> > 
> > I think the reason is that code cannot deal with ">" and "#" characters
> > in a banner in any sane way that gives consistent results. For rancid to
> > function properly, it has to know what the shell prompt is exactly for a
> > given device, and to do that it has to parse the entire text output.
> > 
> > The only tool available to detect the prompt is pattern matching which
> > inevitably means a regex. As a perl regex this is
> > 
> > ^[-a-zA-Z0-9]*[>#]
> > 
> > and that's assuming the prompt is the hostname.
> 
> In hlogin I added
> 
> 	-re "\[#>]+.*\[\n\r]+" {
> 		exp_continue
> 	}
> 
> to just pass over none prompter # and >.
> Banner "#" and ">" is followed by CR or NL!
> 
> Works for HPs

I believe that this is timing dependent.  if clogin happens to receive a
portion of a line from the banner:
^foo#bar\n$
(regex anchors for clarity), such as:
^foo#
there is no way for you to know if thats the prompt or if there is more
coming.  I suppose it could wait on the fdesc to see if more has comes, then
decide if its a prompt or not - but, feh!  tcl is haneous.

the best solution, imo, if it hurts, dont do it.  second best would be to add
a cloginrc variable that allows users to set the initial prompt matching regex
tailored to their device's/environment's quirks - for example, it could easily
be "^[^ ]*#".


More information about the Rancid-discuss mailing list