From: Steve Holme Date: Sun, 29 Sep 2013 08:53:49 +0000 (+0100) Subject: ftpserver.pl: Moved specifying the test number from the RCPT address X-Git-Tag: curl-7_33_0~23 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=49341628b50007c290d669ce3f51c562aad9708c;p=thirdparty%2Fcurl.git ftpserver.pl: Moved specifying the test number from the RCPT address ...to the client address as this frees the RCPT strings to contain just an email address and by passing the test number into curl as the client address remains consistent with POP3 and IMAP tests as they are specified in the URL. --- diff --git a/tests/data/test1320 b/tests/data/test1320 index 7fbefc9d00..4d6c8ea85c 100644 --- a/tests/data/test1320 +++ b/tests/data/test1320 @@ -35,7 +35,7 @@ To: another body -smtp://smtp.1320:%SMTPPORT/user --mail-rcpt 1320@example.com --mail-from 1320@example.com -T - -p -x %HOSTIP:%PROXYPORT +smtp://smtp.1320:%SMTPPORT/1320 --mail-rcpt 1320@example.com --mail-from 1320@example.com -T - -p -x %HOSTIP:%PROXYPORT @@ -46,7 +46,7 @@ smtp://smtp.1320:%SMTPPORT/user --mail-rcpt 1320@example.com --mail-from 1320@ex ^User-Agent: curl/.* -EHLO user +EHLO 1320 MAIL FROM:<1320@example.com> RCPT TO:<1320@example.com> DATA diff --git a/tests/data/test1406 b/tests/data/test1406 index b330691fa2..819e44313c 100644 --- a/tests/data/test1406 +++ b/tests/data/test1406 @@ -32,7 +32,7 @@ To: another body -smtp://%HOSTIP:%SMTPPORT/user --mail-rcpt 1406@example.com --mail-rcpt 1406@foobar.example.com --mail-from 1406@example.com -T log/test1406.eml --libcurl log/test1406.c +smtp://%HOSTIP:%SMTPPORT/1406 --mail-rcpt 1406@example.com --mail-rcpt 1406@foobar.example.com --mail-from 1406@example.com -T log/test1406.eml --libcurl log/test1406.c @@ -40,7 +40,7 @@ smtp://%HOSTIP:%SMTPPORT/user --mail-rcpt 1406@example.com --mail-rcpt 1406@foob # Verify data after the test has been "shot" -EHLO user +EHLO 1406 MAIL FROM:<1406@example.com> SIZE=38 RCPT TO:<1406@example.com> RCPT TO:<1406@foobar.example.com> @@ -73,7 +73,7 @@ int main(int argc, char *argv[]) hnd = curl_easy_init(); curl_easy_setopt(hnd, CURLOPT_INFILESIZE_LARGE, (curl_off_t)38); - curl_easy_setopt(hnd, CURLOPT_URL, "smtp://%HOSTIP:%SMTPPORT/user"); + curl_easy_setopt(hnd, CURLOPT_URL, "smtp://%HOSTIP:%SMTPPORT/1406"); curl_easy_setopt(hnd, CURLOPT_HEADER, 1L); curl_easy_setopt(hnd, CURLOPT_UPLOAD, 1L); curl_easy_setopt(hnd, CURLOPT_USERAGENT, "stripped"); diff --git a/tests/data/test1507 b/tests/data/test1507 index 76ec5320dc..ab7b47eb31 100644 --- a/tests/data/test1507 +++ b/tests/data/test1507 @@ -32,7 +32,7 @@ To: another body -smtp://%HOSTIP:%SMTPPORT/user +smtp://%HOSTIP:%SMTPPORT/1507 @@ -40,7 +40,7 @@ smtp://%HOSTIP:%SMTPPORT/user # Verify data after the test has been "shot" -EHLO user +EHLO 1507 MAIL FROM:<1507-realuser@example.com> RCPT TO:<1507-recipient@example.com> DATA diff --git a/tests/data/test900 b/tests/data/test900 index 5c30ec6206..36f063388f 100644 --- a/tests/data/test900 +++ b/tests/data/test900 @@ -26,7 +26,7 @@ To: another body -smtp://%HOSTIP:%SMTPPORT/user --mail-rcpt 900@example.com --mail-from 900@example.com -T - +smtp://%HOSTIP:%SMTPPORT/900 --mail-rcpt 900@example.com --mail-from 900@example.com -T - @@ -34,7 +34,7 @@ smtp://%HOSTIP:%SMTPPORT/user --mail-rcpt 900@example.com --mail-from 900@exampl # Verify data after the test has been "shot" -EHLO user +EHLO 900 MAIL FROM:<900@example.com> RCPT TO:<900@example.com> DATA diff --git a/tests/data/test901 b/tests/data/test901 index 7d660868ff..7836dcfb3d 100644 --- a/tests/data/test901 +++ b/tests/data/test901 @@ -32,7 +32,7 @@ To: another body -smtp://%HOSTIP:%SMTPPORT/user --mail-rcpt 901@example.com --mail-from 901@example.com -T - +smtp://%HOSTIP:%SMTPPORT/901 --mail-rcpt 901@example.com --mail-from 901@example.com -T - @@ -40,7 +40,7 @@ smtp://%HOSTIP:%SMTPPORT/user --mail-rcpt 901@example.com --mail-from 901@exampl # Verify data after the test has been "shot" -EHLO user +EHLO 901 MAIL FROM:<901@example.com> RCPT TO:<901@example.com> DATA diff --git a/tests/data/test902 b/tests/data/test902 index e185501392..2994eeff3f 100644 --- a/tests/data/test902 +++ b/tests/data/test902 @@ -31,7 +31,7 @@ To: another body -smtp://%HOSTIP:%SMTPPORT/user --mail-rcpt 902@example.com --mail-from 902@example.com -T - +smtp://%HOSTIP:%SMTPPORT/902 --mail-rcpt 902@example.com --mail-from 902@example.com -T - @@ -39,8 +39,8 @@ smtp://%HOSTIP:%SMTPPORT/user --mail-rcpt 902@example.com --mail-from 902@exampl # Verify data after the test has been "shot" -EHLO user -HELO user +EHLO 902 +HELO 902 MAIL FROM:<902@example.com> RCPT TO:<902@example.com> DATA diff --git a/tests/data/test903 b/tests/data/test903 index 56ab36ebb4..1b4530dc11 100644 --- a/tests/data/test903 +++ b/tests/data/test903 @@ -31,7 +31,7 @@ SMTP plain authentication mail body -smtp://%HOSTIP:%SMTPPORT/user --mail-rcpt 903@example.com --mail-from 903@example.com -u test:1234 -T - +smtp://%HOSTIP:%SMTPPORT/903 --mail-rcpt 903@example.com --mail-from 903@example.com -u test:1234 -T - @@ -39,7 +39,7 @@ smtp://%HOSTIP:%SMTPPORT/user --mail-rcpt 903@example.com --mail-from 903@exampl # Verify data after the test has been "shot" -EHLO user +EHLO 903 AUTH PLAIN dGVzdAB0ZXN0ADEyMzQ= MAIL FROM:<903@example.com> diff --git a/tests/data/test904 b/tests/data/test904 index a1d47ba5e8..cb4014a5ed 100644 --- a/tests/data/test904 +++ b/tests/data/test904 @@ -31,7 +31,7 @@ SMTP login authentication mail body -smtp://%HOSTIP:%SMTPPORT/user --mail-rcpt 904@example.com --mail-from 904@example.com -u test:1234 -T - +smtp://%HOSTIP:%SMTPPORT/904 --mail-rcpt 904@example.com --mail-from 904@example.com -u test:1234 -T - @@ -39,7 +39,7 @@ smtp://%HOSTIP:%SMTPPORT/user --mail-rcpt 904@example.com --mail-from 904@exampl # Verify data after the test has been "shot" -EHLO user +EHLO 904 AUTH LOGIN dGVzdA== MTIzNA== diff --git a/tests/data/test905 b/tests/data/test905 index e6c4864eab..214bc1822c 100644 --- a/tests/data/test905 +++ b/tests/data/test905 @@ -34,7 +34,7 @@ SMTP CRAM-MD5 authentication mail body -smtp://%HOSTIP:%SMTPPORT/user --mail-rcpt 905@example.com --mail-from 905@example.com -u tim:tanstaaftanstaaf -T - +smtp://%HOSTIP:%SMTPPORT/905 --mail-rcpt 905@example.com --mail-from 905@example.com -u tim:tanstaaftanstaaf -T - @@ -42,7 +42,7 @@ smtp://%HOSTIP:%SMTPPORT/user --mail-rcpt 905@example.com --mail-from 905@exampl # Verify data after the test has been "shot" -EHLO user +EHLO 905 AUTH CRAM-MD5 dGltIGI5MTNhNjAyYzdlZGE3YTQ5NWI0ZTZlNzMzNGQzODkw MAIL FROM:<905@example.com> diff --git a/tests/data/test906 b/tests/data/test906 index d87f70e577..f60cec3f7c 100644 --- a/tests/data/test906 +++ b/tests/data/test906 @@ -39,7 +39,7 @@ LD_PRELOAD=%PWD/libtest/.libs/libhostname.so mail body -smtp://%HOSTIP:%SMTPPORT/user --mail-rcpt 906@example.com --mail-from 906@example.com -u testuser:testpass -T - +smtp://%HOSTIP:%SMTPPORT/906 --mail-rcpt 906@example.com --mail-from 906@example.com -u testuser:testpass -T - @@ -47,7 +47,7 @@ smtp://%HOSTIP:%SMTPPORT/user --mail-rcpt 906@example.com --mail-from 906@exampl # Verify data after the test has been "shot" -EHLO user +EHLO 906 AUTH NTLM TlRMTVNTUAABAAAABoIIAAAAAAAAAAAAAAAAAAAAAAA= TlRMTVNTUAADAAAAGAAYAEAAAAAYABgAWAAAAAAAAABwAAAACAAIAHAAAAAIAAgAeAAAAAAAAAAAAAAABoKBAFpkQwKRCZFMhjj0tw47wEjKHRHlvzfxQamFcheMuv8v+xeqphEO5V41xRd7R9deOXRlc3R1c2VyY3VybGhvc3Q= diff --git a/tests/data/test907 b/tests/data/test907 index 0265f2605a..7bdde410ec 100644 --- a/tests/data/test907 +++ b/tests/data/test907 @@ -30,7 +30,7 @@ SMTP plain authentication with initial response mail body -smtp://%HOSTIP:%SMTPPORT/user --mail-rcpt 907@example.com --mail-from 907@example.com -u test:1234 --sasl-ir -T - +smtp://%HOSTIP:%SMTPPORT/907 --mail-rcpt 907@example.com --mail-from 907@example.com -u test:1234 --sasl-ir -T - @@ -38,7 +38,7 @@ smtp://%HOSTIP:%SMTPPORT/user --mail-rcpt 907@example.com --mail-from 907@exampl # Verify data after the test has been "shot" -EHLO user +EHLO 907 AUTH PLAIN dGVzdAB0ZXN0ADEyMzQ= MAIL FROM:<907@example.com> RCPT TO:<907@example.com> diff --git a/tests/data/test908 b/tests/data/test908 index f77a61a786..0c1667a3b5 100644 --- a/tests/data/test908 +++ b/tests/data/test908 @@ -30,7 +30,7 @@ SMTP login authentication with initial response mail body -smtp://%HOSTIP:%SMTPPORT/user --mail-rcpt 908@example.com --mail-from 908@example.com -u test:1234 --sasl-ir -T - +smtp://%HOSTIP:%SMTPPORT/908 --mail-rcpt 908@example.com --mail-from 908@example.com -u test:1234 --sasl-ir -T - @@ -38,7 +38,7 @@ smtp://%HOSTIP:%SMTPPORT/user --mail-rcpt 908@example.com --mail-from 908@exampl # Verify data after the test has been "shot" -EHLO user +EHLO 908 AUTH LOGIN dGVzdA== MTIzNA== MAIL FROM:<908@example.com> diff --git a/tests/data/test909 b/tests/data/test909 index b92a872dd0..ffe42ba428 100644 --- a/tests/data/test909 +++ b/tests/data/test909 @@ -30,7 +30,7 @@ To: another body -smtp://%HOSTIP:%SMTPPORT/user --mail-rcpt 909@example.com --mail-from 909@example.com -T log/test909.eml +smtp://%HOSTIP:%SMTPPORT/909 --mail-rcpt 909@example.com --mail-from 909@example.com -T log/test909.eml @@ -38,7 +38,7 @@ smtp://%HOSTIP:%SMTPPORT/user --mail-rcpt 909@example.com --mail-from 909@exampl # Verify data after the test has been "shot" -EHLO user +EHLO 909 MAIL FROM:<909@example.com> RCPT TO:<909@example.com> DATA diff --git a/tests/data/test910 b/tests/data/test910 index ecf7557e51..a3bf480bd3 100644 --- a/tests/data/test910 +++ b/tests/data/test910 @@ -26,7 +26,7 @@ To: another body -smtp://%HOSTIP:%SMTPPORT/user --mail-rcpt 910@example.com --mail-from 910@example.com -T - +smtp://%HOSTIP:%SMTPPORT/910 --mail-rcpt 910@example.com --mail-from 910@example.com -T - @@ -34,7 +34,7 @@ smtp://%HOSTIP:%SMTPPORT/user --mail-rcpt 910@example.com --mail-from 910@exampl # Verify data after the test has been "shot" -EHLO user +EHLO 910 MAIL FROM:<910@example.com> RCPT TO:<910@example.com> DATA diff --git a/tests/data/test911 b/tests/data/test911 index 18a8fc62a8..206f8afe06 100644 --- a/tests/data/test911 +++ b/tests/data/test911 @@ -25,7 +25,7 @@ SMTP with no mail data -smtp://%HOSTIP:%SMTPPORT/user --mail-rcpt 911@example.com --mail-from 911@example.com -T - +smtp://%HOSTIP:%SMTPPORT/911 --mail-rcpt 911@example.com --mail-from 911@example.com -T - @@ -33,7 +33,7 @@ smtp://%HOSTIP:%SMTPPORT/user --mail-rcpt 911@example.com --mail-from 911@exampl # Verify data after the test has been "shot" -EHLO user +EHLO 911 MAIL FROM:<911@example.com> RCPT TO:<911@example.com> DATA diff --git a/tests/data/test912 b/tests/data/test912 index 5e3718400e..04abfd79a0 100644 --- a/tests/data/test912 +++ b/tests/data/test912 @@ -30,7 +30,7 @@ To: another body -smtp://%HOSTIP:%SMTPPORT/user --mail-rcpt 912@example.com --mail-from 912@example.com -T log/test912.eml +smtp://%HOSTIP:%SMTPPORT/912 --mail-rcpt 912@example.com --mail-from 912@example.com -T log/test912.eml @@ -38,7 +38,7 @@ smtp://%HOSTIP:%SMTPPORT/user --mail-rcpt 912@example.com --mail-from 912@exampl # Verify data after the test has been "shot" -EHLO user +EHLO 912 MAIL FROM:<912@example.com> SIZE=38 RCPT TO:<912@example.com> DATA diff --git a/tests/data/test913 b/tests/data/test913 index ceabe1182b..8c016e930e 100644 --- a/tests/data/test913 +++ b/tests/data/test913 @@ -30,7 +30,7 @@ To: another body -smtp://%HOSTIP:%SMTPPORT/user --mail-rcpt 913@example.com --mail-from 913@example.com -T log/test913.eml +smtp://%HOSTIP:%SMTPPORT/913 --mail-rcpt 913@example.com --mail-from 913@example.com -T log/test913.eml @@ -41,7 +41,7 @@ smtp://%HOSTIP:%SMTPPORT/user --mail-rcpt 913@example.com --mail-from 913@exampl 55 -EHLO user +EHLO 913 MAIL FROM:<913@example.com> SIZE=38 QUIT diff --git a/tests/data/test914 b/tests/data/test914 index c2599f64a6..cc97bdd9fc 100644 --- a/tests/data/test914 +++ b/tests/data/test914 @@ -26,7 +26,7 @@ To: another body -smtp://%HOSTIP:%SMTPPORT/user --mail-rcpt 914@example.com --mail-from invalid -T log/test914.eml +smtp://%HOSTIP:%SMTPPORT/914 --mail-rcpt 914@example.com --mail-from invalid -T log/test914.eml @@ -37,7 +37,7 @@ smtp://%HOSTIP:%SMTPPORT/user --mail-rcpt 914@example.com --mail-from invalid -T 55 -EHLO user +EHLO 914 MAIL FROM: QUIT diff --git a/tests/data/test915 b/tests/data/test915 index da851c34c6..3b5b62e167 100644 --- a/tests/data/test915 +++ b/tests/data/test915 @@ -26,7 +26,7 @@ To: another body -smtp://%HOSTIP:%SMTPPORT/user --mail-rcpt 915@example.com -T - +smtp://%HOSTIP:%SMTPPORT/915 --mail-rcpt 915@example.com -T - @@ -34,7 +34,7 @@ smtp://%HOSTIP:%SMTPPORT/user --mail-rcpt 915@example.com -T - # Verify data after the test has been "shot" -EHLO user +EHLO 915 MAIL FROM:<> RCPT TO:<915@example.com> DATA diff --git a/tests/data/test916 b/tests/data/test916 index 3a9ccea187..f2e0aedd06 100644 --- a/tests/data/test916 +++ b/tests/data/test916 @@ -26,7 +26,7 @@ To: another body -smtp://%HOSTIP:%SMTPPORT/user --mail-rcpt invalid --mail-from 916@example.com -T - +smtp://%HOSTIP:%SMTPPORT/916 --mail-rcpt invalid --mail-from 916@example.com -T - @@ -37,7 +37,7 @@ smtp://%HOSTIP:%SMTPPORT/user --mail-rcpt invalid --mail-from 916@example.com -T 55 -EHLO user +EHLO 916 MAIL FROM:<916@example.com> RCPT TO: QUIT diff --git a/tests/data/test917 b/tests/data/test917 index d5dc4f8efa..23a05ecb10 100644 --- a/tests/data/test917 +++ b/tests/data/test917 @@ -26,7 +26,7 @@ To: another body -smtp://%HOSTIP:%SMTPPORT/user --mail-rcpt 917@example.com --mail-rcpt 917@foo.example.com --mail-rcpt 917@bar.example.com --mail-rcpt 917@foobar.example.com --mail-rcpt 917@another.example.com --mail-from 917@example.com -T - +smtp://%HOSTIP:%SMTPPORT/917 --mail-rcpt 917@example.com --mail-rcpt 917@foo.example.com --mail-rcpt 917@bar.example.com --mail-rcpt 917@foobar.example.com --mail-rcpt 917@another.example.com --mail-from 917@example.com -T - @@ -34,7 +34,7 @@ smtp://%HOSTIP:%SMTPPORT/user --mail-rcpt 917@example.com --mail-rcpt 917@foo.ex # Verify data after the test has been "shot" -EHLO user +EHLO 917 MAIL FROM:<917@example.com> RCPT TO:<917@example.com> RCPT TO:<917@foo.example.com> diff --git a/tests/data/test918 b/tests/data/test918 index be9ec853f3..4817e28147 100644 --- a/tests/data/test918 +++ b/tests/data/test918 @@ -26,7 +26,7 @@ To: another body -smtp://%HOSTIP:%SMTPPORT/user --mail-rcpt 918@example.com --mail-rcpt invalid --mail-rcpt 918@bar.example.com --mail-rcpt sTrAnGe --mail-rcpt 918@another.example.com --mail-from 918@example.com -T - +smtp://%HOSTIP:%SMTPPORT/918 --mail-rcpt 918@example.com --mail-rcpt invalid --mail-rcpt 918@bar.example.com --mail-rcpt sTrAnGe --mail-rcpt 918@another.example.com --mail-from 918@example.com -T - @@ -37,7 +37,7 @@ smtp://%HOSTIP:%SMTPPORT/user --mail-rcpt 918@example.com --mail-rcpt invalid -- 55 -EHLO user +EHLO 918 MAIL FROM:<918@example.com> RCPT TO:<918@example.com> RCPT TO: diff --git a/tests/ftpserver.pl b/tests/ftpserver.pl index 838d849a0f..907846ab9b 100755 --- a/tests/ftpserver.pl +++ b/tests/ftpserver.pl @@ -685,12 +685,12 @@ sub close_dataconn { ################ SMTP commands ################ -# what set by "RCPT" -my $smtp_rcpt; - # The type of server (SMTP or ESMTP) my $smtp_type; +# The client (which normally contains the test number) +my $smtp_client; + sub EHLO_smtp { my ($client) = @_; @@ -753,6 +753,9 @@ sub EHLO_smtp { sendcontrol "250 $d\r\n"; } } + + # Store the client (as it may contain the test number) + $smtp_client = $client; } return 0; @@ -784,6 +787,9 @@ sub HELO_smtp { # 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; } return 0; @@ -854,11 +860,11 @@ sub RCPT_smtp { sendcontrol "501 Unrecognized parameter\r\n"; } else { - $smtp_rcpt = $1; + my $to = $1; # Validate the to address (only a valid email address inside <> is # allowed, such as ) - if ($smtp_rcpt !~ + if ($to !~ /^<([a-zA-Z0-9._%+-]+)\@([a-zA-Z0-9.-]+).([a-zA-Z]{2,4})>$/) { sendcontrol "501 Invalid address\r\n"; } @@ -872,17 +878,17 @@ sub RCPT_smtp { sub DATA_smtp { my ($args) = @_; - my $testno = $smtp_rcpt; if ($args) { sendcontrol "501 Unrecognized parameter\r\n"; } + elsif ($smtp_client !~ /^(\d*)$/) + sendcontrol "501 Invalid arguments\r\n"; + } else { - $testno =~ s/^([^0-9]*)([0-9]+).*/$2/; sendcontrol "354 Show me the mail\r\n"; - logmsg "===> rcpt $testno was $smtp_rcpt\n"; - + my $testno = $smtp_client; my $filename = "log/upload.$testno"; logmsg "Store test number $testno in $filename\n";