mirror of
https://blitiri.com.ar/repos/chasquid
synced 2025-12-22 15:27:02 +00:00
chasquid: Detect email loops
This patch implements some measures against email loops, such as keeping a limit on the lenght of an address, and rejecting email that has too many Received headers. It's not perfect (a server could be actively removing Received headers), but it should cover the normal accidents and misconfigurations.
This commit is contained in:
8
test/t-09-loop/A/chasquid.conf
Normal file
8
test/t-09-loop/A/chasquid.conf
Normal file
@@ -0,0 +1,8 @@
|
||||
smtp_address: ":1025"
|
||||
submission_address: ":1587"
|
||||
monitoring_address: ":1099"
|
||||
|
||||
mail_delivery_agent_bin: "test-mda"
|
||||
mail_delivery_agent_args: "%to%"
|
||||
|
||||
data_dir: "../.data-A"
|
||||
2
test/t-09-loop/A/domains/srv-A/aliases
Normal file
2
test/t-09-loop/A/domains/srv-A/aliases
Normal file
@@ -0,0 +1,2 @@
|
||||
|
||||
aliasA: aliasB@srv-B
|
||||
8
test/t-09-loop/B/chasquid.conf
Normal file
8
test/t-09-loop/B/chasquid.conf
Normal file
@@ -0,0 +1,8 @@
|
||||
smtp_address: ":2025"
|
||||
submission_address: ":2587"
|
||||
monitoring_address: ":2099"
|
||||
|
||||
mail_delivery_agent_bin: "test-mda"
|
||||
mail_delivery_agent_args: "%to%"
|
||||
|
||||
data_dir: "../.data-B"
|
||||
1
test/t-09-loop/B/domains/srv-B/aliases
Normal file
1
test/t-09-loop/B/domains/srv-B/aliases
Normal file
@@ -0,0 +1 @@
|
||||
aliasB: aliasA@srv-A
|
||||
9
test/t-09-loop/content
Normal file
9
test/t-09-loop/content
Normal file
@@ -0,0 +1,9 @@
|
||||
From: userA@srv-A
|
||||
To: aliasB@srv-B
|
||||
Subject: Los espejos
|
||||
|
||||
Yo que sentí el horror de los espejos
|
||||
no sólo ante el cristal impenetrable
|
||||
donde acaba y empieza, inhabitable,
|
||||
un imposible espacio de reflejos
|
||||
|
||||
2
test/t-09-loop/hosts
Normal file
2
test/t-09-loop/hosts
Normal file
@@ -0,0 +1,2 @@
|
||||
srv-A localhost
|
||||
srv-B localhost
|
||||
14
test/t-09-loop/msmtprc
Normal file
14
test/t-09-loop/msmtprc
Normal file
@@ -0,0 +1,14 @@
|
||||
account default
|
||||
|
||||
host srv-A
|
||||
port 1587
|
||||
|
||||
tls on
|
||||
tls_trust_file A/certs/srv-A/fullchain.pem
|
||||
|
||||
from userA@srv-A
|
||||
|
||||
auth on
|
||||
user userA@srv-A
|
||||
password userA
|
||||
|
||||
43
test/t-09-loop/run.sh
Executable file
43
test/t-09-loop/run.sh
Executable file
@@ -0,0 +1,43 @@
|
||||
#!/bin/bash
|
||||
|
||||
set -e
|
||||
. $(dirname ${0})/../util/lib.sh
|
||||
|
||||
init
|
||||
|
||||
rm -rf .data-A .data-B .mail
|
||||
|
||||
# Two servers:
|
||||
# A - listens on :1025, hosts srv-A
|
||||
# B - listens on :2015, hosts srv-B
|
||||
#
|
||||
# We cause the following loop:
|
||||
# userA -> aliasB -> aliasA -> aliasB -> ...
|
||||
|
||||
CONFDIR=A generate_certs_for srv-A
|
||||
CONFDIR=A add_user srv-A userA userA
|
||||
|
||||
CONFDIR=B generate_certs_for srv-B
|
||||
|
||||
mkdir -p .logs-A .logs-B
|
||||
|
||||
chasquid -v=2 --log_dir=.logs-A --config_dir=A \
|
||||
--testing__outgoing_smtp_port=2025 &
|
||||
chasquid -v=2 --log_dir=.logs-B --config_dir=B \
|
||||
--testing__outgoing_smtp_port=1025 &
|
||||
|
||||
wait_until_ready 1025
|
||||
wait_until_ready 2025
|
||||
|
||||
run_msmtp aliasB@srv-B < content
|
||||
|
||||
# Wait until one of them has noticed and stopped the loop.
|
||||
while sleep 0.1; do
|
||||
wget -q -O .data-A/vars http://localhost:1099/debug/vars
|
||||
wget -q -O .data-B/vars http://localhost:2099/debug/vars
|
||||
if grep -q '"chasquid/smtpIn/loopsDetected": 1,' .data-?/vars; then
|
||||
break
|
||||
fi
|
||||
done
|
||||
|
||||
success
|
||||
Reference in New Issue
Block a user