summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarc Hoersken <info@marc-hoersken.de>2018-11-19 21:05:57 +0100
committerMarc Hoersken <info@marc-hoersken.de>2019-05-22 19:54:05 +0200
commit081d374f4949b7fabfa76a0fb14daa02d47b5050 (patch)
tree41b3843fe4982b088d99b708f18224f218f85177
parenta57e4786b710b51fe463420f36f1d2a61a029f36 (diff)
downloadcurl-081d374f4949b7fabfa76a0fb14daa02d47b5050.tar.gz
tests: add support to test against OpenSSH for Windows
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
-rw-r--r--tests/sshhelp.pm10
-rw-r--r--[-rwxr-xr-x]tests/sshserver.pl46
2 files changed, 50 insertions, 6 deletions
diff --git a/tests/sshhelp.pm b/tests/sshhelp.pm
index 7345eb300..47ea2324c 100644
--- a/tests/sshhelp.pm
+++ b/tests/sshhelp.pm
@@ -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;
diff --git a/tests/sshserver.pl b/tests/sshserver.pl
index 428535ece..bcb2f1b3a 100755..100644
--- a/tests/sshserver.pl
+++ b/tests/sshserver.pl
@@ -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