mirror of
https://github.com/curl/curl.git
synced 2026-08-26 18:43:32 +03:00
introducing IMAP, POP3 and SMTP support (still lots of polish left to do)
This commit is contained in:
parent
463d2d395c
commit
ec3bb8f727
23 changed files with 4531 additions and 753 deletions
|
|
@ -63,7 +63,7 @@ EXTRA_DIST = test1 test108 test117 test127 test20 test27 test34 test46 \
|
|||
test1089 test1090 test1091 test1092 test1093 test1094 test1095 test1096 \
|
||||
test1097 test560 test561 test1098 test1099 test562 test563 test1100 \
|
||||
test564 test1101 test1102 test1103 test1104 test299 test310 test311 \
|
||||
test312 test1105 test565
|
||||
test312 test1105 test565 test800
|
||||
|
||||
filecheck:
|
||||
@mkdir test-place; \
|
||||
|
|
|
|||
47
tests/data/test800
Normal file
47
tests/data/test800
Normal file
|
|
@ -0,0 +1,47 @@
|
|||
<testcase>
|
||||
<info>
|
||||
<keywords>
|
||||
POP3
|
||||
RETR
|
||||
</keywords>
|
||||
</info>
|
||||
|
||||
#
|
||||
# Server-side
|
||||
<reply>
|
||||
<data>
|
||||
From: me@somewhere
|
||||
To: fake@nowhere
|
||||
|
||||
body
|
||||
|
||||
--
|
||||
yours sincerely
|
||||
</data>
|
||||
</reply>
|
||||
|
||||
#
|
||||
# Client-side
|
||||
<client>
|
||||
<server>
|
||||
pop3
|
||||
</server>
|
||||
<name>
|
||||
POP3 RETR
|
||||
</name>
|
||||
<command>
|
||||
pop3://%HOSTIP:%POP3PORT/800 -u user:secret
|
||||
</command>
|
||||
</client>
|
||||
|
||||
#
|
||||
# Verify data after the test has been "shot"
|
||||
<verify>
|
||||
<protocol>
|
||||
USER user
|
||||
PASS secret
|
||||
RETR 800
|
||||
QUIT
|
||||
</protocol>
|
||||
</verify>
|
||||
</testcase>
|
||||
|
|
@ -22,7 +22,11 @@
|
|||
# $Id$
|
||||
###########################################################################
|
||||
|
||||
# This is the FTP server designed for the curl test suite.
|
||||
# This is a server designed for the curl test suite.
|
||||
#
|
||||
# In December 2009 we started remaking the server to support more protocols
|
||||
# that are similar in spirit. Like POP3, IMAP and SMTP in addition to the
|
||||
# FTP it already supported since a long time.
|
||||
#
|
||||
# It is meant to exercise curl, it is not meant to be a fully working
|
||||
# or even very standard compliant server.
|
||||
|
|
@ -88,6 +92,8 @@ my $pidfile = ".ftpd.pid"; # a default, use --pidfile
|
|||
my $SERVERLOGS_LOCK="log/serverlogs.lock"; # server logs advisor read lock
|
||||
my $serverlogslocked=0;
|
||||
|
||||
my $proto="ftp";
|
||||
|
||||
do {
|
||||
if($ARGV[0] eq "-v") {
|
||||
$verbose=1;
|
||||
|
|
@ -100,6 +106,11 @@ do {
|
|||
$ftpdnum=$ARGV[1];
|
||||
shift @ARGV;
|
||||
}
|
||||
elsif($ARGV[0] eq "--proto") {
|
||||
# ftp pop3 imap smtp
|
||||
$proto=$ARGV[1];
|
||||
shift @ARGV;
|
||||
}
|
||||
elsif($ARGV[0] eq "--pidfile") {
|
||||
$pidfile=$ARGV[1];
|
||||
shift @ARGV;
|
||||
|
|
@ -115,23 +126,28 @@ do {
|
|||
}
|
||||
elsif($ARGV[0] eq "--addr") {
|
||||
$listenaddr = $ARGV[1];
|
||||
$listenaddr =~ s/^\[(.*)\]$/\1/;
|
||||
$listenaddr =~ s/^\[(.*)\]$/$1/;
|
||||
shift @ARGV;
|
||||
}
|
||||
} while(shift @ARGV);
|
||||
|
||||
# a dedicated protocol has been selected, check that it's a fine one
|
||||
if($proto !~ /^(ftp|imap|pop3|smtp)\z/) {
|
||||
die "unsupported protocol selected";
|
||||
}
|
||||
|
||||
sub catch_zap {
|
||||
my $signame = shift;
|
||||
print STDERR "ftpserver.pl received SIG$signame, exiting\n";
|
||||
ftpkillslaves(1);
|
||||
unlink($pidfile);
|
||||
if($serverlogslocked) {
|
||||
$serverlogslocked = 0;
|
||||
clear_advisor_read_lock($SERVERLOGS_LOCK);
|
||||
}
|
||||
exit;
|
||||
die "Somebody sent me a SIG$signame";
|
||||
}
|
||||
$SIG{INT} = \&catch_zap;
|
||||
$SIG{TERM} = \&catch_zap;
|
||||
$SIG{KILL} = \&catch_zap;
|
||||
|
||||
my $sfpid;
|
||||
|
||||
|
|
@ -153,7 +169,6 @@ sub sysread_or_die {
|
|||
logmsg "Error: ftp$ftpdnum$ext sysread error: $!\n";
|
||||
kill(9, $sfpid);
|
||||
waitpid($sfpid, 0);
|
||||
unlink($pidfile);
|
||||
if($serverlogslocked) {
|
||||
$serverlogslocked = 0;
|
||||
clear_advisor_read_lock($SERVERLOGS_LOCK);
|
||||
|
|
@ -167,7 +182,6 @@ sub sysread_or_die {
|
|||
logmsg "Error: ftp$ftpdnum$ext read zero\n";
|
||||
kill(9, $sfpid);
|
||||
waitpid($sfpid, 0);
|
||||
unlink($pidfile);
|
||||
if($serverlogslocked) {
|
||||
$serverlogslocked = 0;
|
||||
clear_advisor_read_lock($SERVERLOGS_LOCK);
|
||||
|
|
@ -193,7 +207,6 @@ sub startsf {
|
|||
logmsg "Failed sockfilt command: $cmd\n";
|
||||
kill(9, $sfpid);
|
||||
waitpid($sfpid, 0);
|
||||
unlink($pidfile);
|
||||
if($serverlogslocked) {
|
||||
$serverlogslocked = 0;
|
||||
clear_advisor_read_lock($SERVERLOGS_LOCK);
|
||||
|
|
@ -202,9 +215,13 @@ sub startsf {
|
|||
}
|
||||
}
|
||||
|
||||
# remove the file here so that if startsf() fails, it is very noticeable
|
||||
unlink($pidfile);
|
||||
|
||||
startsf();
|
||||
|
||||
logmsg sprintf("FTP server listens on port IPv%d/$port\n", $ipv6?6:4);
|
||||
logmsg sprintf("%s server listens on port IPv%d/$port\n", uc($proto),
|
||||
$ipv6?6:4);
|
||||
open(PID, ">$pidfile");
|
||||
print PID $$."\n";
|
||||
close(PID);
|
||||
|
|
@ -273,41 +290,66 @@ sub senddata {
|
|||
}
|
||||
}
|
||||
|
||||
# this text is shown before the function specified below is run
|
||||
my %displaytext = ('USER' => '331 We are happy you popped in!',
|
||||
'PASS' => '230 Welcome you silly person',
|
||||
'PORT' => '200 You said PORT - I say FINE',
|
||||
'TYPE' => '200 I modify TYPE as you wanted',
|
||||
'LIST' => '150 here comes a directory',
|
||||
'NLST' => '150 here comes a directory',
|
||||
'CWD' => '250 CWD command successful.',
|
||||
'SYST' => '215 UNIX Type: L8', # just fake something
|
||||
'QUIT' => '221 bye bye baby', # just reply something
|
||||
'PWD' => '257 "/nowhere/anywhere" is current directory',
|
||||
'MKD' => '257 Created your requested directory',
|
||||
'REST' => '350 Yeah yeah we set it there for you',
|
||||
'DELE' => '200 OK OK OK whatever you say',
|
||||
'RNFR' => '350 Received your order. Please provide more',
|
||||
'RNTO' => '250 Ok, thanks. File renaming completed.',
|
||||
'NOOP' => '200 Yes, I\'m very good at doing nothing.',
|
||||
'PBSZ' => '500 PBSZ not implemented',
|
||||
'PROT' => '500 PROT not implemented',
|
||||
);
|
||||
my %displaytext;
|
||||
my %commandfunc;
|
||||
|
||||
# callback functions for certain commands
|
||||
my %commandfunc = ( 'PORT' => \&PORT_command,
|
||||
'EPRT' => \&PORT_command,
|
||||
'LIST' => \&LIST_command,
|
||||
'NLST' => \&NLST_command,
|
||||
'PASV' => \&PASV_command,
|
||||
'EPSV' => \&PASV_command,
|
||||
'RETR' => \&RETR_command,
|
||||
'SIZE' => \&SIZE_command,
|
||||
'REST' => \&REST_command,
|
||||
'STOR' => \&STOR_command,
|
||||
'APPE' => \&STOR_command, # append looks like upload
|
||||
'MDTM' => \&MDTM_command,
|
||||
);
|
||||
# and text shown before the function specified below is run
|
||||
|
||||
if($proto eq "ftp") {
|
||||
%displaytext = ('USER' => '331 We are happy you popped in!',
|
||||
'PASS' => '230 Welcome you silly person',
|
||||
'PORT' => '200 You said PORT - I say FINE',
|
||||
'TYPE' => '200 I modify TYPE as you wanted',
|
||||
'LIST' => '150 here comes a directory',
|
||||
'NLST' => '150 here comes a directory',
|
||||
'CWD' => '250 CWD command successful.',
|
||||
'SYST' => '215 UNIX Type: L8', # just fake something
|
||||
'QUIT' => '221 bye bye baby', # just reply something
|
||||
'PWD' => '257 "/nowhere/anywhere" is current directory',
|
||||
'MKD' => '257 Created your requested directory',
|
||||
'REST' => '350 Yeah yeah we set it there for you',
|
||||
'DELE' => '200 OK OK OK whatever you say',
|
||||
'RNFR' => '350 Received your order. Please provide more',
|
||||
'RNTO' => '250 Ok, thanks. File renaming completed.',
|
||||
'NOOP' => '200 Yes, I\'m very good at doing nothing.',
|
||||
'PBSZ' => '500 PBSZ not implemented',
|
||||
'PROT' => '500 PROT not implemented',
|
||||
);
|
||||
|
||||
%commandfunc = ( 'PORT' => \&PORT_command,
|
||||
'EPRT' => \&PORT_command,
|
||||
'LIST' => \&LIST_command,
|
||||
'NLST' => \&NLST_command,
|
||||
'PASV' => \&PASV_command,
|
||||
'EPSV' => \&PASV_command,
|
||||
'RETR' => \&RETR_command,
|
||||
'SIZE' => \&SIZE_command,
|
||||
'REST' => \&REST_command,
|
||||
'STOR' => \&STOR_command,
|
||||
'APPE' => \&STOR_command, # append looks like upload
|
||||
'MDTM' => \&MDTM_command,
|
||||
);
|
||||
}
|
||||
elsif($proto eq "pop3") {
|
||||
%commandfunc = ('RETR' => \&RETR_pop3,
|
||||
);
|
||||
|
||||
%displaytext = ('USER' => '+OK We are happy you popped in!',
|
||||
'PASS' => '+OK Access granted',
|
||||
'QUIT' => '+OK byebye',
|
||||
);
|
||||
|
||||
}
|
||||
elsif($proto eq "imap") {
|
||||
%commandfunc = ('FETCH' => \&FETCH_imap,
|
||||
);
|
||||
|
||||
%displaytext = ('LOGIN' => ' OK We are happy you popped in!',
|
||||
'SELECT' => ' OK selection done',
|
||||
);
|
||||
|
||||
}
|
||||
|
||||
|
||||
sub close_dataconn {
|
||||
|
|
@ -330,6 +372,98 @@ sub close_dataconn {
|
|||
$slavepid=0;
|
||||
}
|
||||
|
||||
################
|
||||
################ IMAP commands
|
||||
################
|
||||
|
||||
sub FETCH_imap {
|
||||
my ($testno) = @_;
|
||||
my @data;
|
||||
|
||||
if($testno =~ /^verifiedserver$/) {
|
||||
# this is the secret command that verifies that this actually is
|
||||
# the curl test server
|
||||
my $response = "WE ROOLZ: $$\r\n";
|
||||
if($verbose) {
|
||||
print STDERR "FTPD: We returned proof we are the test server\n";
|
||||
}
|
||||
$data[0] = $response;
|
||||
logmsg "return proof we are we\n";
|
||||
}
|
||||
else {
|
||||
logmsg "retrieve a mail\n";
|
||||
|
||||
$testno =~ s/^([^0-9]*)//;
|
||||
my $testpart = "";
|
||||
if ($testno > 10000) {
|
||||
$testpart = $testno % 10000;
|
||||
$testno = int($testno / 10000);
|
||||
}
|
||||
|
||||
# send mail content
|
||||
loadtest("$srcdir/data/test$testno");
|
||||
|
||||
@data = getpart("reply", "data$testpart");
|
||||
}
|
||||
|
||||
sendcontrol "- OK Mail transfer starts\r\n";
|
||||
|
||||
for my $d (@data) {
|
||||
sendcontrol $d;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
################
|
||||
################ POP3 commands
|
||||
################
|
||||
|
||||
sub RETR_pop3 {
|
||||
my ($testno) = @_;
|
||||
my @data;
|
||||
|
||||
if($testno =~ /^verifiedserver$/) {
|
||||
# this is the secret command that verifies that this actually is
|
||||
# the curl test server
|
||||
my $response = "WE ROOLZ: $$\r\n";
|
||||
if($verbose) {
|
||||
print STDERR "FTPD: We returned proof we are the test server\n";
|
||||
}
|
||||
$data[0] = $response;
|
||||
logmsg "return proof we are we\n";
|
||||
}
|
||||
else {
|
||||
logmsg "retrieve a mail\n";
|
||||
|
||||
$testno =~ s/^([^0-9]*)//;
|
||||
my $testpart = "";
|
||||
if ($testno > 10000) {
|
||||
$testpart = $testno % 10000;
|
||||
$testno = int($testno / 10000);
|
||||
}
|
||||
|
||||
# send mail content
|
||||
loadtest("$srcdir/data/test$testno");
|
||||
|
||||
@data = getpart("reply", "data$testpart");
|
||||
}
|
||||
|
||||
sendcontrol "+OK Mail transfer starts\r\n";
|
||||
|
||||
for my $d (@data) {
|
||||
sendcontrol $d;
|
||||
}
|
||||
|
||||
# end with the magic 5-byte end of mail marker
|
||||
sendcontrol "\r\n.\r\n";
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
################
|
||||
################ FTP commands
|
||||
################
|
||||
my $rest=0;
|
||||
sub REST_command {
|
||||
$rest = $_[0];
|
||||
|
|
@ -798,12 +932,34 @@ sub customize {
|
|||
close(CUSTOM);
|
||||
}
|
||||
|
||||
my @welcome=(
|
||||
'220- _ _ ____ _ '."\r\n",
|
||||
'220- ___| | | | _ \| | '."\r\n",
|
||||
'220- / __| | | | |_) | | '."\r\n",
|
||||
'220- | (__| |_| | _ <| |___ '."\r\n",
|
||||
'220 \___|\___/|_| \_\_____|'."\r\n");
|
||||
my @welcome;
|
||||
|
||||
if($proto eq "ftp") {
|
||||
@welcome=(
|
||||
'220- _ _ ____ _ '."\r\n",
|
||||
'220- ___| | | | _ \| | '."\r\n",
|
||||
'220- / __| | | | |_) | | '."\r\n",
|
||||
'220- | (__| |_| | _ <| |___ '."\r\n",
|
||||
'220 \___|\___/|_| \_\_____|'."\r\n");
|
||||
}
|
||||
elsif($proto eq "pop3") {
|
||||
@welcome=(
|
||||
' _ _ ____ _ '."\r\n",
|
||||
' ___| | | | _ \| | '."\r\n",
|
||||
' / __| | | | |_) | | '."\r\n",
|
||||
' | (__| |_| | _ <| |___ '."\r\n",
|
||||
' \___|\___/|_| \_\_____|'."\r\n",
|
||||
'+OK cURL POP3 server ready to serve'."\r\n");
|
||||
}
|
||||
elsif($proto eq "imap") {
|
||||
@welcome=(
|
||||
' _ _ ____ _ '."\r\n",
|
||||
' ___| | | | _ \| | '."\r\n",
|
||||
' / __| | | | |_) | | '."\r\n",
|
||||
' | (__| |_| | _ <| |___ '."\r\n",
|
||||
' \___|\___/|_| \_\_____|'."\r\n",
|
||||
'* OK cURL IMAP server ready to serve'."\r\n");
|
||||
}
|
||||
|
||||
|
||||
while(1) {
|
||||
|
|
@ -872,13 +1028,28 @@ while(1) {
|
|||
# Remove trailing CRLF.
|
||||
s/[\n\r]+$//;
|
||||
|
||||
unless (m/^([A-Z]{3,4})\s?(.*)/i) {
|
||||
sendcontrol "500 '$_': command not understood.\r\n";
|
||||
last;
|
||||
}
|
||||
my $FTPCMD=$1;
|
||||
my $FTPARG=$2;
|
||||
my $cmdid;
|
||||
my $FTPCMD;
|
||||
my $FTPARG;
|
||||
my $full=$_;
|
||||
if($proto eq "imap") {
|
||||
# IMAP is different with its identifier first on the command line
|
||||
unless (m/^([^ ]+) ([^ ]+) (.*)/i) {
|
||||
sendcontrol "500 '$_': command not understood.\r\n";
|
||||
last;
|
||||
}
|
||||
$cmdid=$1;
|
||||
$FTPCMD=$2;
|
||||
$FTPARG=$3;
|
||||
}
|
||||
else {
|
||||
unless (m/^([A-Z]{3,4})\s?(.*)/i) {
|
||||
sendcontrol "500 '$_': command not understood.\r\n";
|
||||
last;
|
||||
}
|
||||
$FTPCMD=$1;
|
||||
$FTPARG=$2;
|
||||
}
|
||||
|
||||
logmsg "< \"$full\"\n";
|
||||
|
||||
|
|
@ -907,7 +1078,7 @@ while(1) {
|
|||
}
|
||||
my $check;
|
||||
if($text) {
|
||||
sendcontrol "$text\r\n";
|
||||
sendcontrol "$cmdid$text\r\n";
|
||||
}
|
||||
else {
|
||||
$check=1; # no response yet
|
||||
|
|
@ -939,8 +1110,6 @@ while(1) {
|
|||
print SFWRITE "QUIT\n";
|
||||
waitpid $sfpid, 0;
|
||||
|
||||
unlink($pidfile);
|
||||
|
||||
if($serverlogslocked) {
|
||||
$serverlogslocked = 0;
|
||||
clear_advisor_read_lock($SERVERLOGS_LOCK);
|
||||
|
|
|
|||
|
|
@ -109,6 +109,9 @@ my $TFTPPORT; # TFTP
|
|||
my $TFTP6PORT; # TFTP
|
||||
my $SSHPORT; # SCP/SFTP
|
||||
my $SOCKSPORT; # SOCKS4/5 port
|
||||
my $POP3PORT; # POP3
|
||||
my $IMAPPORT; # IMAP
|
||||
my $SMTPPORT; # SMTP
|
||||
|
||||
my $srcdir = $ENV{'srcdir'} || '.';
|
||||
my $CURL="../src/curl"; # what curl executable to run on the tests
|
||||
|
|
@ -147,6 +150,9 @@ my $TFTPPIDFILE=".tftpd.pid";
|
|||
my $TFTP6PIDFILE=".tftp6.pid";
|
||||
my $SSHPIDFILE=".ssh.pid";
|
||||
my $SOCKSPIDFILE=".socks.pid";
|
||||
my $POP3PIDFILE=".pop3.pid";
|
||||
my $IMAPPIDFILE=".imap.pid";
|
||||
my $SMTPPIDFILE=".smtp.pid";
|
||||
|
||||
# invoke perl like this:
|
||||
my $perl="perl -I$srcdir";
|
||||
|
|
@ -663,7 +669,7 @@ sub verifyftp {
|
|||
}
|
||||
if($pid <= 0 && $data[0]) {
|
||||
# this is not a known server
|
||||
logmsg "RUN: Unknown server on our FTP port: $port\n";
|
||||
logmsg "RUN: Unknown server on our $proto port: $port\n";
|
||||
return 0;
|
||||
}
|
||||
# we can/should use the time it took to verify the FTP server as a measure
|
||||
|
|
@ -671,7 +677,7 @@ sub verifyftp {
|
|||
my $took = time()-$time;
|
||||
|
||||
if($verbose) {
|
||||
logmsg "RUN: Verifying our test FTP server took $took seconds\n";
|
||||
logmsg "RUN: Verifying our test $proto server took $took seconds\n";
|
||||
}
|
||||
$ftpchecktime = $took?$took:1; # make sure it never is zero
|
||||
|
||||
|
|
@ -773,6 +779,9 @@ sub verifysocks {
|
|||
my %protofunc = ('http' => \&verifyhttp,
|
||||
'https' => \&verifyhttp,
|
||||
'ftp' => \&verifyftp,
|
||||
'pop3' => \&verifyftp,
|
||||
'imap' => \&verifyftp,
|
||||
'smtp' => \&verifyftp,
|
||||
'ftps' => \&verifyftp,
|
||||
'tftp' => \&verifyftp,
|
||||
'ssh' => \&verifyssh,
|
||||
|
|
@ -942,26 +951,48 @@ sub runhttpsserver {
|
|||
}
|
||||
|
||||
#######################################################################
|
||||
# start the ftp server
|
||||
# start the pingpong server (FTP, POP3, IMAP, SMTP)
|
||||
#
|
||||
sub runftpserver {
|
||||
my ($id, $verbose, $ipv6) = @_;
|
||||
sub runpingpongserver {
|
||||
my ($proto, $id, $verbose, $ipv6) = @_;
|
||||
my $STATUS;
|
||||
my $RUNNING;
|
||||
my $port = $id?$FTP2PORT:$FTPPORT;
|
||||
# check for pidfile
|
||||
my $pidfile = $id?$FTP2PIDFILE:$FTPPIDFILE;
|
||||
my $port;
|
||||
my $pidfile;
|
||||
my $ip=$HOSTIP;
|
||||
my $nameext;
|
||||
my $cmd;
|
||||
my $flag;
|
||||
|
||||
if($ipv6) {
|
||||
# if IPv6, use a different setup
|
||||
$pidfile = $FTP6PIDFILE;
|
||||
$port = $FTP6PORT;
|
||||
$ip = $HOST6IP;
|
||||
$nameext="-ipv6";
|
||||
if($proto eq "ftp") {
|
||||
$port = $id?$FTP2PORT:$FTPPORT;
|
||||
$pidfile = $id?$FTP2PIDFILE:$FTPPIDFILE;
|
||||
|
||||
if($ipv6) {
|
||||
# if IPv6, use a different setup
|
||||
$pidfile = $FTP6PIDFILE;
|
||||
$port = $FTP6PORT;
|
||||
$ip = $HOST6IP;
|
||||
$nameext="-ipv6";
|
||||
}
|
||||
}
|
||||
elsif($proto eq "pop3") {
|
||||
$port = $POP3PORT;
|
||||
$pidfile = $POP3PIDFILE;
|
||||
}
|
||||
elsif($proto eq "imap") {
|
||||
$port = $IMAPPORT;
|
||||
$pidfile = $IMAPPIDFILE;
|
||||
}
|
||||
elsif($proto eq "smtp") {
|
||||
$port = $SMTPPORT;
|
||||
$pidfile = $SMTPPIDFILE;
|
||||
}
|
||||
else {
|
||||
print STDERR "Unsupported protocol $proto!!\n";
|
||||
return 0;
|
||||
}
|
||||
$flag .= "--proto $proto ";
|
||||
|
||||
# don't retry if the server doesn't work
|
||||
if ($doesntrun{$pidfile}) {
|
||||
|
|
@ -975,7 +1006,7 @@ sub runftpserver {
|
|||
unlink($pidfile);
|
||||
|
||||
# start our server:
|
||||
my $flag=$debugprotocol?"-v ":"";
|
||||
$flag.=$debugprotocol?"-v ":"";
|
||||
$flag .= "-s \"$srcdir\" ";
|
||||
my $addr;
|
||||
if($id) {
|
||||
|
|
@ -993,7 +1024,7 @@ sub runftpserver {
|
|||
|
||||
if($ftppid <= 0 || !kill(0, $ftppid)) {
|
||||
# it is NOT alive
|
||||
logmsg "RUN: failed to start the FTP$id$nameext server\n";
|
||||
logmsg "RUN: failed to start the $proto$id$nameext server\n";
|
||||
stopserver("$pid2");
|
||||
displaylogs($testnumcheck);
|
||||
$doesntrun{$pidfile} = 1;
|
||||
|
|
@ -1001,9 +1032,9 @@ sub runftpserver {
|
|||
}
|
||||
|
||||
# Server is up. Verify that we can speak to it.
|
||||
my $pid3 = verifyserver("ftp", $ip, $port);
|
||||
my $pid3 = verifyserver($proto, $ip, $port);
|
||||
if(!$pid3) {
|
||||
logmsg "RUN: FTP$id$nameext server failed verification\n";
|
||||
logmsg "RUN: $proto$id$nameext server failed verification\n";
|
||||
# failed to talk to it properly. Kill the server and return failure
|
||||
stopserver("$ftppid $pid2");
|
||||
displaylogs($testnumcheck);
|
||||
|
|
@ -1013,7 +1044,7 @@ sub runftpserver {
|
|||
$pid2 = $pid3;
|
||||
|
||||
if($verbose) {
|
||||
logmsg "RUN: FTP$id$nameext server is now running PID $ftppid\n";
|
||||
logmsg "RUN: $proto$id$nameext server is now running PID $ftppid\n";
|
||||
}
|
||||
|
||||
sleep(1);
|
||||
|
|
@ -1661,41 +1692,46 @@ sub checksystem {
|
|||
"* Host: $hostname",
|
||||
"* System: $hosttype");
|
||||
|
||||
logmsg sprintf("* Server SSL: %s\n", $stunnel?"ON":"OFF");
|
||||
logmsg sprintf("* libcurl SSL: %s\n", $ssl_version?"ON":"OFF");
|
||||
logmsg sprintf("* debug build: %s\n", $debug_build?"ON":"OFF");
|
||||
logmsg sprintf("* track memory: %s\n", $curl_debug?"ON":"OFF");
|
||||
logmsg sprintf("* valgrind: %s\n", $valgrind?"ON":"OFF");
|
||||
logmsg sprintf("* HTTP IPv6 %s\n", $http_ipv6?"ON":"OFF");
|
||||
logmsg sprintf("* FTP IPv6 %s\n", $ftp_ipv6?"ON":"OFF");
|
||||
|
||||
logmsg sprintf("* HTTP port: %d\n", $HTTPPORT);
|
||||
logmsg sprintf("* FTP port: %d\n", $FTPPORT);
|
||||
logmsg sprintf("* FTP port 2: %d\n", $FTP2PORT);
|
||||
if($stunnel) {
|
||||
logmsg sprintf("* FTPS port: %d\n", $FTPSPORT);
|
||||
logmsg sprintf("* HTTPS port: %d\n", $HTTPSPORT);
|
||||
logmsg sprintf("* Server SSL: %8s", $stunnel?"ON ":"OFF");
|
||||
logmsg sprintf(" libcurl SSL: %s\n", $ssl_version?"ON ":"OFF");
|
||||
logmsg sprintf("* debug build: %8s", $debug_build?"ON ":"OFF");
|
||||
logmsg sprintf(" track memory: %s\n", $curl_debug?"ON ":"OFF");
|
||||
logmsg sprintf("* valgrind: %8s", $valgrind?"ON ":"OFF");
|
||||
logmsg sprintf(" HTTP IPv6 %s\n", $http_ipv6?"ON ":"OFF");
|
||||
logmsg sprintf("* FTP IPv6 %8s", $ftp_ipv6?"ON ":"OFF");
|
||||
logmsg sprintf(" Libtool lib: %s\n", $libtool?"ON ":"OFF");
|
||||
if($ssl_version) {
|
||||
logmsg sprintf("* SSL library: %s\n", $ssllib);
|
||||
}
|
||||
|
||||
logmsg "* Ports:\n";
|
||||
|
||||
logmsg sprintf("* HTTP/%d ", $HTTPPORT);
|
||||
logmsg sprintf("FTP/%d ", $FTPPORT);
|
||||
logmsg sprintf("FTP2/%d ", $FTP2PORT);
|
||||
if($stunnel) {
|
||||
logmsg sprintf("FTPS/%d ", $FTPSPORT);
|
||||
logmsg sprintf("HTTPS/%d ", $HTTPSPORT);
|
||||
}
|
||||
logmsg sprintf("\n* TFTP/%d ", $TFTPPORT);
|
||||
if($http_ipv6) {
|
||||
logmsg sprintf("* HTTP IPv6 port: %d\n", $HTTP6PORT);
|
||||
logmsg sprintf("HTTP-IPv6/%d ", $HTTP6PORT);
|
||||
}
|
||||
if($ftp_ipv6) {
|
||||
logmsg sprintf("* FTP IPv6 port: %d\n", $FTP6PORT);
|
||||
logmsg sprintf("FTP-IPv6/%d ", $FTP6PORT);
|
||||
}
|
||||
logmsg sprintf("* TFTP port: %d\n", $TFTPPORT);
|
||||
if($tftp_ipv6) {
|
||||
logmsg sprintf("* TFTP IPv6 port: %d\n", $TFTP6PORT);
|
||||
logmsg sprintf("TFTP-IPv6/%d ", $TFTP6PORT);
|
||||
}
|
||||
logmsg sprintf("* SCP/SFTP port: %d\n", $SSHPORT);
|
||||
logmsg sprintf("* SOCKS port: %d\n", $SOCKSPORT);
|
||||
logmsg sprintf("\n* SSH/%d ", $SSHPORT);
|
||||
logmsg sprintf("SOCKS/%d ", $SOCKSPORT);
|
||||
logmsg sprintf("POP3/%d ", $POP3PORT);
|
||||
logmsg sprintf("IMAP/%d ", $IMAPPORT);
|
||||
logmsg sprintf("SMTP/%d\n", $SMTPPORT);
|
||||
|
||||
if($ssl_version) {
|
||||
logmsg sprintf("* SSL library: %s\n", $ssllib);
|
||||
}
|
||||
|
||||
$has_textaware = ($^O eq 'MSWin32') || ($^O eq 'msys');
|
||||
|
||||
logmsg sprintf("* Libtool lib: %s\n", $libtool?"ON":"OFF");
|
||||
logmsg "***************************************** \n";
|
||||
}
|
||||
|
||||
|
|
@ -1720,6 +1756,9 @@ sub subVariables {
|
|||
$$thing =~ s/%TFTP6PORT/$TFTP6PORT/g;
|
||||
$$thing =~ s/%SSHPORT/$SSHPORT/g;
|
||||
$$thing =~ s/%SOCKSPORT/$SOCKSPORT/g;
|
||||
$$thing =~ s/%POP3PORT/$POP3PORT/g;
|
||||
$$thing =~ s/%IMAPPORT/$IMAPPORT/g;
|
||||
$$thing =~ s/%SMTPPORT/$SMTPPORT/g;
|
||||
$$thing =~ s/%CURL/$CURL/g;
|
||||
$$thing =~ s/%USER/$USER/g;
|
||||
$$thing =~ s/%CLIENTIP/$CLIENTIP/g;
|
||||
|
|
@ -2546,19 +2585,22 @@ sub startservers {
|
|||
my $what = lc($whatlist[0]);
|
||||
$what =~ s/[^a-z0-9-]//g;
|
||||
|
||||
if($what eq "ftp") {
|
||||
if(!$run{'ftp'}) {
|
||||
($pid, $pid2) = runftpserver("", $verbose);
|
||||
if(($what eq "pop3") ||
|
||||
($what eq "ftp") ||
|
||||
($what eq "imap") ||
|
||||
($what eq "smtp")) {
|
||||
if(!$run{$what}) {
|
||||
($pid, $pid2) = runpingpongserver($what, "", $verbose);
|
||||
if($pid <= 0) {
|
||||
return "failed starting FTP server";
|
||||
return "failed starting $what server";
|
||||
}
|
||||
printf ("* pid ftp => %d %d\n", $pid, $pid2) if($verbose);
|
||||
$run{'ftp'}="$pid $pid2";
|
||||
printf ("* pid $what => %d %d\n", $pid, $pid2) if($verbose);
|
||||
$run{$what}="$pid $pid2";
|
||||
}
|
||||
}
|
||||
elsif($what eq "ftp2") {
|
||||
if(!$run{'ftp2'}) {
|
||||
($pid, $pid2) = runftpserver("2", $verbose);
|
||||
($pid, $pid2) = runpingpongserver("ftp", "2", $verbose);
|
||||
if($pid <= 0) {
|
||||
return "failed starting FTP2 server";
|
||||
}
|
||||
|
|
@ -2568,7 +2610,7 @@ sub startservers {
|
|||
}
|
||||
elsif($what eq "ftp-ipv6") {
|
||||
if(!$run{'ftp-ipv6'}) {
|
||||
($pid, $pid2) = runftpserver("", $verbose, "ipv6");
|
||||
($pid, $pid2) = runpingpongserver("ftp", "", $verbose, "ipv6");
|
||||
if($pid <= 0) {
|
||||
return "failed starting FTP-IPv6 server";
|
||||
}
|
||||
|
|
@ -2609,7 +2651,7 @@ sub startservers {
|
|||
}
|
||||
|
||||
if(!$run{'ftp'}) {
|
||||
($pid, $pid2) = runftpserver("", $verbose);
|
||||
($pid, $pid2) = runpingpongserver("ftp", "", $verbose);
|
||||
if($pid <= 0) {
|
||||
return "failed starting FTP server";
|
||||
}
|
||||
|
|
@ -2939,18 +2981,21 @@ if ($gdbthis) {
|
|||
}
|
||||
}
|
||||
|
||||
$HTTPPORT = $base + 0; # HTTP server port
|
||||
$HTTPSPORT = $base + 1; # HTTPS server port
|
||||
$FTPPORT = $base + 2; # FTP server port
|
||||
$FTPSPORT = $base + 3; # FTPS server port
|
||||
$HTTP6PORT = $base + 4; # HTTP IPv6 server port (different IP protocol
|
||||
$HTTPPORT = $base++; # HTTP server port
|
||||
$HTTPSPORT = $base++; # HTTPS server port
|
||||
$FTPPORT = $base++; # FTP server port
|
||||
$FTPSPORT = $base++; # FTPS server port
|
||||
$HTTP6PORT = $base++; # HTTP IPv6 server port (different IP protocol
|
||||
# but we follow the same port scheme anyway)
|
||||
$FTP2PORT = $base + 5; # FTP server 2 port
|
||||
$FTP6PORT = $base + 6; # FTP IPv6 port
|
||||
$TFTPPORT = $base + 7; # TFTP (UDP) port
|
||||
$TFTP6PORT = $base + 8; # TFTP IPv6 (UDP) port
|
||||
$SSHPORT = $base + 9; # SSH (SCP/SFTP) port
|
||||
$SOCKSPORT = $base + 10; # SOCKS port
|
||||
$FTP2PORT = $base++; # FTP server 2 port
|
||||
$FTP6PORT = $base++; # FTP IPv6 port
|
||||
$TFTPPORT = $base++; # TFTP (UDP) port
|
||||
$TFTP6PORT = $base++; # TFTP IPv6 (UDP) port
|
||||
$SSHPORT = $base++; # SSH (SCP/SFTP) port
|
||||
$SOCKSPORT = $base++; # SOCKS port
|
||||
$POP3PORT = $base++;
|
||||
$IMAPPORT = $base++;
|
||||
$SMTPPORT = $base++;
|
||||
|
||||
#######################################################################
|
||||
# clear and create logging directory:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue