Skip Menu |

This queue is for tickets about the Net-Appliance-Session CPAN distribution.

Report information
The Basics
Id: 47214
Status: resolved
Priority: 0/
Queue: Net-Appliance-Session

People
Owner: OLIVER [...] cpan.org
Requestors: DFREEDMAN [...] cpan.org
Cc:
AdminCc:

Bug Information
Severity: (no value)
Broken in: (no value)
Fixed in: (no value)



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...
Hi David, On Sun Jun 21 12:39:39 2009, DFREEDMAN wrote: Show quoted text
> 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)
Good call, thanks for letting be know about this behaviour. I suppose this means you're not calling $sess->close, which would (I think) try to log out of the console session? Please let me know if you are, and it's actually failing to do that. I've written a different patch, which I'll need to test once I'm back in the office with some equipment to hand. It attempts to "peek" at the prompt as you login/begin_privileged/begin_configure, and skip any unnecessary steps. Your patch was helpful though, in pointing out what you wanted to achieve. I'll keep you posted, and thanks once again for the heads-up. regards, oliver. p.s. I am working on a new version of this module, which is more flexible and extensible. If you are using the module and find yourself with a features wishlist, please do pass it on.
Subject: Re: [rt.cpan.org #47214] Sessionless nature of Serial is annoying
Date: Sun, 21 Jun 2009 22:18:01 +0100 (BST)
To: OLIVER via RT <bug-Net-Appliance-Session [...] rt.cpan.org>
From: DFREEDMAN [...] cpan.org
Show quoted text
> I suppose this means you're not calling $sess->close, which would (I > think) try to log out of the console session? Please let me know if you > are, and it's actually failing to do that.
I can't do that because I can't start the session in the first place! If I try an authenticated connect for the first time and somebody has left the console "logged in" then it will waitfor the Username/Password prompt which of course will never occur Show quoted text
> > I've written a different patch, which I'll need to test once I'm back in > the office with some equipment to hand. It attempts to "peek" at the > prompt as you login/begin_privileged/begin_configure, and skip any > unnecessary steps. Your patch was helpful though, in pointing out what > you wanted to achieve.
Yes, this is exactly what is needed, the problem is that for a fresh device, you never know what state it is in via serial console Show quoted text
> > I'll keep you posted, and thanks once again for the heads-up. > > regards, > oliver. > > p.s. I am working on a new version of this module, which is more > flexible and extensible. If you are using the module and find yourself > with a features wishlist, please do pass it on. >
Shall do, thanks. Dave.
Hi David, Just to let you know that this issue with the Serial transport for Net::Appliance::Session has not been forgotten. I've been snowed under - I'm sure you know how it can get. Hope to have a new release soon, regards, oliver.
Unfortunately the Serial module of Net::Appliance::Session is proving very difficult to fix. I can't in all honesty say I'll be able to resolve this issue :-( I am working on a complete rewrite of Net::Appliance::Session and because it will work in a different way, I hope to work around all this. I have a set of Serial line tests which currently fail so I have a goal to aim for! Sorry about this, and please revisit the module in the future if you have time to try it again. I'm not sure there's much else like it around, and the new version will (I hope) kick ass. yours, seriously bummed, oliver.
I'm just closing this ticket as I've transferred the content into a wish-list action item for the rewrite which is currently underway. -- regards, oliver.