|
@@ -6,10 +6,13 @@ It aims to resolve the problem that OpenDKIM signs ALL mails with domains listed
|
|
The postconf option "reject_authenticated_sender_login_mismatch" doesn't solve the problem at all, because it only enforces the envelope sender to be correct. This milter further ensures that the sender specified in the header matches the envelope sender.
|
|
The postconf option "reject_authenticated_sender_login_mismatch" doesn't solve the problem at all, because it only enforces the envelope sender to be correct. This milter further ensures that the sender specified in the header matches the envelope sender.
|
|
|
|
|
|
## Beta
|
|
## Beta
|
|
-This code is beta. It would be great if someone who has more experience with libmilter would look at my code and send me some feedback. The code is really short (one file with 270 lines) and based on the libmilter example.
|
|
+This code is beta. It would be great if someone who has more experience with libmilter would look at my code and send me some feedback. The code is really short (one file with 270 lines) and based on the libmilter example.
|
|
|
|
+
|
|
|
|
+## Dependencies (as Debian package names)
|
|
|
|
+* git cmake make gcc
|
|
|
|
+* libmilter1.0.1 libmilter-dev
|
|
|
|
|
|
## Build
|
|
## Build
|
|
-As always:
|
|
|
|
```bash
|
|
```bash
|
|
mkdir build
|
|
mkdir build
|
|
cd $_
|
|
cd $_
|
|
@@ -17,11 +20,8 @@ cmake ..
|
|
make
|
|
make
|
|
```
|
|
```
|
|
|
|
|
|
-## Postfix (on Debian)
|
|
+## Install (on a Systemd environment)
|
|
-```bash
|
|
+Add a user:
|
|
-apt-get install git cmake make gcc libmilter1.0.1 libmilter-dev
|
|
|
|
-```
|
|
|
|
-
|
|
|
|
```bash
|
|
```bash
|
|
groupadd milterfrom
|
|
groupadd milterfrom
|
|
useradd -g milterfrom -s /bin/false -d /var/spool/postfix/milterfrom milterfrom
|
|
useradd -g milterfrom -s /bin/false -d /var/spool/postfix/milterfrom milterfrom
|
|
@@ -30,51 +30,28 @@ mkdir /var/spool/postfix/milterfrom
|
|
chown milterfrom:milterfrom /var/spool/postfix/milterfrom
|
|
chown milterfrom:milterfrom /var/spool/postfix/milterfrom
|
|
```
|
|
```
|
|
|
|
|
|
|
|
+Move the binary and the service file:
|
|
```bash
|
|
```bash
|
|
cp milterfrom /usr/local/bin
|
|
cp milterfrom /usr/local/bin
|
|
|
|
+cp ../milterfrom.service /etc/systemd/system/
|
|
```
|
|
```
|
|
-```bash
|
|
|
|
-nano /etc/systemd/system/milterfrom.service
|
|
|
|
-```
|
|
|
|
-```
|
|
|
|
-[Unit]
|
|
|
|
-Description=Milter which enforces equal envelope and header sender
|
|
|
|
-
|
|
|
|
-[Service]
|
|
|
|
-Type=forking
|
|
|
|
-PIDFile=/var/run/milterfrom.pid
|
|
|
|
-EnvironmentFile=-/etc/default/milterfrom
|
|
|
|
-ExecStart=/usr/local/bin/milterfrom -d -p /var/run/milterfrom.pid $OPTIONS
|
|
|
|
-ExecReload=/bin/kill -HUP $MAINPID
|
|
|
|
|
|
|
|
-[Install]
|
|
+Configure postfix to use the milter:
|
|
-WantedBy=multi-user.target
|
|
|
|
```
|
|
```
|
|
-```bash
|
|
+postconf -e "smtpd_milters = unix:/milterfrom/milterfrom$([[ $(postconf -h smtpd_milters) != "" ]] && echo -n ", " && postconf -h smtpd_milters)"
|
|
-nano /etc/default/milterfrom
|
|
+postconf -e "non_smtpd_milters = unix:/milterfrom/milterfrom$([[ $(postconf -h non_smtpd_milters) != "" ]] && echo -n ", " && postconf -h non_smtpd_milters)"
|
|
-```
|
|
|
|
-```bash
|
|
|
|
-OPTIONS="-u milterfrom -g milterfrom -m 002 -s /var/spool/postfix/milterfrom/milterfrom"
|
|
|
|
-```
|
|
|
|
-
|
|
|
|
-Change the Postfix config file (if you don't use DKIM, remove the parts):
|
|
|
|
-```bash
|
|
|
|
-nano /etc/postfix/main.cf
|
|
|
|
-```
|
|
|
|
-```
|
|
|
|
-smtpd_milters = unix:/milterfrom/milterfrom, unix:/opendkim/opendkim.sock
|
|
|
|
-non_smtpd_milters = unix:/milterfrom/milterfrom, unix:/opendkim/opendkim.sock
|
|
|
|
```
|
|
```
|
|
|
|
|
|
|
|
+Start everything:
|
|
```bash
|
|
```bash
|
|
systemctl enable milterfrom
|
|
systemctl enable milterfrom
|
|
-service postfix restart
|
|
|
|
service milterfrom start
|
|
service milterfrom start
|
|
|
|
+service postfix restart
|
|
```
|
|
```
|
|
|
|
|
|
## Example
|
|
## Example
|
|
```bash
|
|
```bash
|
|
-openssl s_client -connect mail.example.invalid -starttls smtp
|
|
+openssl s_client -connect mail.coolkids.invalid -starttls smtp
|
|
```
|
|
```
|
|
```
|
|
```
|
|
CONNECTED(00000003)
|
|
CONNECTED(00000003)
|
|
@@ -84,27 +61,30 @@ CONNECTED(00000003)
|
|
auth login
|
|
auth login
|
|
[...]
|
|
[...]
|
|
235 2.7.0 Authentication successful
|
|
235 2.7.0 Authentication successful
|
|
-mail from: theuser@example.invalid
|
|
+mail from: chantal@coolkids.invalid
|
|
250 2.1.0 Ok
|
|
250 2.1.0 Ok
|
|
-rcpt to: someuser@external.invalid
|
|
+rcpt to: justin@external.invalid
|
|
250 2.1.5 Ok
|
|
250 2.1.5 Ok
|
|
data
|
|
data
|
|
354 End data with <CR><LF>.<CR><LF>
|
|
354 End data with <CR><LF>.<CR><LF>
|
|
-From: anotheruser@example.invalid
|
|
+From: jacqueline@coolkids.invalid
|
|
-To: someuser@external.invalid
|
|
+To: justin@coolkids.invalid
|
|
-Subject: Spam
|
|
+Subject: Diese Mail ist super vertrauemswuerdig!11
|
|
|
|
+
|
|
|
|
+Hey Justin,
|
|
|
|
|
|
-Hey! :)
|
|
+i bims Jacqueline. Ich liebe dich lol!
|
|
|
|
+
|
|
|
|
+Deine Jacqueline
|
|
.
|
|
.
|
|
550 5.7.1 Rejected due to unmatching envelope and header sender.
|
|
550 5.7.1 Rejected due to unmatching envelope and header sender.
|
|
quit
|
|
quit
|
|
221 2.0.0 Bye
|
|
221 2.0.0 Bye
|
|
closed
|
|
closed
|
|
-
|
|
|
|
```
|
|
```
|
|
|
|
|
|
## Run
|
|
## Run
|
|
-To start the daemon directly, run the following:
|
|
+To start the daemon directly, run the following (Remove the `-d` to run in foreground):
|
|
```bash
|
|
```bash
|
|
./milterfrom -u milterfrom -g milterfrom -m 002 -d -p /var/run/milterfrom.pid -s /var/spool/postfix/milterfrom/milterfrom
|
|
./milterfrom -u milterfrom -g milterfrom -m 002 -d -p /var/run/milterfrom.pid -s /var/spool/postfix/milterfrom/milterfrom
|
|
```
|
|
```
|