]> git.ipfire.org Git - thirdparty/curl.git/commitdiff
tests: add support to test against OpenSSH for Windows 3290/head
authorMarc Hoersken <info@marc-hoersken.de>
Mon, 19 Nov 2018 20:05:57 +0000 (21:05 +0100)
committerMarc Hoersken <info@marc-hoersken.de>
Wed, 22 May 2019 17:54:05 +0000 (19:54 +0200)
Testing against OpenSSH for Windows requires v7.7.0.0 or newer
due to the use of AllowUsers and DenyUsers. For more info see:
https://github.com/PowerShell/Win32-OpenSSH/wiki/sshd_config

tests/sshhelp.pm
tests/sshserver.pl [changed mode: 0755->0644]

index 7345eb30043576f55599b9552493352940edd2ce..47ea2324c4203572fd6e6e08e6cfcc39561bd430 100644 (file)
@@ -430,6 +430,16 @@ sub sshversioninfo {
                 $error = undef;
                 last;
             }
+            if($tmpstr =~ /OpenSSH[_-]for[_-]Windows[_-](\d+)\.(\d+)(\.(\d+))*/i) {
+                $major = $1;
+                $minor = $2;
+                $patch = $4?$4:0;
+                $sshid = 'OpenSSH-Windows';
+                $versnum = (100*$major) + (10*$minor) + $patch;
+                $versstr = "$sshid $major.$minor.$patch";
+                $error = undef;
+                last;
+            }
             if($tmpstr =~ /Sun[_-]SSH[_-](\d+)\.(\d+)(\.(\d+))*/i) {
                 $major = $1;
                 $minor = $2;
old mode 100755 (executable)
new mode 100644 (file)
index 428535e..bcb2f1b
@@ -389,6 +389,17 @@ if ($^O eq 'MSWin32' || $^O eq 'cygwin' || $^O eq 'msys') {
     $pidfile_config = pathhelp::build_sys_abs_path($pidfile_config);
     $sftpsrv_config = "internal-sftp";
 }
+if ($sshdid =~ /OpenSSH-Windows/) {
+    # Ensure to use native Windows paths with OpenSSH for Windows
+    $clipubkeyf_config = pathhelp::sys_native_abs_path($clipubkeyf);
+    $hstprvkeyf_config = pathhelp::sys_native_abs_path($hstprvkeyf);
+    $pidfile_config = pathhelp::sys_native_abs_path($pidfile);
+    $sftpsrv_config = pathhelp::sys_native_abs_path($sftpsrv);
+
+    $sshdconfig = pathhelp::sys_native_abs_path($sshdconfig);
+    $sshconfig = pathhelp::sys_native_abs_path($sshconfig);
+    $sftpconfig = pathhelp::sys_native_abs_path($sftpconfig);
+}
 
 #***************************************************************************
 #  ssh daemon configuration file options we might use and version support
@@ -483,8 +494,18 @@ logmsg 'generating ssh server config file...' if($verbose);
 push @cfgarr, '# This is a generated file.  Do not edit.';
 push @cfgarr, "# $sshdverstr sshd configuration file for curl testing";
 push @cfgarr, '#';
-push @cfgarr, "DenyUsers !$username";
-push @cfgarr, "AllowUsers $username";
+
+# AllowUsers and DenyUsers options should use lowercase on Windows
+# and do not support quotes around values for some unknown reason.
+if ($sshdid =~ /OpenSSH-Windows/) {
+    my $username_lc = lc $username;
+    push @cfgarr, "DenyUsers !$username_lc";
+    push @cfgarr, "AllowUsers $username_lc";
+} else {
+    push @cfgarr, "DenyUsers !$username";
+    push @cfgarr, "AllowUsers $username";
+}
+
 push @cfgarr, 'DenyGroups';
 push @cfgarr, 'AllowGroups';
 push @cfgarr, '#';
@@ -758,7 +779,11 @@ if ($^O eq 'MSWin32' || $^O eq 'cygwin' || $^O eq 'msys') {
     $identity_config = pathhelp::build_sys_abs_path($identity_config);
     $knownhosts_config = pathhelp::build_sys_abs_path($knownhosts_config);
 }
-
+if ($sshdid =~ /OpenSSH-Windows/) {
+    # Ensure to use native Windows paths with OpenSSH for Windows
+    $identity_config = pathhelp::sys_native_abs_path($identity);
+    $knownhosts_config = pathhelp::sys_native_abs_path($knownhosts);
+}
 
 #***************************************************************************
 #  ssh client configuration file options we might use and version support
@@ -853,7 +878,12 @@ push @cfgarr, "HostName $listenaddr";
 push @cfgarr, "User $username";
 push @cfgarr, 'Protocol 2';
 push @cfgarr, '#';
-push @cfgarr, "BindAddress $listenaddr";
+
+# BindAddress option is not supported by OpenSSH for Windows
+if (!($sshdid =~ /OpenSSH-Windows/)) {
+    push @cfgarr, "BindAddress $listenaddr";
+}
+
 push @cfgarr, '#';
 push @cfgarr, "IdentityFile $identity_config";
 push @cfgarr, "UserKnownHostsFile $knownhosts_config";
@@ -875,8 +905,12 @@ push @cfgarr, 'NumberOfPasswordPrompts 0';
 push @cfgarr, 'PasswordAuthentication no';
 push @cfgarr, 'PreferredAuthentications publickey';
 push @cfgarr, 'PubkeyAuthentication yes';
-push @cfgarr, 'RhostsRSAAuthentication no';
-push @cfgarr, 'RSAAuthentication no';
+
+# RSA authentication options are not supported by OpenSSH for Windows
+if (!($sshdid =~ /OpenSSH-Windows/)) {
+    push @cfgarr, 'RhostsRSAAuthentication no';
+    push @cfgarr, 'RSAAuthentication no';
+}
 
 # Disabled StrictHostKeyChecking since it makes the tests fail on my
 # OpenSSH_6.0p1 on Debian Linux / Daniel