Subject: | Sessionless nature of Serial is annoying |
Since the Serial connection is "sessionless" , (i.e you can leave it
alone and come back to it at will and it is sitting in the same place
you left it), functions such as authenticated connect() and
begin_privileged() may fail if authentication is configured but the
user is already connected / enabled.
A short simple patch resolves this for me, you check state of the
prompt and then simply return without completing authentication if it
is where you want it to be.
This means making successive calls to ->get which is a bit hit and miss
but generally works, perhaps you can come up with a better way?
Anyway patch included
Subject: | Net-Appliance-Session-1.36.patch |
diff -uNr oldnas/Net-Appliance-Session-1.36/lib/Net/Appliance/Session/Engine.pm newnas/Net-Appliance-Session-1.36/lib/Net/Appliance/Session/Engine.pm
--- oldnas/Net-Appliance-Session-1.36/lib/Net/Appliance/Session/Engine.pm 2008-11-08 21:12:03.000000000 +0000
+++ newnas/Net-Appliance-Session-1.36/lib/Net/Appliance/Session/Engine.pm 2009-06-21 17:30:03.000000000 +0100
@@ -116,6 +116,13 @@
# whether login or enable, we still must be prepared for username:
# prompt because it may appear even with privileged
+ my $data = $self->get; #Check if we are at a prompt or not and if so , return
+ $data = $self->get;
+ if ($data=~m/#/) {
+ $self->in_privileged_mode(1);
+ return $self;
+ }
+
(undef, $match) = $self->waitfor($self->pb->fetch('userpass_prompt'))
or $self->error('Failed to get first privileged prompt');
diff -uNr oldnas/Net-Appliance-Session-1.36/lib/Net/Appliance/Session/Transport/Serial.pm newnas/Net-Appliance-Session-1.36/lib/Net/Appliance/Session/Transport/Serial.pm
--- oldnas/Net-Appliance-Session-1.36/lib/Net/Appliance/Session/Transport/Serial.pm 2008-11-06 20:57:30.000000000 +0000
+++ newnas/Net-Appliance-Session-1.36/lib/Net/Appliance/Session/Transport/Serial.pm 2009-06-21 17:28:19.000000000 +0100
@@ -70,6 +70,11 @@
# optionally, log in to the remote host
if ($self->do_login) {
+ my $data = $self->get; #Check if we are at a prompt or not and if so , return
+ $data = $self->get;
+ $data = $self->get;
+ return $self if (($data eq '>') || ($data eq '#'));
+
# some systems prompt for username, others don't, so we do this
# the long way around...