SPUG: overriding a module's normal behavior
Jon Burdge
jlb at io.com
Tue Mar 1 10:25:13 PST 2005
As background, I needed to use Net::SSH::Perl to log into machines in an
automated fashion, unfortunately some of these machines require
keyboard-interactive authentication, and it's not easy or desirable to get
all of the machine's configs updated. Net::SSH::Perl didn't seem to have
a way to force keyboard-interactive authentication to use stored
credentials (which I presume is simply a feature of well-behaved SSH
clients, but didn't meet my needs.)
I'd rather not have to provide a custom hacked-up version of
Net::SSH::Perl to run with this script, and it it looked like it would be
non-trivial to inherit from Net::SSH::Perl and change things that way.
In fact I would almost guess it was designed to make doing that kind of
thing difficult.
So, in the interest of just getting things done and not messing with the
standard libraries, I loaded Net::SSH::Perl::Auth::KeyboardInt, then
defined *Net::SSH::Perl::Auth::KeyboardInt::authenticate to point to a
subroutine I provide.
The question, then, is what are the downsides of this approach? Is this a
Bad Idea? I've never really done anything like this in any code other
than when I've played around to see how it worked. I did make my code
check the version of Net::SSH::Perl to provide a warning if the version
was not the same as the one where I had tested things, but I'm unsure what
other pitfalls I might need to anticipate.
Any comments? =)
Jon
More information about the spug-list
mailing list