[rancid] HP procurve Menu logon

Marc Boisis-Delavaud marc.boisis at univ-lr.fr
Tue Apr 9 12:17:44 UTC 2013


Hello 

Are these patch are integrated into rancid github repository ?


Le 21 mars 2013 à 13:03, Per-Olof Olsson <peo at chalmers.se> a écrit :

> 
> Not just a small fix make menu login to work.
> Found some more that I think needs to be fixed.
> 
> Now tested on some HP's
> HP2524, H41xx, HP2510, HP2610, HP2620, HP2824, HP2910 och HP2920.
> Telnet and ssh login to operator and manager level.
> Ssh key login to manager level.
> 
> Also tested just hlogin on some Cisco's.
> 
> Look like have this to work.
> 
> How will this new hlogin work for agmrancid and srancid that make
> use of hlogin?
> 
> Files from rancid 2.8.3.
> 
> hrancid:
> - Fix to prevent hrancid from find/parse "Logout"-text from menu.
>  Looks like code is move to WriteTerm and not used any more.
> 
> - Also include ShowReloadAt just to get a proper diff output.
> 
> ===================================================================
> diff -c hrancid.in_ORG hrancid.in_NEW
> *** hrancid.in_ORG      2012-08-29 13:39:33.060145292 +0200
> --- hrancid.in_NEW      2013-03-18 20:18:31.535617594 +0100
> ***************
> *** 168,173 ****
> --- 168,192 ----
>      &ipaddrval($a) <=> &ipaddrval($b);
>  }
> 
> + # This routine parses "show reload at"
> + sub ShowReloadAt {
> +     print STDERR "    In ShowReloadAt: $_" if ($debug);
> +
> +     while (<INPUT>) {
> +       tr/\015//d;
> +       last if (/^$prompt/);
> +       next if (/^(\s*|\s*$cmd\s*)$/);
> +       return(-1) if (/command authorization failed/i);
> +       return(1) if /^(Invalid|Ambiguous) input:/i;
> +
> +       next if (/ \(in /);
> +       next if (/ reload is not scheduled/);
> +
> +       ProcessHistory("COMMENTS","keysort","I0",";$_");
> +     }
> +     return(0);
> + }
> +
>  # This routine parses "show config files"
>  sub ShowConfigFiles {
>      print STDERR "    In ShowConfigFiles: $_" if ($debug);
> ***************
> *** 533,538 ****
> --- 552,558 ----
>        {'show module'                  => 'ShowModule'},
>        {'show stack'                   => 'ShowStack'},
>        {'show tech transceivers'       => 'ShowTechTransceivers'},
> +       {'show reload at'               => 'ShowReloadAt'},
>        {'show config files'            => 'ShowConfigFiles'},
>        {'show config status'           => 'ShowConfigStatus'},
>        {'write term'                   => 'WriteTerm'}
> ***************
> *** 602,614 ****
>  ProcessHistory("COMMENTS","keysort","F0",";\n");      # showstack
>  ProcessHistory("COMMENTS","keysort","G0",";\n");      # showtechtransceivers
>  ProcessHistory("COMMENTS","keysort","H0",";\n");      # showconfigfiles
> ! ProcessHistory("COMMENTS","keysort","I0",";\n");
>  TOP: while(<INPUT>) {
>      tr/\015//d;
> !     if (/$prompt\s*(exit|logout)\s*$/i) {
> !       $clean_run=1;
> !       last;
> !     }
>      if (/^Error:/) {
>        print STDOUT ("$host clogin error: $_");
>        print STDERR ("$host clogin error: $_") if ($debug);
> --- 622,641 ----
>  ProcessHistory("COMMENTS","keysort","F0",";\n");      # showstack
>  ProcessHistory("COMMENTS","keysort","G0",";\n");      # showtechtransceivers
>  ProcessHistory("COMMENTS","keysort","H0",";\n");      # showconfigfiles
> ! ProcessHistory("COMMENTS","keysort","I0",";\n");      # showreloadat
> ! ProcessHistory("COMMENTS","keysort","J0",";\n");
> !
>  TOP: while(<INPUT>) {
>      tr/\015//d;
> !
> ! # Moved to WriteTerm and not removed from here!!!
> ! ## "Logout" text in menu! Don't look for exit or logout before prompt is defined
> ! ##    if (/$prompt\s*(exit|logout)\s*$/i) {
> ! #    if (defined($prompt) && /$prompt\s*(exit|logout)\s*$/i) {
> ! #     print STDERR ("EXIT:$_") if ($debug);
> ! #     $clean_run=1;
> ! #     last;
> ! #    }
>      if (/^Error:/) {
>        print STDOUT ("$host clogin error: $_");
>        print STDERR ("$host clogin error: $_") if ($debug);
> 
> =============================================
> 
> 
> 
> hlogin:
> 
> - Select "Exit to cli" if menu is default for login.
>  Include answer to "save config" prompter before menu is started.
> 
> - Handle some more error text to speed up exit on error.
> 
> - Remove/replace code for two inner expect loops to
>  just have a single expect loop for login.
>  Don't like to duplicate expect code into inner loops.
> 
> - Include fix for "prompt" characters in banner text.
>  Will handle banner text except if it the match "/#\s*($cmds_regexp)\s*$/" in hrancid
> 
> - Speed up logout.  Don't need to use human wait/type speed.
> 
> =============================================
> diff -c hlogin.in_20130318 hlogin.in_NEW
> *** hlogin.in_20130318  2013-02-27 07:56:51.332898135 +0100
> --- hlogin.in_NEW       2013-03-18 20:16:02.286363285 +0100
> ***************
> *** 412,417 ****
> --- 412,427 ----
>            send "\r"
>            exp_continue
>        }
> +       "Do you want to save current configuration" {
> +           send "n"
> +           exp_continue
> +       }
> +       # Menu output "<Enter>" grab all in menu to not match prompter!
> +       -re "(\[0-9])\\. Command Line \\(CLI\\).*" {
> +           set menu_exit "$expect_out(1,string)"
> +           send "$menu_exit"
> +           exp_continue
> +       }
>        -re "(Connection refused|Secure connection \[^\n\r]+ refused|Connection closed by)" {
>            catch {close}; catch {wait};
>            if !$progs {
> ***************
> *** 444,450 ****
>            send_user "\nError: host key mismatch for $router.  Update the SSH known_hosts
> file accordingly.\n"
>            return 1
>        }
> !       eof { send_user "\nError: Couldn't login\n"; wait; return 1 }
>        -nocase "unknown host\r" {
>            catch {close}; catch {wait};
>            send_user "\nError: Unknown host\n"; wait; return 1
> --- 454,483 ----
>            send_user "\nError: host key mismatch for $router.  Update the SSH known_hosts
> file accordingly.\n"
>            return 1
>        }
> !       "Could not resolve hostname" {
> !           send_user "\nError:  Could not resolve hostname $router\n";
> !           catch {close}; catch {wait};
> !           return 1
> !       }
> !       eof {
> !           send_user "\nError: Couldn't login\n";
> !           wait; return 1
> !       }
> !       "Permission denied" {
> !           send_user "\nError: Permission denied. Check your access to $router\n";
> !           catch {close}; catch {wait};
> !           return 1
> !       }
> !       "Invalid password" {
> !           send_user "\nError: Invalid password. Check your passwd for $router\n";
> !           catch {close}; catch {wait};
> !           return 1
> !       }
> !       "Login invalid" {
> !           send_user "\nError: Invalid login\n";
> !           catch {close}; catch {wait};
> !           return 1
> !       }
>        -nocase "unknown host\r" {
>            catch {close}; catch {wait};
>            send_user "\nError: Unknown host\n"; wait; return 1
> ***************
> *** 455,473 ****
>            send -- "$passphrase\r"
>            exp_continue
>        }
> !       -re "$u_prompt" { send -- "$user\r"
> !           expect {
> !               eof                     { send_user "\nError: Couldn't login\n"; wait;
> return 1 }
> !               "Login invalid"         { send_user "\nError: Invalid login\n";
> !                                         catch {close}; catch {wait};
> !                                         return 1 }
> !               -re "$p_prompt"         { send -- "$userpswd\r" }
> !               "$prompt"               { set in_proc 0; return 0 }
> !               "Press any key to continue" {
> !                                         send " "
> !                                         exp_continue
> !                                       }
> !           }
>            exp_continue
>        }
>        -re "$p_prompt" {
> --- 488,498 ----
>            send -- "$passphrase\r"
>            exp_continue
>        }
> !       -re "\[#>]+.*\[\n\r]+" {
> !           exp_continue
> !       }
> !       -re "$u_prompt" {
> !           send -- "$user\r"
>            exp_continue
>        }
>        -re "$p_prompt" {
> ***************
> *** 476,502 ****
>            } else {
>                send -- "$passwd\r"
>            }
> -           expect {
> -               eof             { send_user "\nError: Couldn't login\n";
> -                                 wait;
> -                                 return 1
> -                               }
> -               "Press any key to continue" {
> -                                 send " ";
> -                                 exp_continue
> -                               }
> -               -re "$e_prompt" { send -- "$enapasswd\r" }
> -               "$prompt"       { set in_proc 0;
> -                                 return 0
> -                               }
> -           }
>            exp_continue
>        }
> !       "$prompt"       { break; }
> !       denied          { send_user "\nError: Check your passwd for $router\n"
> !                         catch {close}; catch {wait}; return 1
> !                       }
> !       "% Bad passwords" {send_user "\nError: Check your passwd for $router\n"; return 1 }
>       }
>      }
> 
> --- 501,519 ----
>            } else {
>                send -- "$passwd\r"
>            }
>            exp_continue
>        }
> !       "$prompt" {
> !           break
> !       }
> !       denied {
> !           send_user "\nError: Check your passwd for $router\n"
> !           catch {close}; catch {wait}; return 1
> !       }
> !       "% Bad passwords" {
> !           send_user "\nError: Check your passwd for $router\n"
> !           return 1
> !       }
>       }
>      }
> 
> ***************
> *** 583,589 ****
>        }
>      }
>      log_user 1
> !     send -h "logout\r"
>      expect {
>        "Do you want to save current configuration"     {
>                                                  if {$do_saveconfig} {
> --- 600,606 ----
>        }
>      }
>      log_user 1
> !     send "logout\r"
>      expect {
>        "Do you want to save current configuration"     {
>                                                  if {$do_saveconfig} {
> 
> =============================================
> 
> 
> 
> 
> On 03/04/2013 05:00 PM, Per-Olof Olsson wrote:
>> On 03/02/2013 12:19 AM, heasley wrote:
>>> Thu, Feb 21, 2013 at 08:40:23AM +0100, Per-Olof Olsson:
>>>> Alex DEKKER skrev 02/20/2013 10:19 PM:
>>>>> On 20/02/13 17:43, heasley wrote:
>>>>>> btw, is this menu a standard thing with procurves?  I've never seen it,
>>>>>> but the one that i have is a lower-end model.
>>>>> It's not the default on current Procurves, you can access it with 'menu'. From what Marc
>>>>> is saying, it sounds like there is a way to make it go straight into the menu on login for
>>>>> a given username.
>>>>> 
>>>>> alexd
>>>>> _______________________________________________
>>>>> Rancid-discuss mailing list
>>>>> Rancid-discuss at shrubbery.net
>>>>> http://www.shrubbery.net/mailman/listinfo.cgi/rancid-discuss
>>>> 
>>>> Only setting I found for this is in "8. Run Setup" menu
>>>> where you select "Logon Default" to "CLI" or "Menu"
>>> 
>>> Would you propose a patch for this, since you can test it?
>> 
>> Yes but it will take some time to have it to work and is fully tested.
>> 
>> telnet/ssh login to manager and/or operator level
>> ssh key-login
>> and some switch types.
>> 
>> "5" only works if you do direct login to manager level.
>> Login to operator level needs "3" for "CLI exit".
>> 
>> And one more thing.
>> When you start menu mode and not saved config
>>  "Do you want to save current configuration"-prompt
>> shows up before menu is started, even at login.
>> 
>> ...
>> 
>> Have part of it working but not all.
>> 
>>> 
>>>> /Peo
>>>> ----------------------------------------------------------
>>>> Per-Olof Olsson               Email: peo at chalmers.se
>>>> Chalmers tekniska högskola    IT-service
>>>> Hörsalsvägen 5                412 96 Göteborg
>>>> Tel: 031/772 6738  Fax: 031/772 8660
>>>> ----------------------------------------------------------
>>>> _______________________________________________
>>>> Rancid-discuss mailing list
>>>> Rancid-discuss at shrubbery.net
>>>> http://www.shrubbery.net/mailman/listinfo.cgi/rancid-discuss
>> 
>> 
>> /Peo
>> 
>> 
>> 
>> 
>> _______________________________________________
>> Rancid-discuss mailing list
>> Rancid-discuss at shrubbery.net
>> http://www.shrubbery.net/mailman/listinfo.cgi/rancid-discuss
>> 
> 
> 
> _______________________________________________
> Rancid-discuss mailing list
> Rancid-discuss at shrubbery.net
> http://www.shrubbery.net/mailman/listinfo.cgi/rancid-discuss

Marc Boisis-Delavaud
Direction du Système d'Information
Université de La Rochelle
marc.boisis at univ-lr.fr | 05 46 45 82 14

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.shrubbery.net/pipermail/rancid-discuss/attachments/20130409/4e47bd12/attachment.html>


More information about the Rancid-discuss mailing list