FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

scripts: improve DKIM path scanning in Rspamd setup by georglauterbach · Pull Request #4201 · docker-mailserver/docker-mailserver · GitHub

scripts: improve DKIM path scanning in Rspamd setup - #4201

Merged
georglauterbach merged 3 commits into
masterfrom
rspamd-dkim-path-scanning
Sep 29, 2024
Merged

scripts: improve DKIM path scanning in Rspamd setup#4201
georglauterbach merged 3 commits into
masterfrom
rspamd-dkim-path-scanning

Conversation

georglauterbach commented Sep 28, 2024
edited
Loading

Copy link
Copy Markdown
Member

Description

This PR improves the algorithm to scan for DKIM paths in Rspamd'd configuration. Moreover, it fixes a small inconvenience: cp would output "Nothing to copy" because the directory contained no contents; this has been fixed as well.

Fixes #4172

Type of change

  • Bug fix (non-breaking change which fixes an issue)

Checklist

  • My code follows the style guidelines of this project
  • I have performed a self-review of my code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation (README.md or the documentation under docs/)
  • If necessary, I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes
  • I have added information about changes made in this PR to CHANGELOG.md

The new version uses `rspamadm configdump` to more efficiently scan the
`dkim_signing` section for paths. We strip paths that contain "$" and
only print the key path by using "awk".
georglauterbach added area/scripts kind/bug/fix A fix (PR) for a confirmed bug labels Sep 28, 2024
georglauterbach added this to the v15.0.0 milestone Sep 28, 2024
georglauterbach self-assigned this Sep 28, 2024

polarathene commented Sep 28, 2024
edited
Loading

Copy link
Copy Markdown
Member

I'm happy to approve the change, but I do recall suggesting an alternative back in Dec 2023: #3702 (comment)

I've not refreshed myself on the subject, but I did document a way forward here: #3778

If you have the time to have a quick look over that and let me know if that's potentially a better approach, and if it's acceptable for v15 or should be delayed, that'd be good. It may be a bit of a breaking change / inconvenience, but might be worth considering before switching rspamd to the default (which I assume may also be blocked on adopting Valkey to minimize the wider impact of anyone that has been relying on the internal Redis service?).


EDIT: Looks like I added another revision in the related unified DKIM key generation task, that mentions the current rspamd logic extracting path from dkim_signing.conf and how it would differ with the suggested selector_map + path approach (no need to mess with path in scripts like is done presently, so our logic/maintenance should be simpler): #3630 (comment)

polarathene left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

LGTM. Go with this fix for now 🚀

I'd still appreciate your opinion on adopting selector_map in future before rspamd becomes default. That'll probably need some doc changes and migration advice in changelog for existing users, which I know is a hassle 😅 (but getting it in before the release that defaults to rspamd would be good for testing/feedback)

Comment on lines +343 to +344
if find "$(realpath -L "${KEY_FILE}")" \( -user _rspamd -or -group _rspamd -or -perm -o=r \) \
-exec false {} +; then

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Any reason for the line split? Was it just width?

The concern handled here would be a non-issue if the keys were copied to an internal path right?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Any reason for the line split? Was it just width?

Yes :)

The concern handled here would be a non-issue if the keys were copied to an internal path right?

Indeed!

__rspamd__log 'warn' "Rspamd DKIM private key file '${KEY_FILE}' is configured for usage, but does not appear to exist"
fi
done
done < <(rspamadm configdump dkim_signing | grep 'path =' | grep -v -F '$' | awk '{print $3}' | tr -d ';"')

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

So the config has multiple path values to extract and check. It seems with the mentioned selector_map config, none of that would be necessary. All keys would stored with predictable hierarchy:

selector = "mail";
# These paths should technically be internal locations instead,
# with data sourced from the users config volume (/tmp/docker-mailserver):
path = "/tmp/docker-mailserver/rspamd/dkim/keys/$domain/$selector.private";
selector_map = "/tmp/docker-mailserver/rspamd/dkim/selector_map";

The selector_map file then maps domain with a selector:

example.com dkim-example
another-domain.com another-selector

So I think the selector_map config approach would make all of this logic redundant 🤔

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

I would need to have another look at your proposed, in-depth, but I guess you are right, your approach would simplify and unify our setup.

Copy link
Copy Markdown
Member Author

LGTM. Go with this fix for now 🚀

Just a reminder: this PR is a fix for #4172 only, not a rewrite of the DKIM functionality :)

I'd still appreciate your opinion on adopting selector_map in future before rspamd becomes default. That'll probably need some doc changes and migration advice in changelog for existing users, which I know is a hassle 😅 (but getting it in before the release that defaults to rspamd would be good for testing/feedback)

I think you are absolutely right; when I got some time in the future, I will tackle your proposals.

georglauterbach merged commit 3937e1e into master Sep 29, 2024
georglauterbach deleted the rspamd-dkim-path-scanning branch September 29, 2024 10:18
This file contains hidden or 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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/scripts kind/bug/fix A fix (PR) for a confirmed bug

Projects

2 participants


Back | FazBrowse Home | New Git URL