This commit is contained in:
Randy Bush 2024-03-10 16:45:53 -07:00
parent 1a3991bbe5
commit a4490edc27
3 changed files with 43 additions and 117 deletions

View file

@ -202,7 +202,7 @@ Edit `/etc/default/grub`
```
GRUB_TIMEOUT=6
...
GRUB_CMDLINE_LINUX="console=tty0 console=ttyS0,9600n8"
GRUB_CMDLINE_LINUX="console=tty0 console=ttyS0,115200n8"
...
GRUB_TERMINAL="console serial"

View file

@ -1,5 +1,9 @@
# Postfix with Rspamd on Debian 12 Bookworm
This is based on Thomas Pircher's 2021 [DKIM setup with Postfix and
Rspamd on Debian
Linux](https://p5r.uk/blog/2021/dkim-setup-with-postfix-and-rspamd.html)
## Install needed debs
```
@ -29,6 +33,7 @@ sudo chown -R _rspamd:_rspamd /var/lib/rspamd/dkim
```
sudo mkdir /var/spool/postfix/rspamd
sudo chown postfix:_rspamd /var/spool/postfix/rspamd
sudo chmod g+w /var/spool/postfix/rspamd/
```
## Configure Rspamd
@ -55,7 +60,7 @@ And, beware your selector is probably not 'rgnet-mail'
```
cat >> /etc/rspamd/local.d/dkim_signing.conf << EOF
path = "/var/lib/rspamd/dkim/$domain.$selector.key";
path = "/var/lib/rspamd/dkim/\$domain.public";
selector = "rgnet-mail";
### Enable DKIM signing for alias sender addresses
allow_username_mismatch = true;
@ -68,121 +73,35 @@ Then
sudo systemctl restart rspamd
```
Which fails
```
blort.rg.net:/etc/systemd# sudo systemctl status rspamd
à rspamd.service - rapid spam filtering system
Loaded: loaded (/lib/systemd/system/rspamd.service; enabled; preset: enabled)
Active: failed (Result: exit-code) since Mon 2024-01-01 23:09:09 UTC; 50s ago
Duration: 377ms
Docs: https://rspamd.com/doc/
Process: 2139 ExecStart=/usr/bin/rspamd -c /etc/rspamd/rspamd.conf -f (code=exited, status=1/FAILURE)
Main PID: 2139 (code=exited, status=1/FAILURE)
CPU: 311ms
## Postfix Configuration
Jan 01 23:09:09 blort.rg.net systemd[1]: rspamd.service: Main process exited, code=exited, status=1/FAILURE
Jan 01 23:09:09 blort.rg.net systemd[1]: rspamd.service: Failed with result 'exit-code'.
Jan 01 23:09:09 blort.rg.net systemd[1]: rspamd.service: Scheduled restart job, restart counter is at 5.
Jan 01 23:09:09 blort.rg.net systemd[1]: Stopped rspamd.service - rapid spam filtering system.
Jan 01 23:09:09 blort.rg.net systemd[1]: rspamd.service: Start request repeated too quickly.
Jan 01 23:09:09 blort.rg.net systemd[1]: rspamd.service: Failed with result 'exit-code'.
Jan 01 23:09:09 blort.rg.net systemd[1]: Failed to start rspamd.service - rapid spam filtering system.
Tell postfix to handle milter errors gracefully
```
cat >> /etc/postfix/main.cf << EOF
# Added to work with rspamd
milter_default_action = accept
# As the DKIM milter is the only in use
smtpd_milters = unix:/rspamd/milter.sock
non_smtpd_milters = unix:/rspamd/milter.sock
# Also set the milter_mail_macros and milter_protocol options:
milter_protocol = 6
milter_mail_macros = i {mail_addr} {client_addr} {client_name} {auth_authen}
EOF
```
And
And restart postfix
```
blort.rg.net:/etc/systemd# journalctl -xe
ââ Defined-By: systemd
ââ Support: https://www.debian.org/support
ââ
ââ A start job for unit rspamd.service has finished successfully.
ââ
ââ The job identifier is 1512.
Jan 01 23:09:08 blort.rg.net rspamd[2138]: 2024-01-01 23:09:08 #2138(main) <f8664a>; main; main: rspamd 3.4 is loading configuration, build id: release
Jan 01 23:09:08 blort.rg.net systemd[1]: rspamd.service: Main process exited, code=exited, status=1/FAILURE
ââ Subject: Unit process exited
ââ Defined-By: systemd
ââ Support: https://www.debian.org/support
ââ
ââ An ExecStart= process belonging to unit rspamd.service has exited.
ââ
ââ The process' exit code is 'exited' and its exit status is 1.
Jan 01 23:09:08 blort.rg.net systemd[1]: rspamd.service: Failed with result 'exit-code'.
ââ Subject: Unit failed
ââ Defined-By: systemd
ââ Support: https://www.debian.org/support
ââ
ââ The unit rspamd.service has entered the 'failed' state with result 'exit-code'.
Jan 01 23:09:08 blort.rg.net systemd[1]: rspamd.service: Scheduled restart job, restart counter is at 4.
ââ Subject: Automatic restarting of a unit has been scheduled
ââ Defined-By: systemd
ââ Support: https://www.debian.org/support
ââ
ââ Automatic restarting of the unit rspamd.service has been scheduled, as the result for
ââ the configured Restart= setting for the unit.
Jan 01 23:09:08 blort.rg.net systemd[1]: Stopped rspamd.service - rapid spam filtering system.
ââ Subject: A stop job for unit rspamd.service has finished
ââ Defined-By: systemd
ââ Support: https://www.debian.org/support
ââ
ââ A stop job for unit rspamd.service has finished.
ââ
ââ The job identifier is 1584 and the job result is done.
Jan 01 23:09:08 blort.rg.net systemd[1]: Started rspamd.service - rapid spam filtering system.
ââ Subject: A start job for unit rspamd.service has finished successfully
ââ Defined-By: systemd
ââ Support: https://www.debian.org/support
ââ
ââ A start job for unit rspamd.service has finished successfully.
ââ
ââ The job identifier is 1584.
Jan 01 23:09:08 blort.rg.net rspamd[2139]: 2024-01-01 23:09:08 #2139(main) <f5da70>; main; main: rspamd 3.4 is loading configuration, build id: release
Jan 01 23:09:09 blort.rg.net systemd[1]: rspamd.service: Main process exited, code=exited, status=1/FAILURE
ââ Subject: Unit process exited
ââ Defined-By: systemd
ââ Support: https://www.debian.org/support
ââ
ââ An ExecStart= process belonging to unit rspamd.service has exited.
ââ
ââ The process' exit code is 'exited' and its exit status is 1.
Jan 01 23:09:09 blort.rg.net systemd[1]: rspamd.service: Failed with result 'exit-code'.
ââ Subject: Unit failed
ââ Defined-By: systemd
ââ Support: https://www.debian.org/support
ââ
ââ The unit rspamd.service has entered the 'failed' state with result 'exit-code'.
Jan 01 23:09:09 blort.rg.net systemd[1]: rspamd.service: Scheduled restart job, restart counter is at 5.
ââ Subject: Automatic restarting of a unit has been scheduled
ââ Defined-By: systemd
ââ Support: https://www.debian.org/support
ââ
ââ Automatic restarting of the unit rspamd.service has been scheduled, as the result for
ââ the configured Restart= setting for the unit.
Jan 01 23:09:09 blort.rg.net systemd[1]: Stopped rspamd.service - rapid spam filtering system.
ââ Subject: A stop job for unit rspamd.service has finished
ââ Defined-By: systemd
ââ Support: https://www.debian.org/support
ââ
ââ A stop job for unit rspamd.service has finished.
ââ
ââ The job identifier is 1656 and the job result is done.
Jan 01 23:09:09 blort.rg.net systemd[1]: rspamd.service: Start request repeated too quickly.
Jan 01 23:09:09 blort.rg.net systemd[1]: rspamd.service: Failed with result 'exit-code'.
ââ Subject: Unit failed
ââ Defined-By: systemd
ââ Support: https://www.debian.org/support
ââ
ââ The unit rspamd.service has entered the 'failed' state with result 'exit-code'.
Jan 01 23:09:09 blort.rg.net systemd[1]: Failed to start rspamd.service - rapid spam filtering system.
ââ Subject: A start job for unit rspamd.service has failed
ââ Defined-By: systemd
ââ Support: https://www.debian.org/support
ââ
ââ A start job for unit rspamd.service has finished with a failure.
ââ
ââ The job identifier is 1656 and the job result is failed.
Jan 01 23:09:29 blort.rg.net sshd[2145]: Connection reset by 205.210.31.68 port 60622 [preauth]
Jan 01 23:10:00 blort.rg.net sudo[2147]: root : TTY=pts/1 ; PWD=/etc/systemd ; USER=root ; COMMAND=/usr/bin/systemctl status rspamd
Jan 01 23:10:00 blort.rg.net sudo[2147]: pam_unix(sudo:session): session opened for user root(uid=0) by randy(uid=0)
Jan 01 23:10:00 blort.rg.net sudo[2147]: pam_unix(sudo:session): session closed for user root
```
systemctl restart postfix.service
```
And maybe check its status
```
systemctl status postfix.service
```
---
2024.01.01

View file

@ -4,6 +4,11 @@ This work is motivated by Google, Yahoo, et alia outsourcing their
spam problems to smaller folk such as I. Read [Google's latest
requirements](https://support.google.com/mail/answer/81126).
Note that, at this writing, Google et alia are only asking for SPF and
DKIM unless you are running a large bulk mailer. For the latter, ARC
is also needed. As I do not run a large bulk mailer, I ignore ARC; at
least this season.
This recipe set assumes the Debian or FreeBSD is current. It works on
Buster and Bookworm and FreeBSD 13 with Exim 4.97. YMMV. A variant
actually worked on Ubuntu 18.04.6 LTS (Bionic Beaver).
@ -78,6 +83,8 @@ rgnet-mail._domainkey.myzone. TXT ( "v=DKIM1; p=MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ
"Dt/qZAmFUT+RCj6EIibg3E8Lt30qh5WZsMWFAB+4fCCf7UvBGVsEEOFUjLPsXDdyadBJxNnt3U7q+6p+vG16JwoimGp0onNqlladneBHTVbLPLloAVEv3zqVRBx8s1Smrt3/vp0AxLkjKkRAlJgvi2uiSAbaSukpvSNH+Gt4RRtK8yQWjxOfPDHveaxR0MEqgwIDAQAB" )
```
Those quote marks, ", are necessary.
## Exim Configuration
First, ensure the Exim binary you are running supports DKIM.
@ -144,4 +151,4 @@ configuration conditionals stitch this all into the transport in
the usual arcane Exim fashion.
---
2023.12.18
2024.01.07