Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@polarathene
Copy link
Member

@polarathene polarathene commented Feb 17, 2025

Description

Up to you if you'd like to include this in DMS 15.0 or DMS 15.1. As this is only a change for a setup CLI command, it's not something I'd consider breaking, and functionality wise it should be roughly the same. Tests also seem to indicate all is well 👍


I recently did some refactoring on this command while going over unifying our DKIM feature support.

  • Adds a main() method similar to other setup CLI commands.
  • Help text more aligned with equivalent rspamd DKIM setup CLI command.
  • DRY some repetition such as hard-coded paths to use variables.
  • OpenDKIM config files are created / initialized early on now with _create_opendkim_configs(). while loop only needs to append entries, so is easier to grok.
  • _create_dkim_key() to scope just the logic (and additional notes) to key generation via opendkim-genkey
  • Now overall logic with the while loop of the script occurs in _generate_dkim_keys():
    • Ownership fixes are now applied after the while loop as that seems more appropriate than per iteration.
    • Temporary VHOST config is now removed since it's no longer useful after running.
  • Tests adjusted for one new log for adding of default trusted hosts content.

Overall this should be nicer to grok/maintain. Some of this logic will be reused for the unified DKIM generation command in future, which is more likely to shift towards all domains using the same keypair by default with rspamd/opendkim config generated at runtime rather than reliant upon DMS config volume to provide that (still expected for private key).

Type of change

  • Improvement (non-breaking change that does improve existing functionality)

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
  • New and existing unit tests pass locally with my changes
  • I have added information about changes made in this PR to CHANGELOG.md

@georglauterbach georglauterbach added this to the v15.1.0 milestone Feb 18, 2025
@georglauterbach georglauterbach added service/security/dkim-dmarc-spf kind/improvement Improve an existing feature, configuration file or the documentation labels Feb 18, 2025
@georglauterbach
Copy link
Member

I'd rather not have this in v15.0.0. I marked it appropriately.

@georglauterbach georglauterbach added the meta/feature freeze On hold due to upcoming release process label Feb 18, 2025
@georglauterbach georglauterbach removed the meta/feature freeze On hold due to upcoming release process label Mar 1, 2025
@georglauterbach georglauterbach self-requested a review March 3, 2025 21:17
@georglauterbach
Copy link
Member

I'll take a look at this soon

casperklein
casperklein previously approved these changes Mar 16, 2025
Copy link
Member

@casperklein casperklein left a comment

Choose a reason for hiding this comment

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

Code reviewed, but not tested. LGTM 👍

@polarathene
Copy link
Member Author

polarathene commented Mar 17, 2025

Reminder: Do not merge yet, we still want to release 15.0.1 first.


Bundled in the +set => :- suggestion to other files unrelated to the focus of this PR (😬) at 7eed5d1

No rush to adjust everything right away - this was more of a 'while we're at it' note.

I have done it in this PR since we usually discuss delaying to a future PR but we often don't get back to it 😅 (likely forgotten)

@polarathene polarathene requested a review from casperklein March 17, 2025 20:47
function __initialize_variables() {
function __check_if_set() {
if [[ ${!1+set} != 'set' ]]; then
if [[ -z ${1:-} ]]; then
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
if [[ -z ${1:-} ]]; then
if [[ -z ${!1:-} ]]; then

Without the exclamation mark, you just check, if $1 is not empty.

${!1} is indirect expansion, meaning it retrieves the value of the variable whose name is stored in $1

Copy link
Member Author

Choose a reason for hiding this comment

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

${!1} is indirect expansion, meaning it retrieves the value of the variable whose name is stored in $1

I figured it was something I was going to trip up on 😂 Thanks for spotting that! 🙏

This is the sorta thing that adds friction to attracting more third-party contributions though I think? 🤔

Copy link
Member

Choose a reason for hiding this comment

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

This is the sorta thing that adds friction to attracting more third-party contributions though I think? 🤔

Or it encourage people, to learn something new (in bash). I learned a lot while working on DMS 🚀

Copy link
Member Author

Choose a reason for hiding this comment

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

I learned plenty too, but given the syntax ! / :-, they're not exactly search friendly for a newbie that doesn't know what related keywords to search up.

If we were to swap bash for something else, you've previously expressed reluctance due to the fact you'd have to learn something new... so I don't think that's a particular fair stance 😝

The nushell examples I've shared several snippets of across various discussions is often far more friendly/familiar (or obvious in syntax alone) with equivalent features.


The more friction there is to contribute, the less likely it'll happen. It's often a concern that'll discourage me from contributing to projects for example as I've got enough on my plate to suss out already 😂

Copy link
Member

Choose a reason for hiding this comment

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

I think we had this discussion already, but it does not lead anywhere. I am currently not willing to switch to NuShell. This is not because I think NuShell is inferior (on the contrary, I think it's probably better). But because no one has the time to rewrite this project not can we maintain it efficiently afterward, etc.

Given we went over this with Rust - which I deem to be superior to NuShell for DMS as a whole - we do not need to extend it here.

Copy link
Member Author

Choose a reason for hiding this comment

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

But because no one has the time to rewrite this project not can we maintain it efficiently afterward, etc.

If someone wants to port DMS and maintainers were open to it, that's up to the contributor to handle the rewrite. Bigger issue isn't that contributor time it's the review process, one thing to support a port, another to confidently review something unfamiliar 👍

After that point, I don't think it'd have a negative impact on maintenance tbh.

Given we went over this with Rust - which I deem to be superior to NuShell for DMS as a whole - we do not need to extend it here.

One of the issues with Rust was that it was compile time, rather than the flexibility of an interpreter running arbitrary scripts like bash and python. Nushell was identified as alternative that had perks of rust, but more similar to bash for development without the issues raised with python 😅

Don't mind me though, just an occasional rant about gripes with bash. End of the day there's still two maintainers that are quite comfortable with bash and I am very familiar with our past discussions on the topic, I am just concerned about the bus factor there vs reducing maintenance complexity in a way that more contributors could easily understand what they're reading.

Copy link
Member

Choose a reason for hiding this comment

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

Given we went over this with Rust - which I deem to be superior to NuShell for DMS as a whole - we do not need to extend it here.

One of the issues with Rust was that it was compile time, rather than the flexibility of an interpreter running arbitrary scripts like bash and python. Nushell was identified as alternative that had perks of rust, but more similar to bash for development without the issues raised with python 😅

Agreed, that is indeed an upside! I am sure we can find many upsides, and we could even compare all approaches. But I, too, think that no one will rewrite this any time soon. I am still open, if anyone wants to try :D

casperklein
casperklein previously approved these changes Mar 18, 2025
@georglauterbach georglauterbach added meta/feature freeze On hold due to upcoming release process and removed meta/feature freeze On hold due to upcoming release process labels Mar 22, 2025
Copy link
Member

@georglauterbach georglauterbach left a comment

Choose a reason for hiding this comment

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

LGTM 👍🏼

Needs a rebase, but other than that - nice!

@polarathene
Copy link
Member Author

Bit caught up atm, but I'll rebase and merge after 15.0.2 release once some other tasks I'm juggling are resolved 😓

@polarathene polarathene merged commit 23bb1c8 into master Mar 31, 2025
7 checks passed
@polarathene polarathene deleted the refactor/setup-cli-opendkim branch March 31, 2025 09:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/scripts kind/improvement Improve an existing feature, configuration file or the documentation service/security/dkim-dmarc-spf

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants