diff --git a/tests/ftpserver.pl b/tests/ftpserver.pl index 3ade82fc3..1edb8e8cf 100755 --- a/tests/ftpserver.pl +++ b/tests/ftpserver.pl @@ -702,104 +702,78 @@ my $smtp_client; sub EHLO_smtp { my ($client) = @_; + my @data; - if($client eq "verifiedserver") { - # This is the secret command that verifies that this actually is - # the curl test server - sendcontrol "554 WE ROOLZ: $$\r\n"; - - if($verbose) { - print STDERR "FTPD: We returned proof we are the test server\n"; - } - - logmsg "return proof we are we\n"; + # TODO: Get the IP address of the client connection to use in the + # EHLO response when the client doesn't specify one but for now use + # 127.0.0.1 + if(!$client) { + $client = "[127.0.0.1]"; } - else { - my @data; - # TODO: Get the IP address of the client connection to use in the - # EHLO response when the client doesn't specify one but for now use - # 127.0.0.1 - if (!$client) { - $client = "[127.0.0.1]"; + # Set the server type to ESMTP + $smtp_type = "ESMTP"; + + # Calculate the EHLO response + push @data, "$smtp_type pingpong test server Hello $client"; + + if((@capabilities) || (@auth_mechs)) { + my $mechs; + + for my $c (@capabilities) { + push @data, $c; } - # Set the server type to ESMTP - $smtp_type = "ESMTP"; - - # Calculate the EHLO response - push @data, "$smtp_type pingpong test server Hello $client"; - - if((@capabilities) || (@auth_mechs)) { - my $mechs; - - for my $c (@capabilities) { - push @data, $c; - } - - for my $am (@auth_mechs) { - if(!$mechs) { - $mechs = "$am"; - } - else { - $mechs .= " $am"; - } - } - - if($mechs) { - push @data, "AUTH $mechs"; - } - } - - # Send the EHLO response - for (my $i = 0; $i < @data; $i++) { - my $d = $data[$i]; - - if($i < @data - 1) { - sendcontrol "250-$d\r\n"; + for my $am (@auth_mechs) { + if(!$mechs) { + $mechs = "$am"; } else { - sendcontrol "250 $d\r\n"; + $mechs .= " $am"; } } - # Store the client (as it may contain the test number) - $smtp_client = $client; + if($mechs) { + push @data, "AUTH $mechs"; + } } + # Send the EHLO response + for(my $i = 0; $i < @data; $i++) { + my $d = $data[$i]; + + if($i < @data - 1) { + sendcontrol "250-$d\r\n"; + } + else { + sendcontrol "250 $d\r\n"; + } + } + + # Store the client (as it may contain the test number) + $smtp_client = $client; +} + return 0; } sub HELO_smtp { my ($client) = @_; - if($client eq "verifiedserver") { - # This is the secret command that verifies that this actually is - # the curl test server - sendcontrol "554 WE ROOLZ: $$\r\n"; - - if($verbose) { - print STDERR "FTPD: We returned proof we are the test server\n"; - } - - logmsg "return proof we are we\n"; + # TODO: Get the IP address of the client connection to use in the HELO + # response when the client doesn't specify one but for now use 127.0.0.1 + if(!$client) { + $client = "[127.0.0.1]"; } - else { - # TODO: Get the IP address of the client connection to use in the HELO - # response when the client doesn't specify one but for now use 127.0.0.1 - if (!$client) { - $client = "[127.0.0.1]"; - } - # Set the server type to SMTP - $smtp_type = "SMTP"; + # Set the server type to SMTP + $smtp_type = "SMTP"; - # Send the HELO response - sendcontrol "250 $smtp_type pingpong test server Hello $client\r\n"; + # Send the HELO response + sendcontrol "250 $smtp_type pingpong test server Hello $client\r\n"; - # Store the client (as it may contain the test number) - $smtp_client = $client; - } + # Store the client (as it may contain the test number) + $smtp_client = $client; return 0; } @@ -997,13 +971,26 @@ sub HELP_smtp { logmsg "HELP_smtp got $args\n"; } - sendcontrol "214-This server supports the following commands:\r\n"; + if($smtp_client eq "verifiedserver") { + # This is the secret command that verifies that this actually is + # the curl test server + sendcontrol "214 WE ROOLZ: $$\r\n"; - if(@auth_mechs) { - sendcontrol "214 HELO EHLO RCPT DATA RSET MAIL VRFY EXPN QUIT HELP AUTH\r\n"; + if($verbose) { + print STDERR "FTPD: We returned proof we are the test server\n"; + } + + logmsg "return proof we are we\n"; } else { - sendcontrol "214 HELO EHLO RCPT DATA RSET MAIL VRFY EXPN QUIT HELP\r\n"; + sendcontrol "214-This server supports the following commands:\r\n"; + + if(@auth_mechs) { + sendcontrol "214 HELO EHLO RCPT DATA RSET MAIL VRFY EXPN QUIT HELP AUTH\r\n"; + } + else { + sendcontrol "214 HELO EHLO RCPT DATA RSET MAIL VRFY EXPN QUIT HELP\r\n"; + } } return 0; diff --git a/tests/runtests.pl b/tests/runtests.pl index 8c0c5f280..a5f0efad6 100755 --- a/tests/runtests.pl +++ b/tests/runtests.pl @@ -790,14 +790,6 @@ sub verifyftp { if($proto eq "ftps") { $extra .= "--insecure --ftp-ssl-control "; } - elsif($proto eq "smtp") { - # SMTP is a bit different since it requires more options and it - # has _no_ output! - $extra .= "--mail-rcpt verifiedserver "; - $extra .= "--mail-from fake\@example.com "; - $extra .= "--upload /dev/null "; - $extra .= "--stderr - "; # move stderr to parse the verbose stuff - } my $flags = "--max-time $server_response_maxtime "; $flags .= "--silent ";