]> git.ipfire.org Git - thirdparty/curl.git/commitdiff
tests: use Cygwin-style paths in SSH, SSHD and SFTP config files
authorMarc Hoersken <info@marc-hoersken.de>
Sun, 21 Dec 2014 02:48:41 +0000 (03:48 +0100)
committerMarc Hoersken <info@marc-hoersken.de>
Sun, 21 Dec 2014 02:52:37 +0000 (03:52 +0100)
Second patch to enable Windows support using Cygwin-based OpenSSH.

Tested with CopSSH 5.0.0 free edition using an msys shell on Windows 7.

tests/sshserver.pl

index 794cadcddd481786c2a92702acbd642860d21303..f167f0a21b4c228a18980273a8ff3a7b0bd3011e 100755 (executable)
@@ -27,6 +27,7 @@
 use strict;
 use warnings;
 use Cwd;
+use Cwd 'abs_path';
 
 #***************************************************************************
 # Variables and subs imported from sshhelp module
@@ -381,6 +382,22 @@ if((! -e $hstprvkeyf) || (! -s $hstprvkeyf) ||
 }
 
 
+#***************************************************************************
+# Convert paths for curl's tests running on Windows using Cygwin OpenSSH
+#
+my $clipubkeyf_config = abs_path("$path/$clipubkeyf");
+my $hstprvkeyf_config = abs_path("$path/$hstprvkeyf");
+my $pidfile_config = $pidfile;
+my $sftpsrv_config = $sftpsrv;
+
+if ($^O eq 'MSWin32' || $^O eq 'cygwin' || $^O eq 'msys') {
+    # convert MinGW drive paths to Cygwin drive paths
+    $clipubkeyf_config =~ s/^\/(\w)\//\/cygdrive\/$1\//;
+    $hstprvkeyf_config =~ s/^\/(\w)\//\/cygdrive\/$1\//;
+    $pidfile_config =~ s/^\/(\w)\//\/cygdrive\/$1\//;
+    $sftpsrv_config = "internal-sftp";
+}
+
 #***************************************************************************
 #  ssh daemon configuration file options we might use and version support
 #
@@ -479,10 +496,10 @@ push @cfgarr, "AllowUsers $username";
 push @cfgarr, 'DenyGroups';
 push @cfgarr, 'AllowGroups';
 push @cfgarr, '#';
-push @cfgarr, "AuthorizedKeysFile $path/$clipubkeyf";
-push @cfgarr, "AuthorizedKeysFile2 $path/$clipubkeyf";
-push @cfgarr, "HostKey $path/$hstprvkeyf";
-push @cfgarr, "PidFile $pidfile";
+push @cfgarr, "AuthorizedKeysFile $clipubkeyf_config";
+push @cfgarr, "AuthorizedKeysFile2 $clipubkeyf_config";
+push @cfgarr, "HostKey $hstprvkeyf_config";
+push @cfgarr, "PidFile $pidfile_config";
 push @cfgarr, '#';
 push @cfgarr, "Port $port";
 push @cfgarr, "ListenAddress $listenaddr";
@@ -512,7 +529,7 @@ push @cfgarr, 'RhostsRSAAuthentication no';
 push @cfgarr, 'RSAAuthentication no';
 push @cfgarr, 'ServerKeyBits 768';
 push @cfgarr, 'StrictModes no';
-push @cfgarr, "Subsystem sftp \"$sftpsrv\"";
+push @cfgarr, "Subsystem sftp \"$sftpsrv_config\"";
 push @cfgarr, 'SyslogFacility AUTH';
 push @cfgarr, 'UseLogin no';
 push @cfgarr, 'X11Forwarding no';
@@ -738,6 +755,19 @@ if((! -e $knownhosts) || (! -s $knownhosts)) {
 }
 
 
+#***************************************************************************
+# Convert paths for curl's tests running on Windows using Cygwin OpenSSH
+#
+my $identityf = abs_path("$path/curl_client_key");
+my $knownhostsf = abs_path("$path/$knownhosts");
+
+if ($^O eq 'MSWin32' || $^O eq 'cygwin' || $^O eq 'msys') {
+    # convert MinGW drive paths to Cygwin drive paths
+    $identityf =~ s/^\/(\w)\//\/cygdrive\/$1\//;
+    $knownhostsf =~ s/^\/(\w)\//\/cygdrive\/$1\//;
+}
+
+
 #***************************************************************************
 #  ssh client configuration file options we might use and version support
 #
@@ -834,8 +864,8 @@ push @cfgarr, '#';
 push @cfgarr, "BindAddress $listenaddr";
 push @cfgarr, "DynamicForward $socksport";
 push @cfgarr, '#';
-push @cfgarr, "IdentityFile $path/curl_client_key";
-push @cfgarr, "UserKnownHostsFile $path/$knownhosts";
+push @cfgarr, "IdentityFile $identityf";
+push @cfgarr, "UserKnownHostsFile $knownhostsf";
 push @cfgarr, '#';
 push @cfgarr, 'BatchMode yes';
 push @cfgarr, 'ChallengeResponseAuthentication no';