Discussion:
[rancid] Submission: Modification to MTLOGIN to allow port# selection and longer line width count (for system package detail print)
Ehud Gavron
2015-07-11 23:51:55 UTC
Permalink
The following patch allows
"add method ip.address.goes.here ssh:nnnn" for MikroTik routers.
It also extends the line width so that wide line (200 characters)
responses don't mess up rancid.

Ehud Gavron

--- /usr/libexec/rancid/mtlogin 2015-05-30 11:16:40.000000000 -0700
+++ /home/rancid2/bin/mtlogin 2015-05-15 15:14:01.923740909 -0700
@@ -309,9 +309,16 @@
send_user "\nError: telnet failed: $reason\n"
return 1
}
- } elseif ![string compare $prog "ssh"] {
- if [ catch {spawn $sshcmd -c $cyphertype -x -l $user+ct $router} reason ] {
- send_user "\nError: $sshcmd failed: $reason\n"
+ } elseif [string match "ssh*" $prog] {
+ regexp {ssh(:([^[:space:]]+))*} $prog methcmd suffix port
+ set cmd $sshcmd
+ if {"$port" != ""} {
+ set retval [ catch {spawn $sshcmd -p $port -c $cyphertype -x -l $user+ct200w $router} reason ]
+ } else {
+ set retval [ catch {spawn $sshcmd -c $cyphertype -x -l $user+ct200w $router} reason ]
+ }
+ if { $retval } {
+ send_user "\nError: $sshcmd failed: $reason\n"
return 1
}
} elseif ![string compare $prog "rsh"] {
@@ -382,7 +389,7 @@
return 1 }

-re "$u_prompt" {
- send -- "$user+ct\r"
+ send -- "$user+ct200w\r"
set uprompt_seen 1
exp_continue
}
heasley
2015-07-13 22:01:01 UTC
Permalink
Post by Ehud Gavron
The following patch allows
"add method ip.address.goes.here ssh:nnnn" for MikroTik routers.
It also extends the line width so that wide line (200 characters)
responses don't mess up rancid.
Ehud Gavron
--- /usr/libexec/rancid/mtlogin 2015-05-30 11:16:40.000000000 -0700
+++ /home/rancid2/bin/mtlogin 2015-05-15 15:14:01.923740909 -0700
@@ -309,9 +309,16 @@
send_user "\nError: telnet failed: $reason\n"
return 1
}
- } elseif ![string compare $prog "ssh"] {
- if [ catch {spawn $sshcmd -c $cyphertype -x -l $user+ct $router} reason ] {
- send_user "\nError: $sshcmd failed: $reason\n"
+ } elseif [string match "ssh*" $prog] {
+ regexp {ssh(:([^[:space:]]+))*} $prog methcmd suffix port
+ set cmd $sshcmd
+ if {"$port" != ""} {
+ set retval [ catch {spawn $sshcmd -p $port -c $cyphertype -x -l $user+ct200w $router} reason ]
+ } else {
+ set retval [ catch {spawn $sshcmd -c $cyphertype -x -l $user+ct200w $router} reason ]
+ }
+ if { $retval } {
+ send_user "\nError: $sshcmd failed: $reason\n"
return 1
}
} elseif ![string compare $prog "rsh"] {
we already have this for 3.2. copy attached.
Post by Ehud Gavron
@@ -382,7 +389,7 @@
return 1 }
-re "$u_prompt" {
- send -- "$user+ct\r"
+ send -- "$user+ct200w\r"
set uprompt_seen 1
exp_continue
}
that is a bizarre platform. is it wrapping long lines, truncating or
discarding? Is there any reason that this username feature may not be
supported? eg: a minimum version, etc.
Ehud Gavron
2015-07-13 22:06:57 UTC
Permalink
Thanks! Sadly our RHEL6 and other servers are running 3.1...

Next time I'll check your source tree before duplicating effort on a feature
you've already added :)

Thank you for the work!

E
Post by heasley
Post by Ehud Gavron
The following patch allows
"add method ip.address.goes.here ssh:nnnn" for MikroTik routers.
It also extends the line width so that wide line (200 characters)
responses don't mess up rancid.
Ehud Gavron
--- /usr/libexec/rancid/mtlogin 2015-05-30 11:16:40.000000000 -0700
+++ /home/rancid2/bin/mtlogin 2015-05-15 15:14:01.923740909 -0700
@@ -309,9 +309,16 @@
send_user "\nError: telnet failed: $reason\n"
return 1
}
- } elseif ![string compare $prog "ssh"] {
- if [ catch {spawn $sshcmd -c $cyphertype -x -l $user+ct $router} reason ] {
- send_user "\nError: $sshcmd failed: $reason\n"
+ } elseif [string match "ssh*" $prog] {
+ regexp {ssh(:([^[:space:]]+))*} $prog methcmd suffix port
+ set cmd $sshcmd
+ if {"$port" != ""} {
+ set retval [ catch {spawn $sshcmd -p $port -c $cyphertype -x -l $user+ct200w $router} reason ]
+ } else {
+ set retval [ catch {spawn $sshcmd -c $cyphertype -x -l $user+ct200w $router} reason ]
+ }
+ if { $retval } {
+ send_user "\nError: $sshcmd failed: $reason\n"
return 1
}
} elseif ![string compare $prog "rsh"] {
we already have this for 3.2. copy attached.
Post by Ehud Gavron
@@ -382,7 +389,7 @@
return 1 }
-re "$u_prompt" {
- send -- "$user+ct\r"
+ send -- "$user+ct200w\r"
set uprompt_seen 1
exp_continue
}
that is a bizarre platform. is it wrapping long lines, truncating or
discarding? Is there any reason that this username feature may not be
supported? eg: a minimum version, etc.
_______________________________________________
Rancid-discuss mailing list
http://www.shrubbery.net/mailman/listinfo/rancid-discuss
Loading...