summaryrefslogtreecommitdiff
path: root/tests/sshserver.pl
diff options
context:
space:
mode:
authorYang Tse <yangsita@gmail.com>2008-02-08 13:54:02 +0000
committerYang Tse <yangsita@gmail.com>2008-02-08 13:54:02 +0000
commit1a340de0e5f378e58130dd86955e6bcee47b6f19 (patch)
treece96dff2f7debdf58432e5e51717ee052e687959 /tests/sshserver.pl
parent05c191199dbbc0ac0dbfaebb075b78802edb6f80 (diff)
downloadcurl-1a340de0e5f378e58130dd86955e6bcee47b6f19.tar.gz
To verify that the sftp server is actually running, responsive and that
all curl's tests generated configuration and key files are fine, a real connection is established to the test harness sftp server authenticating and running a simple sftp remote pwd command. The verification is done using OpenSSH's or SunSSH's sftp client tool with a configuration file with the same options as the test harness socks server with the exception that dynamic forwarding is not used for sftp.
Diffstat (limited to 'tests/sshserver.pl')
-rw-r--r--tests/sshserver.pl67
1 files changed, 64 insertions, 3 deletions
diff --git a/tests/sshserver.pl b/tests/sshserver.pl
index e94125343..3eb57a643 100644
--- a/tests/sshserver.pl
+++ b/tests/sshserver.pl
@@ -44,24 +44,31 @@ use Cwd;
use sshhelp qw(
$sshdexe
$sshexe
+ $sftpsrvexe
$sftpexe
$sshkeygenexe
$sshdconfig
$sshconfig
+ $sftpconfig
$knownhosts
$sshdlog
$sshlog
+ $sftplog
+ $sftpcmds
$hstprvkeyf
$hstpubkeyf
$cliprvkeyf
$clipubkeyf
display_sshdconfig
display_sshconfig
+ display_sftpconfig
display_sshdlog
display_sshlog
+ display_sftplog
dump_array
find_sshd
find_ssh
+ find_sftpsrv
find_sftp
find_sshkeygen
logmsg
@@ -193,12 +200,23 @@ if((($sshdid =~ /OpenSSH/) && ($sshdvernum < 299)) ||
#***************************************************************************
# Find out sftp server plugin canonical file name
#
+my $sftpsrv = find_sftpsrv();
+if(!$sftpsrv) {
+ logmsg "cannot find $sftpsrvexe";
+ exit 1;
+}
+logmsg "sftp server plugin found $sftpsrv" if($verbose);
+
+
+#***************************************************************************
+# Find out sftp client canonical file name
+#
my $sftp = find_sftp();
if(!$sftp) {
logmsg "cannot find $sftpexe";
exit 1;
}
-logmsg "sftp server plugin found $sftp" if($verbose);
+logmsg "sftp client found $sftp" if($verbose);
#***************************************************************************
@@ -428,7 +446,7 @@ push @cfgarr, 'RhostsRSAAuthentication no';
push @cfgarr, 'RSAAuthentication no';
push @cfgarr, 'ServerKeyBits 768';
push @cfgarr, 'StrictModes no';
-push @cfgarr, "Subsystem sftp $sftp";
+push @cfgarr, "Subsystem sftp $sftpsrv -f AUTH -l $loglevel";
push @cfgarr, 'SyslogFacility AUTH';
push @cfgarr, 'UseLogin no';
push @cfgarr, 'X11Forwarding no';
@@ -861,12 +879,55 @@ if($error) {
logmsg $error;
exit 1;
}
+
+
+#***************************************************************************
+# Initialize client sftp config with options actually supported.
+#
+logmsg 'generating sftp client config file...' if($verbose);
+splice @cfgarr, 1, 1, "# $sshverstr sftp client configuration file for curl testing";
+#
+for(my $i = scalar(@cfgarr) - 1; $i > 0; $i--) {
+ if($cfgarr[$i] =~ /^DynamicForward/) {
+ splice @cfgarr, $i, 1;
+ next;
+ }
+ if($cfgarr[$i] =~ /^ClearAllForwardings/) {
+ splice @cfgarr, $i, 1, "ClearAllForwardings yes";
+ next;
+ }
+}
+
+
+#***************************************************************************
+# Write out resulting sftp client configuration file for curl's tests
+#
+$error = dump_array($sftpconfig, @cfgarr);
+if($error) {
+ logmsg $error;
+ exit 1;
+}
+@cfgarr = ();
+
+
+#***************************************************************************
+# Generate client sftp commands batch file for sftp server verification
+#
+logmsg 'generating sftp client commands file...' if($verbose);
+push @cfgarr, 'pwd';
+push @cfgarr, 'quit';
+$error = dump_array($sftpcmds, @cfgarr);
+if($error) {
+ logmsg $error;
+ exit 1;
+}
@cfgarr = ();
#***************************************************************************
# Start the ssh server daemon without forking it
#
+logmsg "SCP/SFTP server listening on port $port" if($verbose);
my $rc = system "$sshd -e -D -f $sshdconfig > $sshdlog 2>&1";
if($rc == -1) {
logmsg "$sshd failed with: $!";
@@ -884,7 +945,7 @@ elsif($verbose && ($rc >> 8)) {
# Clean up once the server has stopped
#
unlink($hstprvkeyf, $hstpubkeyf, $cliprvkeyf, $clipubkeyf, $knownhosts);
-unlink($sshdconfig, $sshconfig);
+unlink($sshdconfig, $sshconfig, $sftpconfig);
exit 0;