-
Notifications
You must be signed in to change notification settings - Fork 17
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Replace rspamd with OpenDKIM #186
Conversation
WIP, need to add signature verification now. |
Now it checks at least something but probably needs http://www.opendkim.org/opendkim-lua.3.html scripts to ensure there is at least one valid signature corresponding to the |
I have added
Edit: fixed the problem and opened upstream issue |
60f485d
to
1bc3670
Compare
This is ready for review. I tested that it can reject mails by making a condition for skipping signatures in |
I received the following DKIM signature from c20.testrun.org:
does that mean the autocrypt header was not signed? |
Yes, does not seem to sign |
I tested, now Autocrypt is signed. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seems to work nicely :) one thing I noticed is that senders get a nice error message if their server doesn't have working DKIM, but opendkim doesn't log the rejection in journalctl. Can we add that?
c9.testrun.org is a test host without DKIM if you want to test it.
6cb7877
to
4594ee2
Compare
Can add
But even without this postfix logs already:
So I think additional logs in OpenDKIM are not necessary. |
4594ee2
to
cd3aa73
Compare
systemd.service( | ||
name="Start and enable rspamd", | ||
service="rspamd.service", | ||
name="Start and enable OpenDKIM", | ||
service="opendkim.service", | ||
running=True, | ||
enabled=True, | ||
restarted=rspamd_need_restart, | ||
restarted=opendkim_need_restart, | ||
) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hm, starting the opendkim service during cmdeploy fails for me (on c1):
Jan 23 17:06:42 c1 systemd[1]: Starting opendkim.service - OpenDKIM Milter...
Jan 23 17:06:42 c1 opendkim[359568]: opendkim: milter socket must be specified
Jan 23 17:06:42 c1 opendkim[359568]: (use "-?" for help)
Jan 23 17:06:42 c1 systemd[1]: opendkim.service: Control process exited, code=exited, status=78/CONFIG
Jan 23 17:06:42 c1 systemd[1]: opendkim.service: Failed with result 'exit-code'.
Jan 23 17:06:42 c1 systemd[1]: Failed to start opendkim.service - OpenDKIM Milter.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
But /etc/opendkim.conf
has it:
Socket local:/var/spool/postfix/opendkim/opendkim.sock
The file however does not exist:
ls /var/spool/postfix/opendkim/opendkim.sock
ls: cannot access '/var/spool/postfix/opendkim/opendkim.sock': No such file or directory
Maybe it is created by postfix? Should we maybe reconfigure postfix first so it creates the socket?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I restarted opendkim
with systemctl restart opendkim
, it started and created the socket. :/
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same problem deploying to c2:
...
--> Starting operation: apt install opendkim opendkim-tools
[c2.testrun.org] Success
--> Starting operation: Files/Template (src=/home/user/src/deltachat/chatmail/cmdeploy/src/cmdeploy/opendkim/opendkim.conf, dest=/etc/opendkim.conf, user=root, group=root, mode=644, config={'domain_name': 'c2.testrun.org', 'opendkim_selector': 'opendkim'})
[c2.testrun.org] Success
--> Starting operation: Files/Put (src=/home/user/src/deltachat/chatmail/cmdeploy/src/cmdeploy/opendkim/screen.lua, dest=/etc/opendkim/screen.lua, user=root, group=root, mode=644)
[c2.testrun.org] Success
--> Starting operation: Files/Put (src=/home/user/src/deltachat/chatmail/cmdeploy/src/cmdeploy/opendkim/final.lua, dest=/etc/opendkim/final.lua, user=root, group=root, mode=644)
[c2.testrun.org] Success
--> Starting operation: Add opendkim directory to /etc
[c2.testrun.org] No changes
--> Starting operation: Files/Template (src=/home/user/src/deltachat/chatmail/cmdeploy/src/cmdeploy/opendkim/KeyTable, dest=/etc/dkimkeys/KeyTable, user=opendkim, group=opendkim, mode=644, config={'domain_name': 'c2.testrun.org', 'opendkim_selector': 'opendkim'})
[c2.testrun.org] Success
--> Starting operation: Files/Template (src=/home/user/src/deltachat/chatmail/cmdeploy/src/cmdeploy/opendkim/SigningTable, dest=/etc/dkimkeys/SigningTable, user=opendkim, group=opendkim, mode=644, config={'domain_name': 'c2.testrun.org', 'opendkim_selector': 'opendkim'})
[c2.testrun.org] Success
--> Starting operation: Add opendkim socket directory to /var/spool/postfix
[c2.testrun.org] Success
--> Starting operation: Generate OpenDKIM domain keys
[c2.testrun.org] Success
--> Starting operation: Start and enable OpenDKIM
[c2.testrun.org] Job for opendkim.service failed because the control process exited with error code.
[c2.testrun.org] See "systemctl status opendkim.service" and "journalctl -xeu opendkim.service" for details.
[c2.testrun.org] Error: executed 0/2 commands
--> pyinfra error: No hosts remaining!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Simply running cmdeploy run
second time works, but I cannot figure out why /etc/opendkim.conf
is consistently not found and read the first time.
@missytake I pushed another commit that apparently fixes the bug. Deployed ccc20.testrun.org from main, then deployed this PR. Could you try the same thing on another domain? |
4ffc6b2
to
8b899f3
Compare
Rebased |
sounds good, will try tomorrow... my eyes hurt already^^ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm, a nice simplifying improvement. Didn't test it myself though and also am not sure about the one "you need to run it twice" issue. That probably needs to be addressed before merging.
It is addressed as I commented above, needs someone to test this again by installing a new server using main branch and then deploying this branch on top. |
OpenDKIM configuration has two Lua scripts defining strict DKIM policy. screen.lua filters out signatures that do not correspond to the From: domain so they are not even checked. final.lua rejects mail if it is not outgoing and has no valid DKIM signatures. OpenDKIM is configured as a milter on port 25 smtpd to check DKIM signatures and on mail reinjecting smtpd to sign outgoing messages with DKIM signatures.
8b899f3
to
cfb89ae
Compare
Rebased again to fix conflict in master.cf |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Works :) I first deployed main on c4 and then deployed this PR. A test still expected the old error message, but apart from that it worked.
One thing which could be improved is: printing "please run cmdeploy dns
again, your DKIM setup changed" if apt.packages(packages="rspamd", present=False).changed == True
. That would help admins notice that they need to update their DKIM record, I guess. But it's no blocker.
OpenDKIM configuration
has two Lua scripts defining strict DKIM policy.
screen.lua filters out signatures that do not correspond
to the From: domain so they are not even checked.
final.lua rejects mail if it is not outgoing
and has no valid DKIM signatures.
OpenDKIM is configured as a milter on port 25 smtpd
to check DKIM signatures
and on mail reinjecting smtpd
to sign outgoing messages with DKIM signatures.
Closes #179
Closes #182