-
Notifications
You must be signed in to change notification settings - Fork 44
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
protocols/smtp: Fix treating auth failure as a permanent failure
A typo in the SMTP configuration would cause messages to be rejected due to the AUTH command being failed. This would result in password typos causing messages to be bounced. This change adds a new temporary error code specifically for authentication failures, which will result in retries (with backoff) instead of bounces. Thanks to Fejes József <[email protected]> for identifying this problem. This also adds tests for SMTP AUTH which had been missing.
- Loading branch information
Showing
8 changed files
with
85 additions
and
35 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
echo 250 ME | ||
echo 250-ME | ||
echo 250-AUTH PLAIN | ||
echo 250 OK | ||
cat $1 | ||
rm -f $1 | ||
echo 250 OK | ||
echo 250 OK | ||
echo 351 OK | ||
echo 220 OK | ||
sleep 1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -48,6 +48,10 @@ stop() { | |
wait | ||
done | ||
} | ||
catch-port() { | ||
local name=$1 | ||
port=$( head -n 1 $tmpdir/service/${name}-log ) | ||
} | ||
|
||
#not() { if "$@"; then return 1; else return 0; fi } | ||
not() { ! safe "$@"; } | ||
|
@@ -128,6 +132,21 @@ splitblank() { | |
done | ||
} | ||
|
||
make-testmail() { | ||
testmail=$tmpdir/testmail | ||
rm -f $testmail | ||
cat >$testmail <<EOF | ||
[email protected] | ||
[email protected] | ||
From: <[email protected]> | ||
To: <[email protected]> | ||
Subject: Nullmailer automated test message | ||
Just testing, please ignore | ||
EOF | ||
} | ||
|
||
export PATH=/bin:/usr/bin:/usr/local/bin | ||
rm -f $SYSCONFDIR/* | ||
echo f.q.d.n >$SYSCONFDIR/me | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,69 +1,59 @@ | ||
. functions | ||
export HELOHOST=f.q.d.n | ||
|
||
rm -f testmail | ||
cat >testmail <<EOF | ||
[email protected] | ||
[email protected] | ||
|
||
From: <[email protected]> | ||
To: <[email protected]> | ||
Subject: Nullmailer automated test message | ||
|
||
Just testing, please ignore | ||
EOF | ||
make-testmail | ||
|
||
for p in smtp qmqp | ||
do | ||
start server "tcpserver -1 ::0 0 sh $srcdir/test/accept-$p.sh" | ||
port=$( head -n 1 $tmpdir/service/server-log ) | ||
catch-port server | ||
|
||
echo "Testing protocol success with $p (command-line)" | ||
protocol $p --host=localhost --port=$port 3<testmail | ||
protocol $p --host=localhost --port=$port 3<$testmail | ||
|
||
echo "Testing protocol success with $p (stdin)" | ||
protocol $p -- host=localhost port=$port 3<testmail | ||
protocol $p -- host=localhost port=$port 3<$testmail | ||
|
||
echo "Testing protocol success with $p (stdin, IPv6)" | ||
protocol $p -- host=::1 port=$port 3<testmail | ||
protocol $p -- host=::1 port=$port 3<$testmail | ||
|
||
echo "Testing protocol success with $p (source addr)" | ||
protocol $p -- host=::1 port=$port source=::1 3<testmail | ||
protocol $p -- host=::1 port=$port source=::1 3<$testmail | ||
|
||
echo "Testing protocol failure with $p (bad source addr 1)" | ||
error 19 protocol $p -- host=::1 port=$port source=127.0.0.1 3<testmail | ||
error 19 protocol $p -- host=::1 port=$port source=127.0.0.1 3<$testmail | ||
|
||
echo "Testing protocol failure with $p (bad source addr 2)" | ||
error 19 protocol $p -- host=127.0.0.1 port=$port source=::1 3<testmail | ||
error 19 protocol $p -- host=127.0.0.1 port=$port source=::1 3<$testmail | ||
|
||
stop server | ||
|
||
echo "Testing host not found error with $p." | ||
error 2 protocol $p --host=this.host.can.not.exist 3<testmail | ||
error 2 protocol $p --host=this.host.can.not.exist 3<$testmail | ||
|
||
echo "Testing connection refused error with $p." | ||
error 7 protocol $p -p $port --host=localhost 3<testmail | ||
error 7 protocol $p -p $port --host=localhost 3<$testmail | ||
|
||
echo "Testing connection refused error with $p (IPv6)." | ||
error 7 protocol $p -p $port --host=::1 3<testmail | ||
error 7 protocol $p -p $port --host=::1 3<$testmail | ||
|
||
echo "Testing usage error with $p (zero args)." | ||
error 1 protocol $p 3<testmail | ||
error 1 protocol $p 3<$testmail | ||
|
||
echo "Testing usage error with $p (two args)." | ||
error 1 protocol $p --host=localhost foobar 3<testmail | ||
error 1 protocol $p --host=localhost foobar 3<$testmail | ||
|
||
echo "Testing usage error with $p (unknown option)." | ||
error 1 protocol $p -x --host=localhost 3<testmail | ||
error 1 protocol $p -x --host=localhost 3<$testmail | ||
|
||
echo "Testing usage error with $p (invalid integer)." | ||
error 1 protocol $p -p foo --host=localhost 3<testmail | ||
error 1 protocol $p -p foo --host=localhost 3<$testmail | ||
|
||
start server tcpserver -1 0 0 date | ||
port=$( head -n 1 $tmpdir/service/server-log ) | ||
echo "Testing protocol failure with $p." | ||
error 11 protocol $p -p $port --host=localhost 3<testmail | ||
error 11 protocol $p -p $port --host=localhost 3<$testmail | ||
stop server | ||
done | ||
|
||
rm -f testmail | ||
stop server |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
. functions | ||
export HELOHOST=f.q.d.n | ||
|
||
make-testmail | ||
|
||
start server "tcpserver -1 ::0 0 sh $srcdir/test/authtest-smtp.sh $tmpdir/smtp-result" | ||
catch-port server | ||
|
||
echo 'Testing auth success with smtp' | ||
echo '250 OK' > $tmpdir/smtp-result | ||
protocol smtp --host=localhost --port=$port --user=example --pass=example 3<$testmail | ||
|
||
echo 'Testing auth login success with smtp' | ||
echo $'350 Go ahead\n250 AUTH' > $tmpdir/smtp-result | ||
protocol smtp --host=localhost --port=$port --user=example --pass=example --auth-login 3<$testmail | ||
|
||
echo 'Testing auth temporary failure with smtp' | ||
echo '450 No' > $tmpdir/smtp-result | ||
error 16 protocol smtp --host=localhost --port $port --user=example --pass=example 3<$testmail | ||
|
||
echo 'Testing auth permanent failure with smtp' | ||
echo '550 No' > $tmpdir/smtp-result | ||
error 20 protocol smtp --host=localhost --port $port --user=example --pass=example 3<$testmail | ||
|
||
stop server |