--- clogin-dist Thu Jul 28 10:59:07 2005 +++ clogin Mon Aug 8 11:17:30 2005 @@ -57,6 +57,8 @@ set do_enapasswd 1 # attempt at platform switching. set platform "" +# new option to provide "login" command capabilities +set loginonly 0 # Find the user in the ENV, or use the unix userid. if {[ info exists env(CISCO_USER) ] } { @@ -453,6 +455,39 @@ return 0 } +# New subroutine to provide "login" command capabilities, using the enable user and enable password +# Login +proc do_login { enauser enapasswd } { + global prompt in_proc + global u_prompt e_prompt + set in_proc 1 + + send "login\r" + expect { + -re "$u_prompt" { send "$enauser\r"; exp_continue} + -re "$e_prompt" { send "$enapasswd\r"; exp_continue} + "#" { set prompt "#" } + "(login)" { set prompt "> (login) " } + -re "(denied|Sorry|Incorrect)" { + # % Access denied - from local auth and poss. others + send_user "\nError: Check your Login passwd\n"; + return 1 + } + "% Error in authentication" { + send_user "\nError: Check your Login passwd\n" + return 1 + } + "% Bad passwords" { + send_user "\nError: Check your Login passwd\n" + return 1 + } + } + # We set the prompt variable (above) so script files don't need + # to know what it is. + set in_proc 0 + return 0 +} + # Enable proc do_enable { enauser enapasswd } { global prompt in_proc @@ -638,6 +673,13 @@ } } + # If a "login" option is used, no "enable" will be required + # look for login option in .cloginrc + if { [find login $router] != "" } { + set enable 0 + set loginonly 1 + } + # look for noenable option in .cloginrc if { [find noenable $router] != "" } { set enable 0 @@ -726,6 +768,17 @@ if {[login $router $ruser $userpswd $passwd $enapasswd $cmethod $cyphertype]} { continue } + + # login required? + if { $loginonly } { + if {[do_login $enauser $enapasswd]} { + if { $do_command || $do_script } { + close; wait + continue + } + } + } + if { $enable } { if {[do_enable $enauser $enapasswd]} { if { $do_command || $do_script } { @@ -734,6 +787,7 @@ } } } + # we are logged in, now figure out the full prompt send "\r" expect {