- patch from Anthony Awtrey <tony@awtrey.com> to use s/=/ / in -o
authorivan <ivan>
Fri, 15 Mar 2002 10:43:38 +0000 (10:43 +0000)
committerivan <ivan>
Fri, 15 Mar 2002 10:43:38 +0000 (10:43 +0000)
          options again if OpenSSH v1 is detected

Changes
SSH.pm

diff --git a/Changes b/Changes
index 0e6ef41..fd7ed17 100644 (file)
--- a/Changes
+++ b/Changes
@@ -1,6 +1,10 @@
 Revision history for Perl extension Net::SSH.
 
-0.05  unreleased
+0.06  unreleased
+       - patch from Anthony Awtrey <tony@awtrey.com> to use s/=/ / in -o
+         options again if OpenSSH v1 is detected
+
+0.05  Fri Feb 15 15:46:00 2002
        - brainfart mis-credit
 
 0.04  Fri Feb 15 14:05:06 2002
diff --git a/SSH.pm b/SSH.pm
index 8e55a8a..b5391d5 100644 (file)
--- a/SSH.pm
+++ b/SSH.pm
@@ -1,7 +1,7 @@
 package Net::SSH;
 
 use strict;
-use vars qw($VERSION @ISA @EXPORT_OK $ssh $DEBUG);
+use vars qw($VERSION @ISA @EXPORT_OK $ssh $equalspace $DEBUG);
 use Exporter;
 use IO::File;
 use IPC::Open2;
@@ -9,12 +9,25 @@ use IPC::Open3;
 
 @ISA = qw(Exporter);
 @EXPORT_OK = qw( ssh issh ssh_cmd sshopen2 sshopen3 );
-$VERSION = '0.05';
+$VERSION = '0.06';
 
 $DEBUG = 0;
 
 $ssh = "ssh";
 
+my $reader = IO::File->new();
+my $writer = IO::File->new();
+my $error  = IO::File->new();
+open3($writer, $reader, $error, $ssh, '-V');
+my $ssh_version = <$error>;
+chomp($ssh_version);
+$ssh_version =~ s/.*OpenSSH[-|_](\w+?)\.\w+?\.\w+?.*/$1/g;
+if ($ssh_version == 1) {
+  $equalspace = " ";
+} else {
+  $equalspace = "=";
+}
+
 =head1 NAME
 
 Net::SSH - Perl extension for secure shell
@@ -52,7 +65,7 @@ Calls ssh in batch mode.
 
 sub ssh {
   my($host, @command) = @_;
-  my @cmd = ($ssh, '-o', 'BatchMode=yes', $host, @command);
+  my @cmd = ($ssh, '-o', 'BatchMode'.$equalspace.'yes', $host, @command);
   warn "[Net::SSH::ssh] executing ". join(' ', @cmd). "\n"
     if $DEBUG;
   system(@cmd);
@@ -110,7 +123,7 @@ Connects the supplied filehandles to the ssh process (in batch mode).
 
 sub sshopen2 {
   my($host, $reader, $writer, @command) = @_;
-  open2($reader, $writer, $ssh, '-o', 'BatchMode=yes', $host, @command);
+  open2($reader, $writer, $ssh, '-o', 'BatchMode'.$equalspace.'yes', $host, @command);
 }
 
 =item sshopen3 HOST, WRITER, READER, ERROR, COMMAND [, ARGS ... ]
@@ -121,7 +134,7 @@ Connects the supplied filehandles to the ssh process (in batch mode).
 
 sub sshopen3 {
   my($host, $writer, $reader, $error, @command) = @_;
-  open3($writer, $reader, $error, $ssh, '-o', 'BatchMode=yes', $host, @command);
+  open3($writer, $reader, $error, $ssh, '-o', 'BatchMode'.$equalspace.'yes', $host, @command);
 }
 
 sub _yesno {
@@ -172,6 +185,9 @@ John Harrison <japh@in-ta.net> contributed an example for the documentation.
 Martin Langhoff <martin@cwa.co.nz> contributed the ssh_cmd command, and
 Jeff Finucane <jeff@cmh.net> updated it and took care of the 0.04 release.
 
+Anthony Awtrey <tony@awtrey.com> contributed a fix for those still using
+OpenSSH v1.
+
 =head1 COPYRIGHT
 
 Copyright (c) 2002 Ivan Kohler.