diff -Nru libnet-openssh-perl-0.57/Changes libnet-openssh-perl-0.60/Changes --- libnet-openssh-perl-0.57/Changes 2011-12-21 09:10:16.000000000 +0000 +++ libnet-openssh-perl-0.60/Changes 2013-02-15 13:18:52.000000000 +0000 @@ -1,5 +1,39 @@ Revision history for Perl extension Net::OpenSSH. +0.60 Feb 15, 2013 + - scp_put and rsync_put where not handling correctly the case + where glob was set but the given file patterns didn't match + any local file (bug report by Pavel Leity). + - $SIG{__DIE__} was not always localized before calling eval + +0.59 Jan 31, 2013 + - release as stable + - fix some misspellings + +0.58_04 May 2, 2012 + - solve some git merge mistakes + +0.58_03 May 1, 2012 + - several misspellings corrected on the docs (bug report by + Florian Schlichting from Debian - I love these guys!) + - don't put square brackets around IPv6 addreses when passing + the hostname to ssh (bug report by Alexey ?) + +0.58_02 Apr 16, 2012 + - strict_mode lets pass world-writable directories if they + have the restricted deletion flag set + - implement sshfs import and export methods + - add forward_agent feature + - do not disable ssh-agent when using password authentication + - some documentation improvements + +0.58_01 Jan 30, 2012 + - add new documentation section about debugging + - new helper module Net::OpenSSH::OSTracer added + - ConnectionCache module was missing from MANIFEST + - correction on default_ssh_opts feature documentation + (reported by Yann Kerhervé) + 0.57 Dec 21, 2011 - quote equal sign - do not quote commas @@ -136,6 +170,7 @@ - implement stdintout_dpipe_is_parent feature 0.51_02 Feb 10, 2011 +>>>>>>> master - add support for test method - add support for dpipe feature - simplify _wait_for_master code diff -Nru libnet-openssh-perl-0.57/MANIFEST libnet-openssh-perl-0.60/MANIFEST --- libnet-openssh-perl-0.57/MANIFEST 2011-12-21 09:11:43.000000000 +0000 +++ libnet-openssh-perl-0.60/MANIFEST 2013-02-15 13:19:59.000000000 +0000 @@ -6,6 +6,8 @@ t/2_pods.t lib/Net/OpenSSH.pm lib/Net/OpenSSH/Constants.pm +lib/Net/OpenSSH/ConnectionCache.pm +lib/Net/OpenSSH/OSTracer.pm t/common.pm t/test_server_key t/test_server_key.pub @@ -20,4 +22,5 @@ sample/mod_perl_openssh.pm sample/keep_in_sync.pl sample/password_from_data.pl -META.yml Module meta-data (added by MakeMaker) +META.yml Module YAML meta-data (added by MakeMaker) +META.json Module JSON meta-data (added by MakeMaker) diff -Nru libnet-openssh-perl-0.57/META.json libnet-openssh-perl-0.60/META.json --- libnet-openssh-perl-0.57/META.json 1970-01-01 00:00:00.000000000 +0000 +++ libnet-openssh-perl-0.60/META.json 2013-02-15 13:19:59.000000000 +0000 @@ -0,0 +1,41 @@ +{ + "abstract" : "Perl SSH client package implemented on top of OpenSSH", + "author" : [ + "Salvador Fandino " + ], + "dynamic_config" : 1, + "generated_by" : "ExtUtils::MakeMaker version 6.62, CPAN::Meta::Converter version 2.112150", + "license" : [ + "unknown" + ], + "meta-spec" : { + "url" : "http://search.cpan.org/perldoc?CPAN::Meta::Spec", + "version" : "2" + }, + "name" : "Net-OpenSSH", + "no_index" : { + "directory" : [ + "t", + "inc" + ] + }, + "prereqs" : { + "build" : { + "requires" : { + "ExtUtils::MakeMaker" : 0 + } + }, + "configure" : { + "requires" : { + "ExtUtils::MakeMaker" : 0 + } + }, + "runtime" : { + "requires" : { + "Test::More" : 0 + } + } + }, + "release_status" : "stable", + "version" : "0.60" +} diff -Nru libnet-openssh-perl-0.57/META.yml libnet-openssh-perl-0.60/META.yml --- libnet-openssh-perl-0.57/META.yml 2011-12-21 09:11:43.000000000 +0000 +++ libnet-openssh-perl-0.60/META.yml 2013-02-15 13:19:59.000000000 +0000 @@ -1,22 +1,22 @@ ---- #YAML:1.0 -name: Net-OpenSSH -version: 0.57 -abstract: Perl SSH client package implemented on top of OpenSSH +--- +abstract: 'Perl SSH client package implemented on top of OpenSSH' author: - - Salvador Fandino -license: unknown -distribution_type: module -configure_requires: - ExtUtils::MakeMaker: 0 + - 'Salvador Fandino ' build_requires: - ExtUtils::MakeMaker: 0 -requires: - Test::More: 0 -no_index: - directory: - - t - - inc -generated_by: ExtUtils::MakeMaker version 6.57_05 + ExtUtils::MakeMaker: 0 +configure_requires: + ExtUtils::MakeMaker: 0 +dynamic_config: 1 +generated_by: 'ExtUtils::MakeMaker version 6.62, CPAN::Meta::Converter version 2.112150' +license: unknown meta-spec: - url: http://module-build.sourceforge.net/META-spec-v1.4.html - version: 1.4 + url: http://module-build.sourceforge.net/META-spec-v1.4.html + version: 1.4 +name: Net-OpenSSH +no_index: + directory: + - t + - inc +requires: + Test::More: 0 +version: 0.60 diff -Nru libnet-openssh-perl-0.57/README libnet-openssh-perl-0.60/README --- libnet-openssh-perl-0.57/README 2011-03-17 09:51:41.000000000 +0000 +++ libnet-openssh-perl-0.60/README 2013-02-15 13:04:31.000000000 +0000 @@ -26,7 +26,7 @@ COPYRIGHT AND LICENCE -Copyright (C) 2008-2011 by Salvador Fandino +Copyright (C) 2008-2013 by Salvador Fandino This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself, either Perl version 5.10.0 or, diff -Nru libnet-openssh-perl-0.57/debian/changelog libnet-openssh-perl-0.60/debian/changelog --- libnet-openssh-perl-0.57/debian/changelog 2012-02-24 20:12:38.000000000 +0000 +++ libnet-openssh-perl-0.60/debian/changelog 2013-04-30 22:09:17.000000000 +0000 @@ -1,3 +1,19 @@ +libnet-openssh-perl (0.60-1) unstable; urgency=low + + [ Salvatore Bonaccorso ] + * Change Vcs-Git to canonical URI (git://anonscm.debian.org) + * Change search.cpan.org based URIs to metacpan.org based URIs + + [ Florian Schlichting ] + * Imported Upstream version 0.60 + * Email change: Florian Schlichting -> fsfs@debian.org + * Bumped Standards-Version to 3.9.4 (use copyright-format 1.0) + * Bumped copyright years + * Dropped fix_pod_spelling.patch, applied upstream + * New spelling.patch + + -- Florian Schlichting Tue, 30 Apr 2013 23:44:13 +0200 + libnet-openssh-perl (0.57-1) unstable; urgency=low * Initial Release. (Closes: #660923) diff -Nru libnet-openssh-perl-0.57/debian/control libnet-openssh-perl-0.60/debian/control --- libnet-openssh-perl-0.57/debian/control 2012-02-24 20:12:38.000000000 +0000 +++ libnet-openssh-perl-0.60/debian/control 2013-04-30 22:08:53.000000000 +0000 @@ -2,13 +2,13 @@ Section: perl Priority: optional Maintainer: Debian Perl Group -Uploaders: Florian Schlichting +Uploaders: Florian Schlichting Build-Depends: debhelper (>= 8) Build-Depends-Indep: perl -Standards-Version: 3.9.2 +Standards-Version: 3.9.4 Vcs-Browser: http://anonscm.debian.org/gitweb/?p=pkg-perl/packages/libnet-openssh-perl.git -Vcs-Git: git://git.debian.org/pkg-perl/packages/libnet-openssh-perl.git -Homepage: http://search.cpan.org/dist/Net-OpenSSH/ +Vcs-Git: git://anonscm.debian.org/pkg-perl/packages/libnet-openssh-perl.git +Homepage: https://metacpan.org/release/Net-OpenSSH/ Package: libnet-openssh-perl Architecture: all diff -Nru libnet-openssh-perl-0.57/debian/copyright libnet-openssh-perl-0.60/debian/copyright --- libnet-openssh-perl-0.57/debian/copyright 2012-02-24 20:12:38.000000000 +0000 +++ libnet-openssh-perl-0.60/debian/copyright 2013-04-30 21:40:17.000000000 +0000 @@ -1,14 +1,14 @@ -Format-Specification: http://anonscm.debian.org/viewvc/dep/web/deps/dep5.mdwn?view=markup&pathrev=135 -Maintainer: Salvador Fandino -Source: http://search.cpan.org/dist/Net-OpenSSH/ -Name: Net-OpenSSH +Format: http://www.debian.org/doc/packaging-manuals/copyright-format/1.0/ +Upstream-Name: Net-OpenSSH +Upstream-Contact: Salvador Fandino +Source: https://metacpan.org/release/Net-OpenSSH/ Files: * -Copyright: 2008-2011, Salvador Fandino +Copyright: 2008-2013, Salvador Fandino License: Artistic or GPL-1+ Files: debian/* -Copyright: 2012, Florian Schlichting +Copyright: 2012-2013, Florian Schlichting License: Artistic or GPL-1+ License: Artistic @@ -26,3 +26,4 @@ . On Debian systems, the complete text of version 1 of the GNU General Public License can be found in `/usr/share/common-licenses/GPL-1'. + diff -Nru libnet-openssh-perl-0.57/debian/patches/fix_pod_spelling.patch libnet-openssh-perl-0.60/debian/patches/fix_pod_spelling.patch --- libnet-openssh-perl-0.57/debian/patches/fix_pod_spelling.patch 2012-02-24 20:12:38.000000000 +0000 +++ libnet-openssh-perl-0.60/debian/patches/fix_pod_spelling.patch 1970-01-01 00:00:00.000000000 +0000 @@ -1,114 +0,0 @@ -Description: fix spelling errors detected by lintian -Author: Florian Schlichting -Forwarded: https://rt.cpan.org/Public/Bug/Display.html?id=75226 - ---- a/lib/Net/OpenSSH.pm -+++ b/lib/Net/OpenSSH.pm -@@ -2617,7 +2617,7 @@ - - =item stdout_pipe => 1 - --Creates a new pipe and connects the writting side to the stdout stream -+Creates a new pipe and connects the writing side to the stdout stream - of the remote process. The reading side is returned as the second - value (C<$out>). - -@@ -2664,7 +2664,7 @@ - - =item stderr_pipe => 1 - --Creates a new pipe and connects the writting side to the stderr stream -+Creates a new pipe and connects the writing side to the stderr stream - of the remote process. The reading side is returned as the third - value (C<$err>). - -@@ -3180,7 +3180,7 @@ - =item $ssh->wait_for_master($async) - - When the connection has been established by calling the constructor --with the C option, this call allows to advance the process. -+with the C option, this call allows one to advance the process. - - If C<$async> is true, it will perform any work that can be done - inmediately without waiting (for instance, entering the password or -@@ -3188,7 +3188,7 @@ - return. If a false value is given, it will finalize the connection - process and wait until the multiplexing socket is available. - --It returns a true value after the connection has been succesfully -+It returns a true value after the connection has been successfully - established. False is returned if the connection process fails or if - it has not yet completed (then, the L method can be used to - distinguish between both cases). -@@ -3244,7 +3244,7 @@ - - =item $ssh->master_exited - --This methods allows to tell the module that the master process has -+This methods allows one to tell the module that the master process has - exited when we get its PID from some external wait or waitpid - call. For instance: - -@@ -3297,10 +3297,10 @@ - Under the hood, as the Secure Shell protocol does not provide for this - mode of operation and always spawns a new shell where it runs the - given command, Net::OpenSSH quotes any shell metacharacters in the --comand list. -+command list. - - All the methods that invoke a remote command (system, open_ex, etc.) --accept the option C that allows to force/disable shell -+accept the option C that allows one to force/disable shell - quoting. - - For instance: -@@ -3380,7 +3380,7 @@ - would be to send them signals through the SSH connection as specified - by the protocol standard. - --Unfortunatelly OpenSSH does not implement that feature so Net::OpenSSH -+Unfortunately OpenSSH does not implement that feature so Net::OpenSSH - has to use other imperfect approaches: - - =over 4 -@@ -3408,7 +3408,7 @@ - - =head2 Variable expansion - --The variable expansion feature allows to define variables that are -+The variable expansion feature allows one to define variables that are - expanded automatically inside command arguments and file paths. - - This feature is disabled by default. It is intended to be used with -@@ -3730,7 +3730,7 @@ - - This is another common problem that happens when some server is - replaced or reinstalled from scratch and its public key changes --becomming different to that installed on the C file. -+becoming different to that installed on the C file. - - The easiest way to solve that problem is to remove the old key from - the C file by hand using any editor and then to connect -@@ -3826,7 +3826,7 @@ - - Usually, the SSH server running on these devices does not support - command mode. It unconditionally attachs the restricted shell to any --incomming SSH connection and waits for the user to enter commands -+incoming SSH connection and waits for the user to enter commands - through the redirected stdin stream. - - The only way to workaround this limitation is to make your script talk -@@ -4030,11 +4030,11 @@ - this module on the remote machine (see also the C and - scripts in the sample directory). - --L is an advanced scheduler that allows to run -+L is an advanced scheduler that allows one to run - commands in remote hosts in parallel. It is obviously based on - Net::OpenSSH. - --L allows to run remote commands in parallel in -+L allows one to run remote commands in parallel in - a cluster. It is build on top on C also. - - Other Perl SSH clients: L, diff -Nru libnet-openssh-perl-0.57/debian/patches/series libnet-openssh-perl-0.60/debian/patches/series --- libnet-openssh-perl-0.57/debian/patches/series 2012-02-24 20:12:38.000000000 +0000 +++ libnet-openssh-perl-0.60/debian/patches/series 2013-04-30 22:08:53.000000000 +0000 @@ -1 +1 @@ -fix_pod_spelling.patch +spelling.patch diff -Nru libnet-openssh-perl-0.57/debian/patches/spelling.patch libnet-openssh-perl-0.60/debian/patches/spelling.patch --- libnet-openssh-perl-0.57/debian/patches/spelling.patch 1970-01-01 00:00:00.000000000 +0000 +++ libnet-openssh-perl-0.60/debian/patches/spelling.patch 2013-04-30 22:08:53.000000000 +0000 @@ -0,0 +1,44 @@ +Description: fix pod typos discovered by lintian +Author: Florian Schlichting +Forwarded: https://rt.cpan.org/Public/Bug/Display.html?id=84955 + +--- a/lib/Net/OpenSSH.pm ++++ b/lib/Net/OpenSSH.pm +@@ -3163,7 +3163,7 @@ + + By default, C is called with the quiet flag C<-q> enabled in + order to suppress progress information. This option allows one to +-reenable the progress indication bar. ++re-enable the progress indication bar. + + =item verbose => 1 + +@@ -3190,7 +3190,7 @@ + + =item bwlimit => $Kbits + +-Limits the used bandwith, specified in Kbit/s. ++Limits the used bandwidth, specified in Kbit/s. + + =item timeout => $secs + +--- a/lib/Net/OpenSSH/OSTracer.pm ++++ b/lib/Net/OpenSSH/OSTracer.pm +@@ -127,7 +127,7 @@ + + $Net::OpenSSH::debug |= 512; + +-By default the ouput files of the tracer are saved as ++By default the output files of the tracer are saved as + C. + + Also, the output send by the tracer to stdout/stderr is saved as +@@ -140,7 +140,7 @@ + =item $Net::OpenSSH::OSTracer::type + + By default, the module decides which tracer to use in base to the +-operative system name. This variable allows to select a different ++operative system name. This variable allows one to select a different + tracer. + + Currently accepted types are: strace (linux), ktrace (*bsd), tusc diff -Nru libnet-openssh-perl-0.57/debian/watch libnet-openssh-perl-0.60/debian/watch --- libnet-openssh-perl-0.57/debian/watch 2012-02-24 20:12:38.000000000 +0000 +++ libnet-openssh-perl-0.60/debian/watch 2013-01-27 18:00:24.000000000 +0000 @@ -1,2 +1,2 @@ version=3 -http://search.cpan.org/dist/Net-OpenSSH/ .*/Net-OpenSSH-v?(\d[\d.-]+)\.(?:tar(?:\.gz|\.bz2)?|tgz|zip)$ +https://metacpan.org/release/Net-OpenSSH/ .*/Net-OpenSSH-v?(\d[\d.-]+)\.(?:tar(?:\.gz|\.bz2)?|tgz|zip)$ diff -Nru libnet-openssh-perl-0.57/lib/Net/OpenSSH/ConnectionCache.pm libnet-openssh-perl-0.60/lib/Net/OpenSSH/ConnectionCache.pm --- libnet-openssh-perl-0.57/lib/Net/OpenSSH/ConnectionCache.pm 1970-01-01 00:00:00.000000000 +0000 +++ libnet-openssh-perl-0.60/lib/Net/OpenSSH/ConnectionCache.pm 2012-02-22 11:56:39.000000000 +0000 @@ -0,0 +1,86 @@ +package Net::OpenSSH::ConnectionCache; + +use Net::OpenSSH; +use Net::OpenSSH::Constants qw(:error); + +use Data::Dumper; +use Scalar::Util qw(weaken); + +our $MAX_SIZE = 20; +my %cache; + +sub _factory { + my $class = shift; + my %opts = @_; + my $dump = Data::Dumper->new([\%opts], ['s']); + $dump->Indent(0); + $dump->Sortkeys(1); + $dump->Deepcopy(1); + my $signature = $dump->Dump; + my $ssh = $cache{$signature}; + if ($ssh and $ssh->error != OSSH_MASTER_FAILED) { + if ($opts{async} or $ssh->wait_for_master) { + return $cache{$signature} = $ssh; + } + } + if ($MAX_SIZE <= keys %cache) { + for (keys %cache) { + $ssh = $cache{$_}; + $ssh or $ssh->error != OSSH_MASTER_FAILED or delete $cache{$_} + } + for (keys %cache) { + last if ($MAX_SIZE <= keys %cache); + weaken $cache{$_}; + if (defined $cache{$_}) { + $cache{$_} = $cache{$_}; # unweaken + } + else { + delete $cache{$_}; + } + } + } + local $Net::OpenSSH::FACTORY; + $cache{$signature} = $class->new(@_); +} + +$Net::OpenSSH::FACTORY = \&_factory; + +END { %cache = () } + +1; + +__END__ + +=head1 NAME + +Net::OpenSSH::ConnectionCache - cache and reuse SSH connections transparently + +=head1 SYNOPSIS + + use Net::OpenSSH; + use Net::OpenSSH::ConnectionCache; + + for (1..10) { + my $ssh = Net::OpenSSH->new($host); + $ssh->system("$cmd $_"); + } + +=head1 DESCRIPTION + +This module installs a C<$Net::OpenSSH::FACTORY> hook implementing a +SSH connection caching scheme. + +C<$Net::OpenSSH::ConnectionCache::MAX_SIZE> controls the cache +size. Once as many connections are allocated, the module will try to +free any of them before allocating a new one. + +=head1 COPYRIGHT AND LICENSE + +Copyright (C) 2011 by Salvador FandiEo +(sfandino@yahoo.com) + +This library is free software; you can redistribute it and/or modify +it under the same terms as Perl itself, either Perl version 5.10.0 or, +at your option, any later version of Perl 5 you may have available. + +=cut diff -Nru libnet-openssh-perl-0.57/lib/Net/OpenSSH/OSTracer.pm libnet-openssh-perl-0.60/lib/Net/OpenSSH/OSTracer.pm --- libnet-openssh-perl-0.57/lib/Net/OpenSSH/OSTracer.pm 1970-01-01 00:00:00.000000000 +0000 +++ libnet-openssh-perl-0.60/lib/Net/OpenSSH/OSTracer.pm 2012-02-22 11:56:39.000000000 +0000 @@ -0,0 +1,201 @@ +package Net::OpenSSH::OSTracer; + +our $VERSION = '0.58_01'; + +use strict; +use warnings; + +use POSIX; + +our $cmd; +our $type; +our $output; +our $sudo; +our $delay; + +our @EXTRA_ARGS; + +my %type_by_os = (linux => 'strace', + openbsd => 'ktrace', + freebsd => 'ktrace', + netbsd => 'ktrace', + bsd => 'ktrace', + 'hp-ux' => 'tusc', + aix => 'truss', + solaris => 'truss'); + +sub trace { + my $class = shift; + my ($cmd, $type) = ($cmd, $type); # copy globals + + + if (not defined $type) { + my $os = lc $^O; + if ( defined $cmd and $cmd =~ /([sk]trace|k?truss|tusc)$/) { + $type = $1; + } + elsif ($os =~ /(linux|openbsd|freebsd|netbsd|bsd|hp-ux|aix|solaris)/) { + $type = $type_by_os{$1}; + } + else { + Net::OpenSSH::_debug("unable to determine tracer type for OS $os"); + return; + } + } + + my $output1 = (defined $output ? $output : "/tmp/net_openssh_master") . ".$$"; + my $file = "$output1.$type"; + my $err = "$output1.txt"; + + $cmd = $type unless defined $cmd; + + my @args; + if ($type eq 'strace') { + @args = (-o => $file, -p => $$, -s => 1024, '-fx'); + } + elsif ($type eq 'ktruss') { + @args = (-o => $file, -p => $$, -m => 1024, '-d'); + } + elsif ($type eq 'ktrace') { + @args = (-f => $file, -p => $$, '-id'); + } + elsif ($type eq 'tusc') { + @args = (-o => $file, -b => 1024, '-fa', $$) + } + elsif ($type eq 'truss') { + @args = (-o => $file, -faep => $$); + } + else { + Net::OpenSSH::_debug("tracer type $type not supported"); + return + } + + my @cmd = (defined $sudo ? ($sudo, '-A', $cmd) : $cmd); + + my $pid = fork; + unless ($pid) { + unless (defined $pid) { + Net::OpenSSH::_debug("unable to launch tracer, fork failed: $!"); + return; + } + my ($in, $out); + if (open $in, '', $err and + POSIX::dup2(fileno $in, 0) and + POSIX::dup2(fileno $out, 1) and + POSIX::dup2(fileno $out, 2)) { + exec (@cmd, @EXTRA_ARGS, @args); + } + else { + eval { Net::OpenSSH::_debug("Unable to redirect tracer IO: $!") }; + } + POSIX::_exit(1); + } + sleep (defined $delay ? $delay : 1); # wait for the tracer to come up + Net::OpenSSH::_debug("tracer attached, ssh pid: $$, tracer pid: $pid"); + 1; +} + +1; + +__END__ + +=head1 NAME + +Net::OpenSSH::OSTracer - trace ssh master process at the OS level + +=head1 SYNOPSIS + + use Net::OpenSSH; + $Net::OpenSSH::debug |= 512; + + Net::OpenSSH->new($host)->system("echo hello world"); + + system "less /tmp/net_openssh_master.*.strace"; + +=head1 DESCRIPTION + +This is a Net::OpenSSH helper module that allows you to trace the +master ssh process at the operating system level using the proper +utility available in your system (i.e, strace, truss, ktruss, tusc, +etc.). + +This feature can be used when debugging your programs or to report +bugs on the module. + +It is enabled setting the flag 512 on the C<$Net::OpenSSH::debug> variable: + + $Net::OpenSSH::debug |= 512; + +By default the ouput files of the tracer are saved as +C. + +Also, the output send by the tracer to stdout/stderr is saved as +C. + +The module can be configured through the following global variables: + +=over 4 + +=item $Net::OpenSSH::OSTracer::type + +By default, the module decides which tracer to use in base to the +operative system name. This variable allows to select a different +tracer. + +Currently accepted types are: strace (linux), ktrace (*bsd), tusc +(hp-ux) and truss (solaris and aix). + +=item $Net::OpenSSH::OSTracer::cmd + +Command to execute for tracing the ssh process. + +By default, it inferres it from the tracer type selected. + +=item $Net::OpenSSH::OSTracer::output + +Basename for the destination file. The PID of the ssh process and the +tracer type will be appended. + +=item $Net::OpenSSH::OSTracer::sudo + +This variable can be used to request the tracer to be run with C +(some operating systems as for example Ubuntu, do not allow to attach +tracers, even to your own processes, unless you do it as root). + +The variable has to be set with the path of the C binary. For +instance: + + $Net::OpenSSH::OSTracer::sudo = '/usr/bin/sudo'; + +If you need to pass a password to C, set the environment +variable C. For instance: + + SUDO_ASKPASS=/usr/bin/ssh-askpass + +=item $Net::OpenSSH::OSTracer::delay + +This variable can be used to delay the ssh execution so that the +tracer can attach the process first. This is specially handy when +using C with a password. + +=back + +=head1 BUGS + +This module has not been tested under all the operating systems is +says to support. + +If you find any problem, just report it, please! + +=head1 COPYRIGHT AND LICENSE + +Copyright (C) 2012 by Salvador FandiEo +(sfandino@yahoo.com) + +This library is free software; you can redistribute it and/or modify +it under the same terms as Perl itself, either Perl version 5.10.0 or, +at your option, any later version of Perl 5 you may have available. + + +=cut diff -Nru libnet-openssh-perl-0.57/lib/Net/OpenSSH.pm libnet-openssh-perl-0.60/lib/Net/OpenSSH.pm --- libnet-openssh-perl-0.57/lib/Net/OpenSSH.pm 2011-12-21 09:09:53.000000000 +0000 +++ libnet-openssh-perl-0.60/lib/Net/OpenSSH.pm 2013-02-15 13:14:14.000000000 +0000 @@ -1,6 +1,6 @@ package Net::OpenSSH; -our $VERSION = '0.57'; +our $VERSION = '0.60'; use strict; use warnings; @@ -240,6 +240,9 @@ my $ssh_cmd = _first_defined delete $opts{ssh_cmd}, 'ssh'; my $rsync_cmd = _first_defined delete $opts{rsync_cmd}, 'rsync'; my $scp_cmd = delete $opts{scp_cmd}; + my $sshfs_cmd = _first_defined delete $opts{sshfs_cmd}, 'sshfs'; + my $sftp_server_cmd = _first_defined delete $opts{sftp_server_cmd}, + '/usr/lib/openssh/sftp-server'; my $timeout = delete $opts{timeout}; my $kill_ssh_on_timeout = delete $opts{kill_ssh_on_timeout}; my $strict_mode = _first_defined delete $opts{strict_mode}, 1; @@ -252,6 +255,9 @@ _first_defined delete $opts{default_stream_encoding}, $default_encoding; my $default_argument_encoding = _first_defined delete $opts{default_argument_encoding}, $default_encoding; + my $forward_agent = delete $opts{forward_agent}; + $forward_agent and $passphrase and + croak "agent forwarding can not be used when a passphrase has also been given"; my ($master_opts, @master_opts, $master_stdout_fh, $master_stderr_fh, @@ -311,8 +317,7 @@ push @ssh_opts, -p => $port if defined $port; my $home = do { - local $SIG{__DIE__}; - local $@; + local ($@, $SIG{__DIE__}); eval { Cwd::realpath((getpwuid $>)[7]) } }; @@ -329,6 +334,8 @@ _ssh_cmd => $ssh_cmd, _scp_cmd => $scp_cmd, _rsync_cmd => $rsync_cmd, + _sshfs_cmd => $sshfs_cmd, + _sftp_server_cmd => $sftp_server_cmd, _pid => undef, _host => $host, _host_squared => $host_squared, @@ -344,6 +351,7 @@ _kill_ssh_on_timeout => $kill_ssh_on_timeout, _batch_mode => $batch_mode, _home => $home, + _forward_agent => $forward_agent, _external_master => $external_master, _default_ssh_opts => $default_ssh_opts, _default_stdin_fh => $default_stdin_fh, @@ -357,7 +365,8 @@ _default_stream_encoding => $default_stream_encoding, _default_argument_encoding => $default_argument_encoding, _expand_vars => $expand_vars, - _vars => $vars }; + _vars => $vars, + }; bless $self, $class; # default file handles are opened so late in order to have the @@ -492,7 +501,7 @@ } my ($mode, $uid) = (stat $dir)[2, 4]; $debug and $debug & 2 and _debug "_is_secure_path(dir: $dir, file mode: $mode, file uid: $uid, euid: $>"; - return undef unless(($uid == $> or $uid == 0 ) and (($mode & 022) == 0)); + return undef unless(($uid == $> or $uid == 0 ) and (($mode & 022) == 0 or ($mode & 01000))); return 1 if (defined $home and $home eq $dir); } return 1; @@ -503,7 +512,7 @@ my @before = @{shift || []}; my @args = ($self->{_ssh_cmd}, @before, -S => $self->{_ctl_path}, - @{$self->{_ssh_opts}}, $self->{_host_squared}, + @{$self->{_ssh_opts}}, $self->{_host}, '--', (@_ ? "@_" : ())); $debug and $debug & 8 and _debug_dump 'call args' => \@args; @@ -655,6 +664,10 @@ push @master_opts, -i => $self->{_key_path}; } + if (defined $self->{_forward_agent}) { + push @master_opts, ($self->{_forward_agent} ? '-A' : '-a'); + } + my $proxy_command = $self->{_proxy_command}; my $gateway; @@ -701,15 +714,18 @@ return undef; } unless ($pid) { + if ($debug and $debug & 512) { + require Net::OpenSSH::OSTracer; + Net::OpenSSH::OSTracer->trace; + } + $mpty->make_slave_controlling_terminal if $mpty; $self->_master_redirect('STDOUT'); $self->_master_redirect('STDERR'); - if (defined $self->{_passwd}) { - delete $ENV{SSH_ASKPASS}; - delete $ENV{SSH_AUTH_SOCK}; - } + delete $ENV{SSH_ASKPASS} if defined $self->{_passwd}; + delete $ENV{SSH_AUTH_SOCK} if defined $self->{_passphrase}; local $SIG{__DIE__}; eval { exec @call }; @@ -894,8 +910,7 @@ return undef; } if ($state eq 'waiting_for_login_handler') { - local $SIG{__DIE__}; - local $@; + local ($@, $SIG{__DIE__}); if (eval { $login_handler->($self, $mpty, $bout) }) { $state = 'waiting_for_mux_socket'; next; @@ -956,6 +971,29 @@ stderr_to_stdout => 1, ssh_opts => [-O => $cmd]}); } +sub stop { + # FIXME: this method currently fails because of a bug in ssh. + my ($self, $timeout) = @_; + my $pid = $self->{_pid}; + $self->_master_ctl('stop'); + if (not $self->error and + $pid and + $self->{_perl_pid} == $$ and + $self->{_thread_generation} == $thread_generation) { + + local $self->{_kill_ssh_on_timeout}; + if ($self->_waitpid($pid, $timeout)) { + delete $self->{_pid}; + $self->_set_error(OSSH_MASTER_FAILED, "master ssh connection stopped"); + return 1; + } + else { + return $self->_kill_master; + } + } + undef; +} + sub _make_pipe { my $self = shift; my ($r, $w); @@ -975,15 +1013,13 @@ my ($module, $version) = @_; $loaded_module{$module} ||= do { do { - local $SIG{__DIE__}; - local $@; + local ($@, $SIG{__DIE__}); eval "require $module; 1" } or croak "unable to load Perl module $module"; 1 }; if (defined $version) { - local $SIG{__DIE__}; - local $@; + local ($@, $SIG{__DIE__}); my $mv = eval "\$${module}::VERSION" || 0; (my $mv1 = $mv) =~ s/_\d*$//; croak "$module version $version required, $mv is available" @@ -1117,6 +1153,10 @@ my @ssh_opts = _array_or_scalar_to_list delete $opts{ssh_opts}; my $tty = delete $opts{tty}; push @ssh_opts, ($tty ? '-qtt' : '-T') if defined $tty; + if ($self->{_forward_agent}) { + my $forward_agent = delete $opts{forward_agent}; + push @ssh_opts, ($forward_agent ? '-A' : '-a') if defined $forward_agent; + } my $tunnel = delete $opts{tunnel}; my (@args); if ($tunnel) { @@ -1206,10 +1246,10 @@ $self->wait_for_master or return; my %opts = (ref $_[0] eq 'HASH' ? %{shift()} : ()); my $tunnel = delete $opts{tunnel}; - my ($stdinout_socket, $stdinout_dpipe_is_parent); + my ($stdinout_socket, $stdinout_dpipe_make_parent); my $stdinout_dpipe = delete $opts{stdinout_dpipe}; if ($stdinout_dpipe) { - $stdinout_dpipe_is_parent = delete $opts{stdinout_dpipe_is_parent}; + $stdinout_dpipe_make_parent = delete $opts{stdinout_dpipe_make_parent}; $stdinout_socket = 1; } else { @@ -1243,11 +1283,15 @@ $stderr_file = delete $opts{stderr_file} ); my $argument_encoding = $self->_delete_argument_encoding(\%opts); - my $ssh_opts = delete $opts{ssh_opts}; $ssh_opts = $self->{_default_ssh_opts} unless defined $ssh_opts; my @ssh_opts = $self->_expand_vars(_array_or_scalar_to_list $ssh_opts); + if ($self->{_forward_agent}) { + my $forward_agent = delete $opts{forward_agent}; + push @ssh_opts, ($forward_agent ? '-A' : '-a') if defined $forward_agent; + } + my ($cmd, $close_slave_pty, @args); if ($tunnel) { @_ == 2 or croak 'bad number of arguments for tunnel, use $ssh->method(\\%opts, $host, $port)'; @@ -1363,7 +1407,7 @@ my $pid1 = fork; defined $pid1 or POSIX::_exit(255); - unless ($pid1 xor $stdinout_dpipe_is_parent) { + unless ($pid1 xor $stdinout_dpipe_make_parent) { eval { $self->_exec_dpipe($stdinout_dpipe, $win, $werr) }; POSIX::_exit(255); } @@ -1454,7 +1498,7 @@ my $self = shift; my $enc = shift; if (defined $enc and @_) { - local $@; + local ($@, $SIG{__DIE__}); eval { for (@_) { defined or next; @@ -1484,7 +1528,7 @@ sub _decode { my $self = shift; my $enc = shift; - local $@; + local ($@, $SIG{__DIE__}); eval { for (@_) { defined or next; @@ -1621,8 +1665,8 @@ _sub_options spawn => qw(stderr_to_stdout stdin_discard stdin_fh stdin_file stdout_discard stdout_fh stdout_file stderr_discard stderr_fh stderr_file - stdinout_dpipe stdintout_dpipe_is_parent quote_args tty ssh_opts tunnel - encoding argument_encoding); + stdinout_dpipe stdinout_dpipe_make_parent quote_args tty ssh_opts tunnel + encoding argument_encoding forward_agent); sub spawn { ${^TAINT} and &_catch_tainted_args; my $self = shift; @@ -1633,7 +1677,7 @@ } _sub_options open2 => qw(stderr_to_stdout stderr_discard stderr_fh stderr_file quote_args - tty ssh_opts tunnel encoding argument_encoding); + tty ssh_opts tunnel encoding argument_encoding forward_agent); sub open2 { ${^TAINT} and &_catch_tainted_args; my $self = shift; @@ -1648,7 +1692,7 @@ } _sub_options open2pty => qw(stderr_to_stdout stderr_discard stderr_fh stderr_file quote_args tty - close_slave_pty ssh_opts encoding argument_encoding); + close_slave_pty ssh_opts encoding argument_encoding forward_agent); sub open2pty { ${^TAINT} and &_catch_tainted_args; my $self = shift; @@ -1664,7 +1708,7 @@ } _sub_options open2socket => qw(stderr_to_stdout stderr_discard stderr_fh stderr_file quote_args tty - ssh_opts tunnel encoding argument_encoding); + ssh_opts tunnel encoding argument_encoding forward_agent); sub open2socket { ${^TAINT} and &_catch_tainted_args; my $self = shift; @@ -1677,7 +1721,7 @@ return ($socket, $pid); } -_sub_options open3 => qw(quote_args tty ssh_opts encoding argument_encoding); +_sub_options open3 => qw(quote_args tty ssh_opts encoding argument_encoding forward_agent); sub open3 { ${^TAINT} and &_catch_tainted_args; my $self = shift; @@ -1694,7 +1738,7 @@ } _sub_options open3pty => qw(quote_args tty close_slave_pty ssh_opts - encoding argument_encoding); + encoding argument_encoding forward_agent); sub open3pty { ${^TAINT} and &_catch_tainted_args; my $self = shift; @@ -1713,8 +1757,8 @@ _sub_options system => qw(stdout_discard stdout_fh stdin_discard stdout_file stdin_fh stdin_file quote_args stderr_to_stdout stderr_discard stderr_fh stderr_file - stdinout_dpipe stdinout_dpipe_is_parent tty ssh_opts tunnel encoding - argument_encoding); + stdinout_dpipe stdinout_dpipe_make_parent tty ssh_opts tunnel encoding + argument_encoding forward_agent); sub system { ${^TAINT} and &_catch_tainted_args; my $self = shift; @@ -1742,8 +1786,8 @@ _sub_options test => qw(stdout_discard stdout_fh stdin_discard stdout_file stdin_fh stdin_file quote_args stderr_to_stdout stderr_discard stderr_fh stderr_file - stdinout_dpipe stdinout_dpipe_is_parent stdtty ssh_opts timeout stdin_data - encoding stream_encoding argument_encoding); + stdinout_dpipe stdinout_dpipe_make_parent tty ssh_opts timeout stdin_data + encoding stream_encoding argument_encoding forward_agent); sub test { ${^TAINT} and &_catch_tainted_args; my $self = shift; @@ -1768,7 +1812,7 @@ _sub_options capture => qw(stderr_to_stdout stderr_discard stderr_fh stderr_file stdin_discard stdin_fh stdin_file quote_args tty ssh_opts tunnel - encoding argument_encoding); + encoding argument_encoding forward_agent); sub capture { ${^TAINT} and &_catch_tainted_args; my $self = shift; @@ -1795,7 +1839,9 @@ $output } -_sub_options capture2 => qw(stdin_discard stdin_fh stdin_file quote_args tty ssh_opts encoding argument_encoding); +_sub_options capture2 => qw(stdin_discard stdin_fh stdin_file + quote_args tty ssh_opts encoding + argument_encoding forward_agent); sub capture2 { ${^TAINT} and &_catch_tainted_args; my $self = shift; @@ -1819,7 +1865,7 @@ wantarray ? @capture : $capture[0]; } -_sub_options open_tunnel => qw(ssh_opts stderr_discard stderr_fh stderr_file encoding argument_encoding); +_sub_options open_tunnel => qw(ssh_opts stderr_discard stderr_fh stderr_file encoding argument_encoding forward_agent); sub open_tunnel { ${^TAINT} and &_catch_tainted_args; my $self = shift; @@ -1833,7 +1879,7 @@ _sub_options capture_tunnel => qw(ssh_opts stderr_discard stderr_fh stderr_file stdin_discard stdin_fh stdin_file stdin_data timeout encoding stream_encoding - argument_encoding); + argument_encoding forward_agent); sub capture_tunnel { ${^TAINT} and &_catch_tainted_args; my $self = shift; @@ -1918,18 +1964,21 @@ sub scp_put { ${^TAINT} and &_catch_tainted_args; my ($self, $opts, $target, @src) = _scp_put_args @_; + return unless $self; $self->_scp($opts, @src, $target); } sub rsync_put { ${^TAINT} and &_catch_tainted_args; my ($self, $opts, $target, @src) = _scp_put_args @_; + return unless $self; $self->_rsync($opts, @src, $target); } _sub_options _scp => qw(stderr_to_stdout stderr_discard stderr_fh stderr_file stdout_discard stdout_fh - stdout_file encoding argument_encoding); + stdout_file encoding argument_encoding + forward_agent); sub _scp { my $self = shift; my %opts = (ref $_[0] eq 'HASH' ? %{shift()} : ()); @@ -2060,7 +2109,7 @@ } _sub_options sftp => qw(autoflush timeout argument_encoding encoding block_size - queue_size late_set_perm); + queue_size late_set_perm forward_agent); sub sftp { ${^TAINT} and &_catch_tainted_args; @@ -2094,16 +2143,55 @@ $sftp } +_sub_options sshfs_import => qw(stderr_discard stderr_fh stderr_file + ssh_opts argument_encoding sshfs_opts); +sub sshfs_import { + ${^TAINT} and &_catch_tainted_args; + my $self = shift; + my %opts = (ref $_[0] eq 'HASH' ? %{shift()} : ()); + @_ == 2 or croak 'Usage: $ssh->sshfs_import(\%opts, $remote, $local)'; + my ($from, $to) = @_; + my @sshfs_opts = ( -o => 'slave', + _array_or_scalar_to_list delete $opts{sshfs_opts} ); + _croak_bad_options %opts; + + $opts{ssh_opts} = ['-s', _array_or_scalar_to_list delete $opts{ssh_opts}]; + $opts{stdinout_dpipe} = [$self->{_sshfs_cmd}, "$self->{_host_squared}:$from", $to, @sshfs_opts]; + $opts{stdinout_dpipe_make_parent} = 1; + $self->spawn(\%opts, 'sftp'); +} + +_sub_options sshfs_export => qw(stderr_discard stderr_fh stderr_file + ssh_opts argument_encoding sshfs_opts); +sub sshfs_export { + ${^TAINT} and &_catch_tainted_args; + my $self = shift; + my %opts = (ref $_[0] eq 'HASH' ? %{shift()} : ()); + @_ == 2 or croak 'Usage: $ssh->sshfs_export(\%opts, $local, $remote)'; + my ($from, $to) = @_; + my @sshfs_opts = ( -o => 'slave', + _array_or_scalar_to_list delete $opts{sshfs_opts} ); + _croak_bad_options %opts; + $opts{stdinout_dpipe} = $self->{_sftp_server_cmd}; + + my $hostname = eval { + require Sys::Hostname; + Sys::Hostname::hostname(); + }; + $hostname = 'remote' if (not defined $hostname or + not length $hostname or + $hostname=~/^localhost\b/); + $self->spawn(\%opts, $self->{_sshfs_cmd}, "$hostname:$from", $to, @sshfs_opts); +} + sub DESTROY { my $self = shift; my $pid = $self->{_pid}; - local $@; + local ($@, $SIG{__DIE__}); $debug and $debug & 2 and _debug("DESTROY($self, pid: ", $pid, ")"); if ($pid and $self->{_perl_pid} == $$ and $self->{_thread_generation} == $thread_generation) { $debug and $debug & 32 and _debug("killing master"); - local $?; - local $!; - + local ($?, $!); unless ($self->{_wfm_state}) { # we have successfully created the master connection so we # can send control commands: @@ -2315,9 +2403,10 @@ bad idea. When possible, you should use public key authentication instead. + =item passphrase => $passphrase -Uses given passphrase to open private key. +XUses given passphrase to open private key. =item key_path => $private_key_path @@ -2436,7 +2525,14 @@ For instance: my $ssh = Net::OpenSSH->new($host, - default_ssh_options => [-o => "ConnectionAttempts=0"]); + default_ssh_opts => [-o => "ConnectionAttempts=0"]); + +=item forward_agent => 1 + +Enables forwarding of the authentication agent. + +This option can not be used when passing a passphrase (via +L) to unlock the login private key. =item default_stdin_fh => $fh @@ -2617,7 +2713,7 @@ =item stdout_pipe => 1 -Creates a new pipe and connects the writting side to the stdout stream +Creates a new pipe and connects the writing side to the stdout stream of the remote process. The reading side is returned as the second value (C<$out>). @@ -2664,7 +2760,7 @@ =item stderr_pipe => 1 -Creates a new pipe and connects the writting side to the stderr stream +Creates a new pipe and connects the writing side to the stderr stream of the remote process. The reading side is returned as the third value (C<$err>). @@ -2710,6 +2806,13 @@ See L below. +=item forward_agent => $bool + +Enables/disables forwarding of the authentication agent. + +This option can only be used when agent forwarding has been previously +requested on the constructor. + =item ssh_opts => \@opts List of extra options for the C command. @@ -2864,6 +2967,8 @@ returns the output broken into lines (it honors C<$/>, see L). +The exit status of the remote command is returned in C<$?>. + When an error happens while capturing (for instance, the operation times out), the partial captured output will be returned. Error conditions have to be explicitly checked using the L @@ -3057,8 +3162,8 @@ =item quiet => 0 By default, C is called with the quiet flag C<-q> enabled in -order to suppress progress information. This option allows reenabling -the progress indication bar. +order to suppress progress information. This option allows one to +reenable the progress indication bar. =item verbose => 1 @@ -3158,10 +3263,10 @@ =item $sftp = $ssh->sftp(%sftp_opts) -Creates a new L object for SFTP interaction that -runs through the ssh master connection. +Creates a new L object for SFTP +interaction that runs through the ssh master connection. -=item @call = $ssh->make_remote_command(%opts, @cmd) +=item @call = $ssh->make_remote_command(\%opts, @cmd) =item $call = $ssh->make_remote_command(\%opts, @cmd) @@ -3177,10 +3282,35 @@ my $remote = $ssh->make_remote_comand("cd /tmp/ && tar xf -"); system "tar cf - . | $remote"; +The options accepted are as follows: + +=over 4 + +=item tty => $bool + +Enables/disables allocation of a tty on the remote side. + +=item forward_agent => $bool + +Enables/disables forwarding of authentication agent. + +This option can only be used when agent forwarding has been previously +requested on the constructor. + +=item tunnel => 1 + +Return a command to create a connection to some TCP server reachable +from the remote host. In that case the arguments are the destination +address and port. For instance: + + $cmd = $ssh->make_remote_command({tunnel => 1}, $host, $port); + +=back + =item $ssh->wait_for_master($async) When the connection has been established by calling the constructor -with the C option, this call allows to advance the process. +with the C option, this call allows one to advance the process. If C<$async> is true, it will perform any work that can be done inmediately without waiting (for instance, entering the password or @@ -3188,7 +3318,7 @@ return. If a false value is given, it will finalize the connection process and wait until the multiplexing socket is available. -It returns a true value after the connection has been succesfully +It returns a true value after the connection has been successfully established. False is returned if the connection process fails or if it has not yet completed (then, the L method can be used to distinguish between both cases). @@ -3244,7 +3374,7 @@ =item $ssh->master_exited -This methods allows to tell the module that the master process has +This methods allows one to tell the module that the master process has exited when we get its PID from some external wait or waitpid call. For instance: @@ -3265,6 +3395,43 @@ the OS could reassign the PID to a new unrelated process and the module would try to kill it at object destruction time. +=item $pid = $ssh->sshfs_import(\%opts, $remote_fs, $local_mnt_point) + +=item $pid = $ssh->sshfs_export(\%opts, $local_fs, $remote_mnt_point) + +These methods use L to import or export a file system +through the SSH connection. + +They return the C<$pid> of the C process or of the slave C +process used to proxy it. Killing that process unmounts the file +system, though, it may be probably better to use L. + +The options acepted are as follows: + +=over + +=item ssh_opts => \@ssh_opts + +Options passed to the slave C process. + +=item sshfs_opts => \@sshfs_opts + +Options passed to the C command. For instance, to mount the file +system in read-only mode: + + my $pid = $ssh->sshfs_export({sshfs_opts => [-o => 'ro']}, + "/", "/mnt/foo"); + +=back + +Note that this command requires a recent version of C to work (at +the time of writing, it requires the yet unreleased version available +from the FUSE git repository!). + +See also the L man page and the C and FUSE web sites +at L and +L respectively. + =back =head2 Shell quoting @@ -3297,10 +3464,10 @@ Under the hood, as the Secure Shell protocol does not provide for this mode of operation and always spawns a new shell where it runs the given command, Net::OpenSSH quotes any shell metacharacters in the -comand list. +command list. All the methods that invoke a remote command (system, open_ex, etc.) -accept the option C that allows to force/disable shell +accept the option C that allows one to force/disable shell quoting. For instance: @@ -3380,7 +3547,7 @@ would be to send them signals through the SSH connection as specified by the protocol standard. -Unfortunatelly OpenSSH does not implement that feature so Net::OpenSSH +Unfortunately OpenSSH does not implement that feature so Net::OpenSSH has to use other imperfect approaches: =over 4 @@ -3408,7 +3575,7 @@ =head2 Variable expansion -The variable expansion feature allows to define variables that are +The variable expansion feature allows one to define variables that are expanded automatically inside command arguments and file paths. This feature is disabled by default. It is intended to be used with @@ -3437,8 +3604,8 @@ =head2 Tunnels Besides running commands on the remote host, Net::OpenSSH also allows -to tunnel TCP connections to remote machines reachable from the SSH -server. +one to tunnel TCP connections to remote machines reachable from the +SSH server. That feature is made available through the C option of the L method, and also through wrapper methods L @@ -3596,7 +3763,7 @@ L and L tie STDIN and STDOUT to objects that are not backed up by real file descriptors at the operative system level. Net::OpenSSH will fail if any of these handles is used -explicetly or implicitly when calling some remote command. +explicitly or implicitly when calling some remote command. The workaround is to redirect them to C or to some file: @@ -3730,7 +3897,7 @@ This is another common problem that happens when some server is replaced or reinstalled from scratch and its public key changes -becomming different to that installed on the C file. +becoming different to that installed on the C file. The easiest way to solve that problem is to remove the old key from the C file by hand using any editor and then to connect @@ -3791,6 +3958,67 @@ =back +=head1 DEBUGGING + +Debugging of Net::OpenSSH internals is controlled through the variable +C<$Net::OpenSSH::debug>. Every bit of this variable activates +debugging of some subsystem as follows: + +=over 4 + +=item bit 1 - errors + +Dumps changes on the internal object attribute where errors are stored. + +=item bit 2 - ctl_path + +Dumps information about ctl_path calculation and the tests performed +on that directory in order to decide if it is secure to place the +multiplexing socket inside. + +=item bit 4 - connecting + +Dumps information about the establishment of new master connections. + +=item bit 8 - commands and arguments + +Dumps the command and arguments for every system/exec call. + +=item bit 16 - command execution + +Dumps information about the progress of command execution. + +=item bit 32 - destruction + +Dumps information about the destruction of Net::OpenSSH objects and +the termination of the SSH master processes. + +=item bit 64 - IO loop + +Dumps information about the progress of the IO loop on capture +operations. + +=item bit 128 - IO hexdumps + +Generates hexdumps of the information that travels through the SSH +streams inside capture operations. + +=item bit 512 - OS tracing of the master process + +Use the module L to trace the SSH master +process at the OS level. + +=back + +For instance, in order to activate all the debugging flags, you can +use: + + $Net::OpenSSH::debug = ~0; + +Note that the meaning of the flags and the information generated is +only intended for debugging of the module and may change without +notice between releases. + =head1 FAQ Frequent questions about the module: @@ -3826,7 +4054,7 @@ Usually, the SSH server running on these devices does not support command mode. It unconditionally attachs the restricted shell to any -incomming SSH connection and waits for the user to enter commands +incoming SSH connection and waits for the user to enter commands through the redirected stdin stream. The only way to workaround this limitation is to make your script talk @@ -3997,12 +4225,32 @@ with the C<-k> flag. You may also like to use the C<-p> flag to tell C to print an empty prompt. For instance: - my @out = $ssh->capture({stdin_data => $sudo_passwd}, + my @out = $ssh->capture({stdin_data => "$sudo_passwd\n"}, 'sudo', '-Sk', '-p', '', '--', @cmd); +If the version of sudo installed on the remote host does not support +the C<-S> flag (it tells sudo to read the password from its STDIN +stream), you can do it as follows: + + my @out = $ssh->capture({tty => 1, + stdin_data => "$sudo_passwd\n"}, + 'sudo', '-k', + '-p', '', + '--', + @cmd); + +This may generate an spurious and harmless warning from the SSH master +connection (because we are requesting allocation of a tty on the +remote side and locally we are attaching it to a regular pair of +pipes). + +If for whatever reason the methods described above fail, you can +always revert to using Expect to talk to the remote C. See the +C script from this module distribution. + =back =head1 SEE ALSO @@ -4030,16 +4278,17 @@ this module on the remote machine (see also the C and scripts in the sample directory). -L is an advanced scheduler that allows to run +L is an advanced scheduler that allows one to run commands in remote hosts in parallel. It is obviously based on Net::OpenSSH. -L allows to run remote commands in parallel in +L allows one to run remote commands in parallel in a cluster. It is build on top on C also. Other Perl SSH clients: L, L, L, -L, L. +L, L, +L. L is a package offering a set of compatibility layers for other SSH modules on top of Net::OpenSSH. @@ -4071,7 +4320,7 @@ the CPAN bug tracking system at L. B -L, you will probably get faster responses than +L, you will probably get faster responses than if you address me directly and I visit Perlmonks quite often, so I will see your question anyway. @@ -4118,7 +4367,7 @@ =head1 COPYRIGHT AND LICENSE -Copyright (C) 2008-2011 by Salvador FandiEo +Copyright (C) 2008-2013 by Salvador FandiEo (sfandino@yahoo.com) This library is free software; you can redistribute it and/or modify