aboutsummaryrefslogtreecommitdiff
path: root/tests/ftpserver.pl
diff options
context:
space:
mode:
authorSteve Holme <steve_holme@hotmail.com>2013-09-21 20:49:23 +0100
committerSteve Holme <steve_holme@hotmail.com>2013-09-21 20:49:23 +0100
commitb07709f7417c3e30a6c09445585579a4616d2e81 (patch)
treec58363667f61e74708cb576323cb6cda840cc7c8 /tests/ftpserver.pl
parent9215cee4c6c3cc15b30e50bec98cbbc9f7a62663 (diff)
ftpserver.pl: Moved cURL SMTP server detection into EHLO command handler
Moved the special SMTP server detection code from the DATA command handler, which happens further down the operation chain after EHLO, MAIL and RCPT commands, to the EHLO command as it is the first command to be generated by a SMTP operation as well as containing the special "verifiedserver" string from the URL. This not only makes it easier and quicker to detect but also means that cURL doesn't need to specify "verifiedserver" as --mail-from and --mail-rcpt arguments. More importantly, this also makes the upcoming verification changes to the RCPT handler easier to implement.
Diffstat (limited to 'tests/ftpserver.pl')
-rwxr-xr-xtests/ftpserver.pl87
1 files changed, 48 insertions, 39 deletions
diff --git a/tests/ftpserver.pl b/tests/ftpserver.pl
index 603302eda..1c1512bf7 100755
--- a/tests/ftpserver.pl
+++ b/tests/ftpserver.pl
@@ -693,50 +693,65 @@ my $smtp_type;
sub EHLO_smtp {
my ($client) = @_;
- 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]";
+ 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";
}
+ else {
+ my @data;
- # Set the server type to ESMTP
- $smtp_type = "ESMTP";
+ # 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]";
+ }
- # Calculate the EHLO response
- push @data, "$smtp_type pingpong test server Hello $client";
+ # Set the server type to ESMTP
+ $smtp_type = "ESMTP";
- if((@capabilities) || (@auth_mechs)) {
- my $mechs;
+ # Calculate the EHLO response
+ push @data, "$smtp_type pingpong test server Hello $client";
- for my $c (@capabilities) {
- push @data, $c;
- }
+ if((@capabilities) || (@auth_mechs)) {
+ my $mechs;
- for my $am (@auth_mechs) {
- if(!$mechs) {
- $mechs = "$am";
+ for my $c (@capabilities) {
+ push @data, $c;
}
- else {
- $mechs .= " $am";
+
+ for my $am (@auth_mechs) {
+ if(!$mechs) {
+ $mechs = "$am";
+ }
+ else {
+ $mechs .= " $am";
+ }
}
- }
- if($mechs) {
- push @data, "AUTH $mechs";
+ if($mechs) {
+ push @data, "AUTH $mechs";
+ }
}
- }
- # Send the EHLO response
- for (my $i = 0; $i < @data; $i++) {
- my $d = $data[$i];
+ # 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";
+ if($i < @data - 1) {
+ sendcontrol "250-$d\r\n";
+ }
+ else {
+ sendcontrol "250 $d\r\n";
+ }
}
}
@@ -808,14 +823,8 @@ sub DATA_smtp {
return; # failure
}
- if($testno eq "<verifiedserver>") {
- sendcontrol "554 WE ROOLZ: $$\r\n";
- return 0; # don't wait for data now
- }
- else {
- $testno =~ s/^([^0-9]*)([0-9]+).*/$2/;
- sendcontrol "354 Show me the mail\r\n";
- }
+ $testno =~ s/^([^0-9]*)([0-9]+).*/$2/;
+ sendcontrol "354 Show me the mail\r\n";
logmsg "===> rcpt $testno was $smtp_rcpt\n";