Start using the centralized pidfile and logfile name generation

subroutines for ftp, pop3, imap and smtp test suite servers.
This commit is contained in:
Yang Tse
2010-01-09 18:35:59 +00:00
parent b90703f594
commit 017c14cc99
3 changed files with 226 additions and 149 deletions

View File

@@ -5,7 +5,7 @@
# | (__| |_| | _ <| |___ # | (__| |_| | _ <| |___
# \___|\___/|_| \_\_____| # \___|\___/|_| \_\_____|
# #
# Copyright (C) 1998 - 2009, Daniel Stenberg, <daniel@haxx.se>, et al. # Copyright (C) 1998 - 2010, Daniel Stenberg, <daniel@haxx.se>, et al.
# #
# This software is licensed as described in the file COPYING, which # This software is licensed as described in the file COPYING, which
# you should have received as part of this distribution. The terms # you should have received as part of this distribution. The terms
@@ -24,6 +24,12 @@
use strict; use strict;
use warnings; use warnings;
use serverhelp qw(
servername_str
mainsockf_pidfilename
datasockf_pidfilename
);
####################################################################### #######################################################################
# pidfromfile returns the pid stored in the given pidfile. The value # pidfromfile returns the pid stored in the given pidfile. The value
# of the returned pid will never be a negative value. It will be zero # of the returned pid will never be a negative value. It will be zero
@@ -167,44 +173,52 @@ sub killpid {
} }
} }
############################################################################# #######################################################################
# Kill a specific slave # killsockfilters kills sockfilter processes for a given server.
# #
sub ftpkillslave { sub killsockfilters {
my ($id, $ext, $verbose)=@_; my ($proto, $ipvnum, $idnum, $verbose) = @_;
my $srvrname;
my $pidfile;
my $pid;
for my $base (('filt', 'data')) { return if($proto !~ /^(ftp|imap|pop3|smtp)$/);
my $f = ".sock$base$id$ext.pid";
my $pid = processexists($f); $srvrname = servername_str($proto, $ipvnum, $idnum) if($verbose);
if($pid > 0) {
printf("* kill pid for %s => %d\n", "ftp-$base$id$ext", $pid) $pidfile = "./". mainsockf_pidfilename($proto, $ipvnum, $idnum);
if($verbose); $pid = processexists($pidfile);
kill (9, $pid); if($pid > 0) {
waitpid($pid, 0); printf("* kill pid for %s => %d\n", "${srvrname}-CTRL", $pid)
} if($verbose);
unlink($f); kill("KILL", $pid);
waitpid($pid, 0);
} }
unlink($pidfile) if(-f $pidfile);
return if($proto ne 'ftp');
$pidfile = "./". datasockf_pidfilename($proto, $ipvnum, $idnum);
$pid = processexists($pidfile);
if($pid > 0) {
printf("* kill pid for %s => %d\n", "${srvrname}-DATA", $pid)
if($verbose);
kill("KILL", $pid);
waitpid($pid, 0);
}
unlink($pidfile) if(-f $pidfile);
} }
############################################################################# #######################################################################
# Make sure no FTP leftovers are still running. Kill all slave processes. # killallsockfilters kills sockfilter processes for all servers.
# This uses pidfiles since it might be used by other processes.
# #
sub ftpkillslaves { sub killallsockfilters {
my ($verbose) = @_; my $verbose = $_[0];
for my $ext (('', 'ipv6')) { for my $proto (('ftp', 'imap', 'pop3', 'smtp')) {
for my $id (('', '2')) { for my $ipvnum (('4', '6')) {
for my $base (('filt', 'data')) { for my $idnum (('1', '2')) {
my $f = ".sock$base$id$ext.pid"; killsockfilters($proto, $ipvnum, $idnum, $verbose);
my $pid = processexists($f);
if($pid > 0) {
printf("* kill pid for %s => %d\n", "ftp-$base$id$ext",
$pid) if($verbose);
kill (9, $pid);
waitpid($pid, 0);
}
unlink($f);
} }
} }
} }

View File

@@ -39,14 +39,8 @@
# All socket/network/TCP related stuff is done by the 'sockfilt' program. # All socket/network/TCP related stuff is done by the 'sockfilt' program.
# #
use strict;
use warnings;
use IPC::Open2;
require "getpart.pm";
require "ftp.pm";
BEGIN { BEGIN {
@INC=(@INC, $ENV{'srcdir'}, '.');
# sub second timestamping needs Time::HiRes # sub second timestamping needs Time::HiRes
eval { eval {
no warnings "all"; no warnings "all";
@@ -55,29 +49,53 @@ BEGIN {
} }
} }
use strict;
use warnings;
use IPC::Open2;
require "getpart.pm";
require "ftp.pm";
use serverhelp qw(
servername_str
server_pidfilename
server_logfilename
mainsockf_pidfilename
mainsockf_logfilename
datasockf_pidfilename
datasockf_logfilename
);
#********************************************************************** #**********************************************************************
# global vars... # global vars...
# #
my $verbose = 0; # set to 1 for debugging my $verbose = 0; # set to 1 for debugging
my $ftpdnum = ""; # server instance number my $idstr = ""; # server instance string
my $idnum = 1; # server instance number
my $ipvnum = 4; # server IPv number (4 or 6) my $ipvnum = 4; # server IPv number (4 or 6)
my $proto = 'ftp'; # server protocol my $proto = 'ftp'; # default server protocol
my $srcdir = '.'; # directory where ftpserver.pl is located my $srcdir; # directory where ftpserver.pl is located
my $ipv6 = ""; my $srvrname; # server name for presentation purposes
my $ext = "";
my $grok_eprt; my $grok_eprt;
my $path = '.';
my $logdir = $path .'/log';
#********************************************************************** #**********************************************************************
# global vars used for server address and primary listener port # global vars used for server address and primary listener port
# #
my $port = 8921; # server primary listener port my $port = 8921; # default primary listener port
my $listenaddr = '127.0.0.1'; # server address for listener port my $listenaddr = '127.0.0.1'; # default address for listener port
#********************************************************************** #**********************************************************************
# global vars used for file names # global vars used for file names
# #
my $logfilename = 'log/logfile.log'; # Override this for each test server my $pidfile; # server pid file name
my $pidfile = '.ftpd.pid'; # a default, use --pidfile my $logfile; # server log file name
my $mainsockf_pidfile; # pid file for primary connection sockfilt process
my $mainsockf_logfile; # log file for primary connection sockfilt process
my $datasockf_pidfile; # pid file for secondary connection sockfilt process
my $datasockf_logfile; # log file for secondary connection sockfilt process
#********************************************************************** #**********************************************************************
# global vars used for server logs advisor read lock handling # global vars used for server logs advisor read lock handling
@@ -133,7 +151,7 @@ my $exit_signal; # first signal handled in exit_signal_handler
sub exit_signal_handler { sub exit_signal_handler {
my $signame = shift; my $signame = shift;
# For now, simply mimic old behavior. # For now, simply mimic old behavior.
ftpkillslaves($verbose); killsockfilters($proto, $ipvnum, $idnum, $verbose);
unlink($pidfile); unlink($pidfile);
if($serverlogslocked) { if($serverlogslocked) {
$serverlogslocked = 0; $serverlogslocked = 0;
@@ -142,19 +160,6 @@ sub exit_signal_handler {
exit; exit;
} }
#**********************************************************************
# getlogfilename returns a log file name depending on given arguments.
#
sub getlogfilename {
my ($proto, $ipversion, $ssl, $instance, $sockfilter) = @_;
my $filename;
# For now, simply mimic old behavior.
$filename = "log/ftpd$ftpdnum.log";
return $filename;
}
#********************************************************************** #**********************************************************************
# logmsg is general message logging subroutine for our test servers. # logmsg is general message logging subroutine for our test servers.
# #
@@ -173,7 +178,7 @@ sub logmsg {
localtime($seconds); localtime($seconds);
$now = sprintf("%02d:%02d:%02d ", $hour, $min, $sec); $now = sprintf("%02d:%02d:%02d ", $hour, $min, $sec);
} }
if(open(LOGFILEFH, ">>$logfilename")) { if(open(LOGFILEFH, ">>$logfile")) {
print LOGFILEFH $now; print LOGFILEFH $now;
print LOGFILEFH @_; print LOGFILEFH @_;
close(LOGFILEFH); close(LOGFILEFH);
@@ -182,8 +187,8 @@ sub logmsg {
sub ftpmsg { sub ftpmsg {
# append to the server.input file # append to the server.input file
open(INPUT, ">>log/server$ftpdnum.input") || open(INPUT, ">>log/server$idstr.input") ||
logmsg "failed to open log/server$ftpdnum.input\n"; logmsg "failed to open log/server$idstr.input\n";
print INPUT @_; print INPUT @_;
close(INPUT); close(INPUT);
@@ -207,11 +212,11 @@ sub sysread_or_die {
if(not defined $result) { if(not defined $result) {
($fcaller, $lcaller) = (caller)[1,2]; ($fcaller, $lcaller) = (caller)[1,2];
logmsg "Failed to read input\n"; logmsg "Failed to read input\n";
logmsg "Error: ftp$ftpdnum$ext sysread error: $!\n"; logmsg "Error: $srvrname server, sysread error: $!\n";
kill(9, $sfpid); kill(9, $sfpid);
waitpid($sfpid, 0); waitpid($sfpid, 0);
logmsg "Exited from sysread_or_die() at $fcaller " . logmsg "Exited from sysread_or_die() at $fcaller " .
"line $lcaller. ftp$ftpdnum$ext sysread error: $!\n"; "line $lcaller. $srvrname server, sysread error: $!\n";
unlink($pidfile); unlink($pidfile);
if($serverlogslocked) { if($serverlogslocked) {
$serverlogslocked = 0; $serverlogslocked = 0;
@@ -222,11 +227,11 @@ sub sysread_or_die {
elsif($result == 0) { elsif($result == 0) {
($fcaller, $lcaller) = (caller)[1,2]; ($fcaller, $lcaller) = (caller)[1,2];
logmsg "Failed to read input\n"; logmsg "Failed to read input\n";
logmsg "Error: ftp$ftpdnum$ext read zero\n"; logmsg "Error: $srvrname server, read zero\n";
kill(9, $sfpid); kill(9, $sfpid);
waitpid($sfpid, 0); waitpid($sfpid, 0);
logmsg "Exited from sysread_or_die() at $fcaller " . logmsg "Exited from sysread_or_die() at $fcaller " .
"line $lcaller. ftp$ftpdnum$ext read zero\n"; "line $lcaller. $srvrname server, read zero\n";
unlink($pidfile); unlink($pidfile);
if($serverlogslocked) { if($serverlogslocked) {
$serverlogslocked = 0; $serverlogslocked = 0;
@@ -239,17 +244,20 @@ sub sysread_or_die {
} }
sub startsf { sub startsf {
my $cmd="./server/sockfilt --port $port --logfile log/sockctrl$ftpdnum$ext.log --pidfile .sockfilt$ftpdnum$ext.pid $ipv6"; my $mainsockfcmd = "./server/sockfilt " .
$sfpid = open2(*SFREAD, *SFWRITE, $cmd); "--ipv$ipvnum --port $port " .
"--pidfile \"$mainsockf_pidfile\" " .
"--logfile \"$mainsockf_logfile\"";
$sfpid = open2(*SFREAD, *SFWRITE, $mainsockfcmd);
print STDERR "$cmd\n" if($verbose); print STDERR "$mainsockfcmd\n" if($verbose);
print SFWRITE "PING\n"; print SFWRITE "PING\n";
my $pong; my $pong;
sysread SFREAD, $pong, 5; sysread SFREAD, $pong, 5;
if($pong !~ /^PONG/) { if($pong !~ /^PONG/) {
logmsg "Failed sockfilt command: $cmd\n"; logmsg "Failed sockfilt command: $mainsockfcmd\n";
kill(9, $sfpid); kill(9, $sfpid);
waitpid($sfpid, 0); waitpid($sfpid, 0);
unlink($pidfile); unlink($pidfile);
@@ -922,9 +930,8 @@ sub STOR_ftp {
sub PASV_ftp { sub PASV_ftp {
my ($arg, $cmd)=@_; my ($arg, $cmd)=@_;
my $pasvport; my $pasvport;
my $pidf=".sockdata$ftpdnum$ext.pid";
my $prev = processexists($pidf); my $prev = processexists($datasockf_pidfile);
if($prev > 0) { if($prev > 0) {
print "kill existing server: $prev\n" if($verbose); print "kill existing server: $prev\n" if($verbose);
kill(9, $prev); kill(9, $prev);
@@ -932,8 +939,11 @@ sub PASV_ftp {
} }
# We fire up a new sockfilt to do the data transfer for us. # We fire up a new sockfilt to do the data transfer for us.
$slavepid = open2(\*DREAD, \*DWRITE, my $datasockfcmd = "./server/sockfilt " .
"./server/sockfilt --port 0 --logfile log/sockdata$ftpdnum$ext.log --pidfile $pidf $ipv6"); "--ipv$ipvnum --port 0 " .
"--pidfile \"$datasockf_pidfile\" " .
"--logfile \"$datasockf_logfile\"";
$slavepid = open2(\*DREAD, \*DWRITE, $datasockfcmd);
print DWRITE "PING\n"; print DWRITE "PING\n";
my $pong; my $pong;
@@ -1067,11 +1077,13 @@ sub PORT_ftp {
} }
# We fire up a new sockfilt to do the data transfer for us. # We fire up a new sockfilt to do the data transfer for us.
# FIX: make it use IPv6 if need be my $datasockfcmd = "./server/sockfilt " .
my $filtcmd="./server/sockfilt --connect $port --addr $addr --logfile log/sockdata$ftpdnum$ext.log --pidfile .sockdata$ftpdnum$ext.pid $ipv6"; "--ipv$ipvnum --connect $port --addr \"$addr\" " .
$slavepid = open2(\*DREAD, \*DWRITE, $filtcmd); "--pidfile \"$datasockf_pidfile\" " .
"--logfile \"$datasockf_logfile\"";
$slavepid = open2(\*DREAD, \*DWRITE, $datasockfcmd);
print STDERR "$filtcmd\n" if($verbose); print STDERR "$datasockfcmd\n" if($verbose);
print DWRITE "PING\n"; print DWRITE "PING\n";
my $pong; my $pong;
@@ -1163,74 +1175,118 @@ sub customize {
# #
# Options: # Options:
# #
# -v # verbose # --verbose # verbose
# -s # source directory # --srcdir # source directory
# --id # server instance number # --id # server instance number
# --proto # server protocol # --proto # server protocol
# --pidfile # server pid file # --pidfile # server pid file
# --logfile # server log file
# --ipv4 # server IP version 4
# --ipv6 # server IP version 6 # --ipv6 # server IP version 6
# --port # server listener port # --port # server listener port
# --addr # server address for listener port binding # --addr # server address for listener port binding
# #
while(@ARGV) { while(@ARGV) {
if($ARGV[0] eq '-v') { if($ARGV[0] eq '--verbose') {
$verbose = 1; $verbose = 1;
} }
elsif($ARGV[0] eq '-s') { elsif($ARGV[0] eq '--srcdir') {
$srcdir = $ARGV[1]; if($ARGV[1]) {
shift @ARGV; $srcdir = $ARGV[1];
shift @ARGV;
}
} }
elsif($ARGV[0] eq '--id') { elsif($ARGV[0] eq '--id') {
if($ARGV[1] =~ /^(\d+)$/) { if($ARGV[1] && ($ARGV[1] =~ /^(\d+)$/)) {
$ftpdnum = $1 if($1 > 0); $idnum = $1 if($1 > 0);
shift @ARGV;
} }
shift @ARGV;
} }
elsif($ARGV[0] eq '--proto') { elsif($ARGV[0] eq '--proto') {
if($ARGV[1] =~ /^(ftp|imap|pop3|smtp)$/) { if($ARGV[1] && ($ARGV[1] =~ /^(ftp|imap|pop3|smtp)$/)) {
$proto = $1; $proto = $1;
shift @ARGV;
} }
else { else {
die "unsupported protocol $ARGV[1]"; die "unsupported protocol $ARGV[1]";
} }
shift @ARGV;
} }
elsif($ARGV[0] eq '--pidfile') { elsif($ARGV[0] eq '--pidfile') {
$pidfile = $ARGV[1]; if($ARGV[1]) {
shift @ARGV; $pidfile = $ARGV[1];
shift @ARGV;
}
}
elsif($ARGV[0] eq '--logfile') {
if($ARGV[1]) {
$logfile = $ARGV[1];
shift @ARGV;
}
}
elsif($ARGV[0] eq '--ipv4') {
$ipvnum = 4;
$listenaddr = '127.0.0.1' if($listenaddr eq '::1');
$grok_eprt = 0;
} }
elsif($ARGV[0] eq '--ipv6') { elsif($ARGV[0] eq '--ipv6') {
$ipvnum = 6; $ipvnum = 6;
$listenaddr = '::1' if($listenaddr eq '127.0.0.1'); $listenaddr = '::1' if($listenaddr eq '127.0.0.1');
$ipv6 = '--ipv6';
$ext = 'ipv6';
$grok_eprt = 1; $grok_eprt = 1;
} }
elsif($ARGV[0] eq '--port') { elsif($ARGV[0] eq '--port') {
if($ARGV[1] =~ /^(\d+)$/) { if($ARGV[1] && ($ARGV[1] =~ /^(\d+)$/)) {
$port = $1 if($1 > 1024); $port = $1 if($1 > 1024);
shift @ARGV;
} }
shift @ARGV;
} }
elsif($ARGV[0] eq '--addr') { elsif($ARGV[0] eq '--addr') {
my $tmpstr = $ARGV[1]; if($ARGV[1]) {
if($tmpstr =~ /^(\d\d?\d?)\.(\d\d?\d?)\.(\d\d?\d?)\.(\d\d?\d?)$/) { my $tmpstr = $ARGV[1];
$listenaddr = "$1.$2.$3.$4" if($ipvnum == 4); if($tmpstr =~ /^(\d\d?\d?)\.(\d\d?\d?)\.(\d\d?\d?)\.(\d\d?\d?)$/) {
$listenaddr = "$1.$2.$3.$4" if($ipvnum == 4);
}
elsif($ipvnum == 6) {
$listenaddr = $tmpstr;
$listenaddr =~ s/^\[(.*)\]$/$1/;
}
shift @ARGV;
} }
elsif($ipvnum == 6) { }
$listenaddr = $tmpstr; else {
$listenaddr =~ s/^\[(.*)\]$/$1/; print STDERR "\nWarning: ftpserver.pl unknown parameter: $ARGV[0]\n";
}
shift @ARGV;
} }
shift @ARGV; shift @ARGV;
}; }
#*************************************************************************** #***************************************************************************
# Initialize command line option dependant variables # Initialize command line option dependant variables
# #
$logfilename = getlogfilename(); if(!$srcdir) {
$srcdir = $ENV{'srcdir'} || '.';
}
if(!$pidfile) {
$pidfile = "$path/". server_pidfilename($proto, $ipvnum, $idnum);
}
if(!$logfile) {
$logfile = server_logfilename($logdir, $proto, $ipvnum, $idnum);
}
$mainsockf_pidfile = "$path/".
mainsockf_pidfilename($proto, $ipvnum, $idnum);
$mainsockf_logfile =
mainsockf_logfilename($logdir, $proto, $ipvnum, $idnum);
if($proto eq 'ftp') {
$datasockf_pidfile = "$path/".
datasockf_pidfilename($proto, $ipvnum, $idnum);
$datasockf_logfile =
datasockf_logfilename($logdir, $proto, $ipvnum, $idnum);
}
$srvrname = servername_str($proto, $ipvnum, $idnum);
$idstr = "$idnum" if($idnum > 1);
protocolsetup($proto); protocolsetup($proto);
@@ -1239,8 +1295,8 @@ $SIG{TERM} = \&exit_signal_handler;
startsf(); startsf();
logmsg sprintf("%s server listens on port IPv%d/$port\n", uc($proto), logmsg sprintf("%s server listens on port IPv${ipvnum}/${port}\n", uc($proto));
$ipv6?6:4);
open(PID, ">$pidfile"); open(PID, ">$pidfile");
print PID $$."\n"; print PID $$."\n";
close(PID); close(PID);

View File

@@ -122,8 +122,11 @@ my $TFTP6PORT; # TFTP
my $SSHPORT; # SCP/SFTP my $SSHPORT; # SCP/SFTP
my $SOCKSPORT; # SOCKS4/5 port my $SOCKSPORT; # SOCKS4/5 port
my $POP3PORT; # POP3 my $POP3PORT; # POP3
my $POP36PORT; # POP3 IPv6 server port
my $IMAPPORT; # IMAP my $IMAPPORT; # IMAP
my $IMAP6PORT; # IMAP IPv6 server port
my $SMTPPORT; # SMTP my $SMTPPORT; # SMTP
my $SMTP6PORT; # SMTP IPv6 server port
my $srcdir = $ENV{'srcdir'} || '.'; my $srcdir = $ENV{'srcdir'} || '.';
my $CURL="../src/curl"; # what curl executable to run on the tests my $CURL="../src/curl"; # what curl executable to run on the tests
@@ -957,75 +960,67 @@ sub runhttpsserver {
# #
sub runpingpongserver { sub runpingpongserver {
my ($proto, $id, $verbose, $ipv6) = @_; my ($proto, $id, $verbose, $ipv6) = @_;
my $STATUS;
my $RUNNING;
my $port; my $port;
my $pidfile; my $ip = $HOSTIP;
my $ip=$HOSTIP;
my $cmd;
my $flag;
my $ipvnum = 4; my $ipvnum = 4;
my $idnum = ($id && ($id =~ /^(\d+)$/) && ($id > 1)) ? $id : 1; my $idnum = ($id && ($id =~ /^(\d+)$/) && ($id > 1)) ? $id : 1;
my $srvrname; my $srvrname;
my $pidfile;
my $logfile;
my $flags = "";
if($proto eq "ftp") { if($proto eq "ftp") {
$port = ($idnum>1)?$FTP2PORT:$FTPPORT; $port = ($idnum>1)?$FTP2PORT:$FTPPORT;
$pidfile = ($idnum>1)?$FTP2PIDFILE:$FTPPIDFILE;
if($ipv6) { if($ipv6) {
# if IPv6, use a different setup # if IPv6, use a different setup
$ipvnum = 6;
$pidfile = $FTP6PIDFILE;
$port = $FTP6PORT; $port = $FTP6PORT;
$ip = $HOST6IP;
} }
} }
elsif($proto eq "pop3") { elsif($proto eq "pop3") {
$port = $POP3PORT; $port = ($ipv6) ? $POP36PORT : $POP3PORT;
$pidfile = $POP3PIDFILE;
} }
elsif($proto eq "imap") { elsif($proto eq "imap") {
$port = $IMAPPORT; $port = ($ipv6) ? $IMAP6PORT : $IMAPPORT;
$pidfile = $IMAPPIDFILE;
} }
elsif($proto eq "smtp") { elsif($proto eq "smtp") {
$port = $SMTPPORT; $port = ($ipv6) ? $SMTP6PORT : $SMTPPORT;
$pidfile = $SMTPPIDFILE;
} }
else { else {
print STDERR "Unsupported protocol $proto!!\n"; print STDERR "Unsupported protocol $proto!!\n";
return 0; return 0;
} }
$flag .= "--proto $proto ";
if($ipv6) {
# if IPv6, use a different setup
$ipvnum = 6;
$ip = $HOST6IP;
}
$pidfile = server_pidfilename($proto, $ipvnum, $idnum);
# don't retry if the server doesn't work # don't retry if the server doesn't work
if ($doesntrun{$pidfile}) { if ($doesntrun{$pidfile}) {
return (0,0); return (0,0);
} }
$srvrname = servername_str($proto, $ipvnum, $idnum);
my $pid = processexists($pidfile); my $pid = processexists($pidfile);
if($pid > 0) { if($pid > 0) {
stopserver($pid); stopserver($pid);
} }
unlink($pidfile); unlink($pidfile);
# start our server: $srvrname = servername_str($proto, $ipvnum, $idnum);
$flag .= $debugprotocol?"-v ":"";
$flag .= "-s \"$srcdir\" ";
my $addr;
if($idnum > 1) {
$flag .="--id $idnum ";
}
if($ipv6) {
$flag .="--ipv6 ";
$addr = $HOST6IP;
} else {
$addr = $HOSTIP;
}
$cmd="$perl $srcdir/ftpserver.pl --pidfile $pidfile $flag --port $port --addr \"$addr\""; $logfile = server_logfilename($LOGDIR, $proto, $ipvnum, $idnum);
$flags .= "--verbose " if($debugprotocol);
$flags .= "--pidfile \"$pidfile\" --logfile \"$logfile\" ";
$flags .= "--srcdir \"$srcdir\" --proto $proto ";
$flags .= "--id $idnum " if($idnum > 1);
$flags .= "--ipv$ipvnum --port $port --addr \"$ip\"";
my $cmd = "$perl $srcdir/ftpserver.pl $flags";
my ($ftppid, $pid2) = startnew($cmd, $pidfile, 15, 0); my ($ftppid, $pid2) = startnew($cmd, $pidfile, 15, 0);
if($ftppid <= 0 || !kill(0, $ftppid)) { if($ftppid <= 0 || !kill(0, $ftppid)) {
@@ -1754,6 +1749,11 @@ sub checksystem {
logmsg sprintf("POP3/%d ", $POP3PORT); logmsg sprintf("POP3/%d ", $POP3PORT);
logmsg sprintf("IMAP/%d ", $IMAPPORT); logmsg sprintf("IMAP/%d ", $IMAPPORT);
logmsg sprintf("SMTP/%d\n", $SMTPPORT); logmsg sprintf("SMTP/%d\n", $SMTPPORT);
if($tftp_ipv6) {
logmsg sprintf("POP3-IPv6/%d ", $POP36PORT);
logmsg sprintf("IMAP-IPv6/%d ", $IMAP6PORT);
logmsg sprintf("SMTP-IPv6/%d ", $SMTP6PORT);
}
$has_textaware = ($^O eq 'MSWin32') || ($^O eq 'msys'); $has_textaware = ($^O eq 'MSWin32') || ($^O eq 'msys');
@@ -1783,8 +1783,11 @@ sub subVariables {
$$thing =~ s/%SSHPORT/$SSHPORT/g; $$thing =~ s/%SSHPORT/$SSHPORT/g;
$$thing =~ s/%SOCKSPORT/$SOCKSPORT/g; $$thing =~ s/%SOCKSPORT/$SOCKSPORT/g;
$$thing =~ s/%POP3PORT/$POP3PORT/g; $$thing =~ s/%POP3PORT/$POP3PORT/g;
$$thing =~ s/%POP36PORT/$POP36PORT/g;
$$thing =~ s/%IMAPPORT/$IMAPPORT/g; $$thing =~ s/%IMAPPORT/$IMAPPORT/g;
$$thing =~ s/%IMAP6PORT/$IMAP6PORT/g;
$$thing =~ s/%SMTPPORT/$SMTPPORT/g; $$thing =~ s/%SMTPPORT/$SMTPPORT/g;
$$thing =~ s/%SMTP6PORT/$SMTP6PORT/g;
$$thing =~ s/%CURL/$CURL/g; $$thing =~ s/%CURL/$CURL/g;
$$thing =~ s/%USER/$USER/g; $$thing =~ s/%USER/$USER/g;
$$thing =~ s/%CLIENTIP/$CLIENTIP/g; $$thing =~ s/%CLIENTIP/$CLIENTIP/g;
@@ -2329,10 +2332,11 @@ sub singletest {
my @killservers = getpart("client", "killserver"); my @killservers = getpart("client", "killserver");
foreach my $serv (@killservers) { foreach my $serv (@killservers) {
chomp $serv; chomp $serv;
if($serv =~ /^ftp(\d*)(-ipv6|)/) { if($serv =~ /^(ftp|imap|pop3|smtp)(\d*)(-ipv6|)/) {
my ($id, $ext) = ($1, $2); my $proto = $1;
#print STDERR "SERV $serv $id $ext\n"; my $idnum = ($2 && ($2 > 1)) ? $2 : 1;
ftpkillslave($id, $ext, $verbose); my $ipvnum = ($3 && ($3 =~ /6$/)) ? 6 : 4;
killsockfilters($proto, $ipvnum, $idnum, $verbose);
} }
if($run{$serv}) { if($run{$serv}) {
stopserver($run{$serv}); # the pid file is in the hash table stopserver($run{$serv}); # the pid file is in the hash table
@@ -2677,7 +2681,7 @@ sub singletest {
####################################################################### #######################################################################
# Stop all running test servers # Stop all running test servers
sub stopservers { sub stopservers {
my ($verbose)=@_; my $verbose = $_[0];
my $pidlist; my $pidlist;
for(keys %run) { for(keys %run) {
@@ -2698,7 +2702,7 @@ sub stopservers {
delete $run{$server}; delete $run{$server};
} }
killpid($verbose, $pidlist); killpid($verbose, $pidlist);
ftpkillslaves($verbose); killallsockfilters($verbose);
} }
####################################################################### #######################################################################
@@ -3285,8 +3289,11 @@ $TFTP6PORT = $base++; # TFTP IPv6 (UDP) port
$SSHPORT = $base++; # SSH (SCP/SFTP) port $SSHPORT = $base++; # SSH (SCP/SFTP) port
$SOCKSPORT = $base++; # SOCKS port $SOCKSPORT = $base++; # SOCKS port
$POP3PORT = $base++; $POP3PORT = $base++;
$POP36PORT = $base++;
$IMAPPORT = $base++; $IMAPPORT = $base++;
$IMAP6PORT = $base++;
$SMTPPORT = $base++; $SMTPPORT = $base++;
$SMTP6PORT = $base++;
####################################################################### #######################################################################
# clear and create logging directory: # clear and create logging directory: