[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[gnurl] 165/264: tests: use Cygwin/msys PIDs for stunnel and sshd on Win
From: |
gnunet |
Subject: |
[gnurl] 165/264: tests: use Cygwin/msys PIDs for stunnel and sshd on Windows |
Date: |
Thu, 30 Apr 2020 16:07:48 +0200 |
This is an automated email from the git hooks/post-receive script.
nikita pushed a commit to branch master
in repository gnurl.
commit c1951cdb38817c4c7ba14535140912f5f69ae982
Author: Marc Hoersken <address@hidden>
AuthorDate: Fri Apr 10 22:54:24 2020 +0200
tests: use Cygwin/msys PIDs for stunnel and sshd on Windows
Since the Windows versions of both programs would write Windows
PIDs to their pidfiles which we cannot handle, we need to use
our known perl.exe Cygwin/msys PID together with exec() in order
to tie the spawned processes to the existance of our perl.exe
The perl.exe that is executing secureserver.pl and sshserver.pl
has a Cygwin/msys PID, because it is started inside Cygwin/msys.
Related to #5188
---
tests/secureserver.pl | 5 ++++-
tests/sshserver.pl | 34 +++++++++++++++++++++++++++++++---
2 files changed, 35 insertions(+), 4 deletions(-)
diff --git a/tests/secureserver.pl b/tests/secureserver.pl
index 492e180c8..c525ef7d8 100755
--- a/tests/secureserver.pl
+++ b/tests/secureserver.pl
@@ -329,6 +329,7 @@ if($stunnel_version >= 400) {
# Set file permissions on certificate pem file.
#
chmod(0600, $certfile) if(-f $certfile);
+print STDERR "RUN: $cmd\n" if($verbose);
#***************************************************************************
# Run tstunnel on Windows.
@@ -341,8 +342,10 @@ if($tstunnel_windows) {
}
# Put an "exec" in front of the command so that the child process
- # keeps this child's process ID.
+ # keeps this child's process ID by being tied to the spawned shell.
exec("exec $cmd") || die "Can't exec() $cmd: $!";
+ # exec() will create a new process, but ties the existance of the
+ # new process to the parent waiting perl.exe and sh.exe processes.
# exec() should never return back here to this process. We protect
# ourselves by calling die() just in case something goes really bad.
diff --git a/tests/sshserver.pl b/tests/sshserver.pl
index 084b4a83c..1874b9388 100644
--- a/tests/sshserver.pl
+++ b/tests/sshserver.pl
@@ -535,7 +535,9 @@ push @cfgarr, '#';
push @cfgarr, "AuthorizedKeysFile $clipubkeyf_config";
push @cfgarr, "AuthorizedKeysFile2 $clipubkeyf_config";
push @cfgarr, "HostKey $hstprvkeyf_config";
-push @cfgarr, "PidFile $pidfile_config";
+if ($sshdid !~ /OpenSSH-Windows/) {
+ push @cfgarr, "PidFile $pidfile_config";
+}
push @cfgarr, '#';
push @cfgarr, "Port $port";
push @cfgarr, "ListenAddress $listenaddr";
@@ -1098,12 +1100,38 @@ if($error) {
}
@cfgarr = ();
+#***************************************************************************
+# Prepare command line of ssh server daemon
+#
+my $cmd = "\"$sshd\" -e -D -f $sshdconfig > $sshdlog 2>&1";
+logmsg "SCP/SFTP server listening on port $port" if($verbose);
+logmsg "RUN: $cmd" if($verbose);
+
+#***************************************************************************
+# Start the ssh server daemon on Windows without forking it
+#
+if ($sshdid =~ /OpenSSH-Windows/) {
+ # Fake pidfile for ssh server on Windows.
+ if(open(OUT, ">$pidfile")) {
+ print OUT $$ . "\n";
+ close(OUT);
+ }
+
+ # Put an "exec" in front of the command so that the child process
+ # keeps this child's process ID by being tied to the spawned shell.
+ exec("exec $cmd") || die "Can't exec() $cmd: $!";
+ # exec() will create a new process, but ties the existance of the
+ # new process to the parent waiting perl.exe and sh.exe processes.
+
+ # exec() should never return back here to this process. We protect
+ # ourselves by calling die() just in case something goes really bad.
+ die "error: exec() has returned";
+}
#***************************************************************************
# 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";
+my $rc = system($cmd);
if($rc == -1) {
logmsg "\"$sshd\" failed with: $!";
}
--
To stop receiving notification emails like this one, please contact
address@hidden.
- [gnurl] 124/264: KNOWN_BUGS: fixed "USE_UNIX_SOCKETS on Windows", (continued)
- [gnurl] 124/264: KNOWN_BUGS: fixed "USE_UNIX_SOCKETS on Windows", gnunet, 2020/04/30
- [gnurl] 154/264: CI/macos: convert CRLF to LF and align indentation, gnunet, 2020/04/30
- [gnurl] 152/264: server/resolve: remove AI_CANONNAME to make macos tell the truth, gnunet, 2020/04/30
- [gnurl] 213/264: tests/FILEFORMAT: converted to markdown and extended, gnunet, 2020/04/30
- [gnurl] 259/264: doh: Constify some input pointers, gnunet, 2020/04/30
- [gnurl] 161/264: release-notes.pl: detect the start of the references in cleanup mode, gnunet, 2020/04/30
- [gnurl] 214/264: mime: properly check Content-Type even if it has parameters, gnunet, 2020/04/30
- [gnurl] 164/264: tests: add Windows compatible pidwait like pidkill and pidterm, gnunet, 2020/04/30
- [gnurl] 166/264: tests/server/util.c: use curl_off_t instead of long for pid, gnunet, 2020/04/30
- [gnurl] 167/264: compressed.d: stress that the headers are not modified, gnunet, 2020/04/30
- [gnurl] 165/264: tests: use Cygwin/msys PIDs for stunnel and sshd on Windows,
gnunet <=
- [gnurl] 264/264: make gnurl-aux, gnunet, 2020/04/30
- [gnurl] 177/264: cirrus: no longer ignore test 504 which is working again, gnunet, 2020/04/30
- [gnurl] 180/264: tool: do not declare functions with Curl_ prefix, gnunet, 2020/04/30
- [gnurl] 229/264: http: free memory when Alt-Used header creation fails due to OOM, gnunet, 2020/04/30
- [gnurl] 162/264: RELEASE-NOTES: synced, gnunet, 2020/04/30
- [gnurl] 157/264: sshserver.pl: use cached Win32 environment check variable, gnunet, 2020/04/30
- [gnurl] 175/264: test1908: avoid using fixed port number in test data, gnunet, 2020/04/30
- [gnurl] 183/264: tests: support hex encoded data and mqtt server, gnunet, 2020/04/30
- [gnurl] 156/264: appveyor: partially revert 3413a110 to keep build without proxy, gnunet, 2020/04/30
- [gnurl] 173/264: socks: Fix blocking timeout logic, gnunet, 2020/04/30