Skip to content

Conversation

@polarathene
Copy link
Member

@polarathene polarathene commented Sep 14, 2021

Description

Summary

  • DH params were only provided during setup-stack.sh.
  • We now just do the copy operation in Dockerfile to always have DH params file by default.
  • doveadm in newer versions of Dovecot (community/bullseye) seems to validate Dovecot configs and will fail if setup-stack.sh is not run first (eg when using setup.sh and no existing running container).
  • Some feature disparity, but this was never officially supported / documented, thus not a breaking change IMO.

Problem

setup-stack.sh currently copies the ffdhe4096.pem DH param file when none exists and no custom DH params file is provided by a user. This only applies when initializing a container instance via the default command however..

When you provide another command, such as the setup.sh management ones, and a container instance needs to be started instead of using an existing one, this will not run setup-stack.sh and thus default DH params are not guaranteed.

With our current Dovecot in buster-slim images, this has gone unnoticed as no error is raised. With the community edition of Dovecot that some users replace our shipped version with, or with the newer Dovecot in the bullseye-slim image we want to upgrade to, it seems that doveadm will validate the 10-ssl.conf config, which involves ssl_dh pointing to a file that doesn't exist. doveadm throws an error and refuses to run as a result, even though this file is unnecessary.

Solution

As the cause has been identified, this PR resolves the issue by copying the ffdhe4096.pem to Dovecot and Postfix locations during a build via the Dockerfile.

The DH param handling in setup-stack.sh has been heavily refactored to remove no longer relevant logic, and make it easier to maintain. Commit history of this PR has carefully iterated on this process with relevant commit messages for anyone interested in following the changes made in an easier to grok manner.

Likewise, the related tests were updated and I've opted to combine them all into a single new refactored DRY variant. As ONE_DIR handling was removed from the relevant setup-stack.sh function, the test could also drop testing both states if desired. There is minimal increase in test time from the ONE_DIR handling, so I've left it as-is for now.

Note: While this resolves a failure with bullseye-slim image, the TLS cipher suite test continues to fail on bullseye-slim for other reasons AFAIK (presently investigating).

I do not consider this a breaking change despite some of the changes. The original PR that added the feature added no documentation, and I did several searches through the git repo files to double check. If we don't advertise official support for providing custom DH params, this seems fine.

AFAIK most/all users would have just been using the default supplied DH params (ffdhe4096.pem). Custom DH params is still supported and that has only changed in removing the variant ONE_DIR=1 (mail-state/lib-shared/) directory. The ONE_DIR=0 approach (add custom file to /tmp/docker-mailserver/dhparams.pem) is now the the approach regardles of ONE_DIR setting.

I've not yet added documentation of the feature (eg providing custom params, what are the default params). If you would like that as well with this PR let me know.

Type of change

  • Bug fix (non-breaking change which fixes an issue)
  • Improvement (non-breaking change that does improve existing functionality)
  • This change requires a documentation update

Checklist:

  • My code follows the style guidelines of this project
  • I have performed a self-review of my own 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

This file only exists at the location to be copied to separate `postfix` and `dovecot` locations. `/etc/postfix/shared` seems like an inappropriate location to have been using.
These are effectively the same, did a diff comparison:

- Identified minor inconsistencies and in `_notify` output.
- Parameterized service names and paths.
- Added some comments to better grok the flow.

Next these two methods can be collapsed into a single one with input args to make it DRY.
This only needs to modify the `DH_CUSTOM` path var. More DRY, the conditional branch for `ONE_DIR=0` (else), is kept and shifts it's indentation one level to the left.

I don't see any value in checking the alternative service for dh params file to copy over, so that's now dropped too.
Another conditional check is dropped and the default fallback message for existing DH params file is no longer relevant.

Improved the remaining `_notify` messages. Collapsing the warning into a single logged message also seemed relevant.

Custom provided DH params now use `cp -f` to overwrite the existing default `ffdhe4096.pem` used.
- Normalize whitespace (had mixed indentation of spaces and tabs, and mixed indentation width of 2 and 4 spaces).
- Improved formatting of docker args.
- (default test file) Swapped order of ONE_DIR bool definitions, and `PRIVATE_CONFIG` var duplicated with ONE_DIR suffix instead of recycling the var.
- Updated the grep tests checking docker logs for warning message.
This feature was introduced by the PR: docker-mailserver#1463

There is no official documented support for custom DH parameters. As no guarantee is provided, this is considered an internal change, not a breaking one.

There is no apparent need for special handling with `ONE_DIR=1`.
Now DRY and ready to merge the other two DH param tests into.
@georglauterbach
Copy link
Member

I'd love to see a bit of documentation on this :) Other than that, LGTM 👍🏼

@polarathene
Copy link
Member Author

I'd love to see a bit of documentation on this

Sure, I'll sort that out after I figure out the other bullseye failure with TLS tests.

@polarathene
Copy link
Member Author

Test failure can be ignored, fixed by the v10.2 release setup.sh change.


Lint errors to address:

  1. DH_DEFAULT_CHECKSUM="$(sha512sum ${DH_DEFAULT_PARAMS} | awk '{print $1}')" => "SC2086: Double quote to prevent globbing and word splitting."
  2. DMS_ONE_DIR=0 => "SC2030: Modification of DMS_ONE_DIR is local (to subshell caused by @BATS test)."
  3. -v "${PRIVATE_CONFIG}:/tmp/docker-mailserver" => "SC2031: PRIVATE_CONFIG was modified in a subshell. That change might be lost."

These 3 ShellCheck failures seem like they should be ignored?

  • 1st one I have no clue how to fix since it's already wrapping the $() (subshell?) with double quotes.
  • The last two are due to how bats works AFAIK and non-issue.

@georglauterbach
Copy link
Member

LGTM. I addressed the linting problems with comments above. Note that GitHub now has a "batch" feature with which you can commit multiple suggestions at once.

@casperklein
Copy link
Member

Very nice simplification of our DH parameter stuff! I was not able to find anything to complain 😉 Just waiting till Georgs suggestion are applied, to approve this PR 👍

Copy link
Member

@wernerfred wernerfred left a comment

Choose a reason for hiding this comment

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

LGTM 👍🏻 well done

Co-authored-by: Georg Lauterbach <[email protected]>
Copy link
Member Author

@polarathene polarathene left a comment

Choose a reason for hiding this comment

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

I'll need to apply the other lint corrections (same lint issues raised on similar lines). Then docs will follow.

@polarathene polarathene marked this pull request as draft September 14, 2021 21:34
Additionally updates the acme RFC URL to what it now redirects to.
@polarathene polarathene force-pushed the fix/enable-default-dhparams branch from 1742ccf to ca49f9d Compare September 14, 2021 23:20
@polarathene polarathene marked this pull request as ready for review September 14, 2021 23:22
@github-actions
Copy link
Contributor

Documentation preview for this PR is ready! 🎉

Built with commit: bbedf5f

Copy link
Member

@wernerfred wernerfred left a comment

Choose a reason for hiding this comment

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

@polarathene polarathene merged commit 08cd4d3 into docker-mailserver:master Sep 15, 2021
@polarathene
Copy link
Member Author

The failing action is due to missing setup.sh changes right?

Correct :)

Almost got another PR ready that is intended for 10.2 release. So that issue should be taken care of soon enough.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants