mirror of
https://github.com/curl/curl.git
synced 2026-06-20 09:35:37 +03:00
Implement SMTP authentication
This commit is contained in:
parent
c5e539c312
commit
4bfe07640c
15 changed files with 858 additions and 50 deletions
|
|
@ -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; \
|
||||
|
|
|
|||
54
tests/data/test805
Normal file
54
tests/data/test805
Normal file
|
|
@ -0,0 +1,54 @@
|
|||
<testcase>
|
||||
<info>
|
||||
<keywords>
|
||||
SMTP
|
||||
SMTP AUTH PLAIN
|
||||
RFC4616
|
||||
RFC4954
|
||||
</keywords>
|
||||
</info>
|
||||
|
||||
#
|
||||
# Server-side
|
||||
<reply>
|
||||
<servercmd>
|
||||
REPLY EHLO 220 AUTH PLAIN
|
||||
REPLY AUTH 235 Authenticated
|
||||
</servercmd>
|
||||
</reply>
|
||||
|
||||
#
|
||||
# Client-side
|
||||
<client>
|
||||
<server>
|
||||
smtp
|
||||
</server>
|
||||
<name>
|
||||
SMTP plain authentication
|
||||
</name>
|
||||
<stdin>
|
||||
mail body
|
||||
</stdin>
|
||||
<command>
|
||||
smtp://%HOSTIP:%SMTPPORT/user --mail-rcpt 805@foo --mail-from 805@from -u test:1234 -T -
|
||||
</command>
|
||||
</client>
|
||||
|
||||
#
|
||||
# Verify data after the test has been "shot"
|
||||
<verify>
|
||||
<protocol>
|
||||
EHLO user
|
||||
AUTH PLAIN dGVzdAB0ZXN0ADEyMzQ=
|
||||
MAIL FROM:805@from
|
||||
RCPT TO:<805@foo>
|
||||
DATA
|
||||
QUIT
|
||||
</protocol>
|
||||
<upload>
|
||||
mail body
|
||||
|
||||
.
|
||||
</upload>
|
||||
</verify>
|
||||
</testcase>
|
||||
55
tests/data/test806
Normal file
55
tests/data/test806
Normal file
|
|
@ -0,0 +1,55 @@
|
|||
<testcase>
|
||||
<info>
|
||||
<keywords>
|
||||
SMTP
|
||||
SMTP AUTH LOGIN
|
||||
RFC4954
|
||||
</keywords>
|
||||
</info>
|
||||
|
||||
#
|
||||
# Server-side
|
||||
<reply>
|
||||
<servercmd>
|
||||
REPLY EHLO 220 AUTH LOGIN
|
||||
REPLY AUTH 334 UGFzc3dvcmQ6
|
||||
REPLY MTIzNA== 235 Authenticated
|
||||
</servercmd>
|
||||
</reply>
|
||||
|
||||
#
|
||||
# Client-side
|
||||
<client>
|
||||
<server>
|
||||
smtp
|
||||
</server>
|
||||
<name>
|
||||
SMTP login authentication
|
||||
</name>
|
||||
<stdin>
|
||||
mail body
|
||||
</stdin>
|
||||
<command>
|
||||
smtp://%HOSTIP:%SMTPPORT/user --mail-rcpt 806@foo --mail-from 806@from -u test:1234 -T -
|
||||
</command>
|
||||
</client>
|
||||
|
||||
#
|
||||
# Verify data after the test has been "shot"
|
||||
<verify>
|
||||
<protocol>
|
||||
EHLO user
|
||||
AUTH LOGIN dGVzdA==
|
||||
MTIzNA==
|
||||
MAIL FROM:806@from
|
||||
RCPT TO:<806@foo>
|
||||
DATA
|
||||
QUIT
|
||||
</protocol>
|
||||
<upload>
|
||||
mail body
|
||||
|
||||
.
|
||||
</upload>
|
||||
</verify>
|
||||
</testcase>
|
||||
59
tests/data/test807
Normal file
59
tests/data/test807
Normal file
|
|
@ -0,0 +1,59 @@
|
|||
<testcase>
|
||||
<info>
|
||||
<keywords>
|
||||
SMTP
|
||||
SMTP AUTH CRAM-MD5
|
||||
RFC2195
|
||||
RFC4954
|
||||
</keywords>
|
||||
</info>
|
||||
|
||||
#
|
||||
# Server-side
|
||||
<reply>
|
||||
<servercmd>
|
||||
REPLY EHLO 220 AUTH CRAM-MD5
|
||||
REPLY AUTH 334 PDE4OTYuNjk3MTcwOTUyQHBvc3RvZmZpY2UucmVzdG9uLm1jaS5uZXQ+
|
||||
REPLY dGltIGI5MTNhNjAyYzdlZGE3YTQ5NWI0ZTZlNzMzNGQzODkw 235 Authenticated
|
||||
</servercmd>
|
||||
</reply>
|
||||
|
||||
#
|
||||
# Client-side
|
||||
<client>
|
||||
<server>
|
||||
smtp
|
||||
</server>
|
||||
<features>
|
||||
crypto
|
||||
</features>
|
||||
<name>
|
||||
SMTP CRAM-MD5 authentication
|
||||
</name>
|
||||
<stdin>
|
||||
mail body
|
||||
</stdin>
|
||||
<command>
|
||||
smtp://%HOSTIP:%SMTPPORT/user --mail-rcpt 807@foo --mail-from 807@from -u tim:tanstaaftanstaaf -T -
|
||||
</command>
|
||||
</client>
|
||||
|
||||
#
|
||||
# Verify data after the test has been "shot"
|
||||
<verify>
|
||||
<protocol>
|
||||
EHLO user
|
||||
AUTH CRAM-MD5
|
||||
dGltIGI5MTNhNjAyYzdlZGE3YTQ5NWI0ZTZlNzMzNGQzODkw
|
||||
MAIL FROM:807@from
|
||||
RCPT TO:<807@foo>
|
||||
DATA
|
||||
QUIT
|
||||
</protocol>
|
||||
<upload>
|
||||
mail body
|
||||
|
||||
.
|
||||
</upload>
|
||||
</verify>
|
||||
</testcase>
|
||||
|
|
@ -1118,7 +1118,7 @@ sub customize {
|
|||
logmsg "FTPD: Getting commands from log/ftpserver.cmd\n";
|
||||
|
||||
while(<CUSTOM>) {
|
||||
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";
|
||||
|
|
|
|||
|
|
@ -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
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue