From 4bfe07640c93f8dfd3af4bb76c8346ef4a129cc8 Mon Sep 17 00:00:00 2001 From: monnerat Date: Mon, 19 Apr 2010 11:16:30 +0200 Subject: Implement SMTP authentication --- tests/data/Makefile.am | 2 +- tests/data/test805 | 54 +++++++++++++++++++++++++++++++++++++++++++++ tests/data/test806 | 55 ++++++++++++++++++++++++++++++++++++++++++++++ tests/data/test807 | 59 ++++++++++++++++++++++++++++++++++++++++++++++++++ tests/ftpserver.pl | 19 ++++++++++------ tests/runtests.pl | 1 - 6 files changed, 181 insertions(+), 9 deletions(-) create mode 100644 tests/data/test805 create mode 100644 tests/data/test806 create mode 100644 tests/data/test807 (limited to 'tests') diff --git a/tests/data/Makefile.am b/tests/data/Makefile.am index 6f2c09079..b28c5adc2 100644 --- a/tests/data/Makefile.am +++ b/tests/data/Makefile.am @@ -65,7 +65,7 @@ EXTRA_DIST = test1 test108 test117 test127 test20 test27 test34 test46 \ test564 test1101 test1102 test1103 test1104 test299 test310 test311 \ test312 test1105 test565 test800 test1106 test801 test566 test802 test803 \ test1107 test1108 test1109 test1110 test1111 test1112 test129 test567 \ - test568 test569 test570 test571 test804 test572 + test568 test569 test570 test571 test572 test804 test805 test806 test807 filecheck: @mkdir test-place; \ diff --git a/tests/data/test805 b/tests/data/test805 new file mode 100644 index 000000000..fba5124f3 --- /dev/null +++ b/tests/data/test805 @@ -0,0 +1,54 @@ + + + +SMTP +SMTP AUTH PLAIN +RFC4616 +RFC4954 + + + +# +# Server-side + + +REPLY EHLO 220 AUTH PLAIN +REPLY AUTH 235 Authenticated + + + +# +# Client-side + + +smtp + + +SMTP plain authentication + + +mail body + + +smtp://%HOSTIP:%SMTPPORT/user --mail-rcpt 805@foo --mail-from 805@from -u test:1234 -T - + + + +# +# Verify data after the test has been "shot" + + +EHLO user +AUTH PLAIN dGVzdAB0ZXN0ADEyMzQ= +MAIL FROM:805@from +RCPT TO:<805@foo> +DATA +QUIT + + +mail body + +. + + + diff --git a/tests/data/test806 b/tests/data/test806 new file mode 100644 index 000000000..8ece5dc8c --- /dev/null +++ b/tests/data/test806 @@ -0,0 +1,55 @@ + + + +SMTP +SMTP AUTH LOGIN +RFC4954 + + + +# +# Server-side + + +REPLY EHLO 220 AUTH LOGIN +REPLY AUTH 334 UGFzc3dvcmQ6 +REPLY MTIzNA== 235 Authenticated + + + +# +# Client-side + + +smtp + + +SMTP login authentication + + +mail body + + +smtp://%HOSTIP:%SMTPPORT/user --mail-rcpt 806@foo --mail-from 806@from -u test:1234 -T - + + + +# +# Verify data after the test has been "shot" + + +EHLO user +AUTH LOGIN dGVzdA== +MTIzNA== +MAIL FROM:806@from +RCPT TO:<806@foo> +DATA +QUIT + + +mail body + +. + + + diff --git a/tests/data/test807 b/tests/data/test807 new file mode 100644 index 000000000..6daa1d02b --- /dev/null +++ b/tests/data/test807 @@ -0,0 +1,59 @@ + + + +SMTP +SMTP AUTH CRAM-MD5 +RFC2195 +RFC4954 + + + +# +# Server-side + + +REPLY EHLO 220 AUTH CRAM-MD5 +REPLY AUTH 334 PDE4OTYuNjk3MTcwOTUyQHBvc3RvZmZpY2UucmVzdG9uLm1jaS5uZXQ+ +REPLY dGltIGI5MTNhNjAyYzdlZGE3YTQ5NWI0ZTZlNzMzNGQzODkw 235 Authenticated + + + +# +# Client-side + + +smtp + + +crypto + + +SMTP CRAM-MD5 authentication + + +mail body + + +smtp://%HOSTIP:%SMTPPORT/user --mail-rcpt 807@foo --mail-from 807@from -u tim:tanstaaftanstaaf -T - + + + +# +# Verify data after the test has been "shot" + + +EHLO user +AUTH CRAM-MD5 +dGltIGI5MTNhNjAyYzdlZGE3YTQ5NWI0ZTZlNzMzNGQzODkw +MAIL FROM:807@from +RCPT TO:<807@foo> +DATA +QUIT + + +mail body + +. + + + diff --git a/tests/ftpserver.pl b/tests/ftpserver.pl index d6b676cab..cc69585c8 100755 --- a/tests/ftpserver.pl +++ b/tests/ftpserver.pl @@ -1118,7 +1118,7 @@ sub customize { logmsg "FTPD: Getting commands from log/ftpserver.cmd\n"; while() { - if($_ =~ /REPLY ([A-Z]+) (.*)/) { + if($_ =~ /REPLY ([A-Za-z0-9+\/=]+) (.*)/) { $customreply{$1}=eval "qq{$2}"; logmsg "FTPD: set custom reply for $1\n"; } @@ -1380,13 +1380,18 @@ while(1) { $FTPCMD=$2; $FTPARG=$3; } - else { - unless (m/^([A-Z]{3,4})\s?(.*)/i) { - sendcontrol "500 '$_': command not understood.\r\n"; - last; - } + elsif (m/^([A-Z]{3,4})(\s(.*))?$/i) { $FTPCMD=$1; - $FTPARG=$2; + $FTPARG=$3; + } + elsif($proto eq "smtp" && m/^[A-Z0-9+\/]{0,512}={0,2}$/i) { + # SMTP long "commands" are base64 authentication data. + $FTPCMD=$_; + $FTPARG=""; + } + else { + sendcontrol "500 '$_': command not understood.\r\n"; + last; } logmsg "< \"$full\"\n"; diff --git a/tests/runtests.pl b/tests/runtests.pl index 6e3b5b9cf..c8a54f05a 100755 --- a/tests/runtests.pl +++ b/tests/runtests.pl @@ -755,7 +755,6 @@ sub verifyftp { # has _no_ output! $extra .= "--mail-rcpt verifiedserver "; $extra .= "--mail-from fake "; - $extra .= "--user localhost:unused "; $extra .= "--upload /dev/null "; $extra .= "--stderr - "; # move stderr to parse the verbose stuff } -- cgit v1.2.3