Discussion:
[rancid] jlogin and root shell
Dale Shaw
2010-05-06 22:25:47 UTC
Permalink
Hi all,

[ I admit to not having done a thorough search through the archives on
this one -- apologies if the answer is out there already, or -gulp-
it's a FAQ ]

Can jlogin handle the situation where the 'root' user is used to
authenticate and is subsequently dropped into a shell, as distinct
from the JUNOS CLI?

cheers,
Dale
john heasley
2010-05-07 00:23:47 UTC
Permalink
Post by Dale Shaw
Hi all,
[ I admit to not having done a thorough search through the archives on
this one -- apologies if the answer is out there already, or -gulp-
it's a FAQ ]
Can jlogin handle the situation where the 'root' user is used to
authenticate and is subsequently dropped into a shell, as distinct
from the JUNOS CLI?
no, it 100% expects the cli.
Post by Dale Shaw
cheers,
Dale
_______________________________________________
Rancid-discuss mailing list
http://www.shrubbery.net/mailman/listinfo.cgi/rancid-discuss
Ernest Johanson
2010-05-07 16:41:10 UTC
Permalink
Dale,

I have a Juniper EX4200 that doesn't automatically launch the cli. The
following worked for me. I also had to set TERM=xterm in rancid.conf.

--Ernie Johanson

--- jlogin.orig 2010-05-07 09:29:37.000000000 -0700
+++ jlogin 2010-05-07 09:29:37.000000000 -0700
@@ -285,7 +285,7 @@
# Log into the router.
# returns: 0 on success, 1 on failure
proc login { router user passwd cmethod cyphertype identfile} {
- global spawn_id in_proc do_command do_script passphrase prompt
+ global spawn_id in_proc do_command do_script passphrase prompt
sys_prompt
global sshcmd
set in_proc 1

@@ -405,7 +405,13 @@
sleep 1; send
"$passwd\r"
exp_continue
}
- -re "$prompt" { break; }
+ # We define an additional prompt if the switch doesn't
+ # start the cli by default
+ -re "$sys_prompt" { break; }
+
+ # Standard cli prompt
+ -re "$prompt" { break; }
+
denied { send_user "\nError: Check your password for
$router\n"
catch {close}; catch {wait}; return 1
}
@@ -416,7 +422,14 @@
send "\r"
expect {
-re "(\r\n|\n)" { exp_continue; }
- -re "^\[^ ]+$prompt" { set prompt $expect_out(0,string);
+
+ # If we get the system prompt, launch the cli
+
+ -re ".+$sys_prompt" { sleep 1; send "cli\r";
+ exp_continue;
+ }
+ -re ".+$prompt"
+ { set prompt $expect_out(0,string);
regsub ">" $prompt "\[#>]" prompt;
}
}
@@ -427,7 +440,7 @@

# Run commands given on the command line.
proc run_commands { prompt command } {
- global in_proc
+ global in_proc sys_prompt
set in_proc 1

send "set cli complete-on-space off\r"
@@ -458,6 +471,11 @@
}
send "quit\r"
expect {
+ -re ".+$sys_prompt" {
+ sleep 1 ; send "exit\r"
;
+ catch {close}; catch
{wait};
+ return 0
+ }
"\n" { exp_continue }
timeout { catch {close}; catch
{wait};
return 0
@@ -479,6 +497,11 @@

set prompt ">"

+ # If the switch doesn't automatically
+ # launch the cli, we'll get a system prompt
+
+ set sys_prompt "%"
+
# Figure out username
if {[info exists username]} {
# command line username

#--------------------- end diff -----------------------------------------
Date: Fri, 7 May 2010 08:25:47 +1000
Subject: [rancid] jlogin and root shell
Hi all,
[ I admit to not having done a thorough search through the archives on
this one -- apologies if the answer is out there already, or -gulp-
it's a FAQ ]
Can jlogin handle the situation where the 'root' user is used to
authenticate and is subsequently dropped into a shell, as distinct
from the JUNOS CLI?
cheers,
Dale
_______________________________________________
Rancid-discuss mailing list
http://www.shrubbery.net/mailman/listinfo.cgi/rancid-discuss
Loading...