summaryrefslogtreecommitdiff
path: root/tests/secureserver.pl
diff options
context:
space:
mode:
authorMarc Hoersken <info@marc-hoersken.de>2014-01-13 00:09:46 +0100
committerMarc Hoersken <info@marc-hoersken.de>2014-01-13 00:09:46 +0100
commit87ade5f0eb0d40c14ba65b04d309a4f52a49c1be (patch)
treefe82d33d52f8440a671315296e5ce7edfddf7338 /tests/secureserver.pl
parenta33e7edcec0fe6f980a0dc7b5670072c4be58708 (diff)
downloadcurl-87ade5f0eb0d40c14ba65b04d309a4f52a49c1be.tar.gz
secureserver.pl: added full support for tstunnel on Windows
tstunnel on Windows does not support the pid option and is unable to write to an output log that is already being used as a redirection target for stdout. Therefore it does now output all log data to stdout by default and secureserver.pl creates a fake pidfile on Windows.
Diffstat (limited to 'tests/secureserver.pl')
-rwxr-xr-xtests/secureserver.pl47
1 files changed, 34 insertions, 13 deletions
diff --git a/tests/secureserver.pl b/tests/secureserver.pl
index bb4452269..37a395710 100755
--- a/tests/secureserver.pl
+++ b/tests/secureserver.pl
@@ -248,19 +248,21 @@ if($stunnel_version >= 400) {
$SIG{TERM} = \&exit_signal_handler;
# stunnel configuration file
if(open(STUNCONF, ">$conffile")) {
- print STUNCONF "
- CApath = $path
- cert = $certfile
- pid = $pidfile
- debug = $loglevel
- output = $logfile
- socket = $socketopt
- foreground = yes
-
- [curltest]
- accept = $accept_port
- connect = $target_port
- ";
+ print STUNCONF "
+ CApath = $path
+ cert = $certfile
+ debug = $loglevel
+ output = /dev/stdout
+ socket = $socketopt";
+ if($stunnel !~ /tstunnel(\.exe)?"?$/) {
+ print STUNCONF "
+ pid = $pidfile
+ foreground = yes";
+ }
+ print STUNCONF "
+ [curltest]
+ accept = $accept_port
+ connect = $target_port";
if(!close(STUNCONF)) {
print "$ssltext Error closing file $conffile\n";
exit 1;
@@ -293,6 +295,25 @@ if($stunnel_version >= 400) {
chmod(0600, $certfile) if(-f $certfile);
#***************************************************************************
+# Run tstunnel on Windows.
+#
+if($stunnel =~ /tstunnel(\.exe)?"?$/) {
+ # Fake pidfile for tstunnel 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.
+ exec("exec $cmd") || die "Can't exec() $cmd: $!";
+
+ # 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";
+}
+
+#***************************************************************************
# Run stunnel.
#
my $rc = system($cmd);