Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Conversation

polarathene
Copy link
Member

@polarathene polarathene commented Jan 28, 2024

Description

While revising the docs on this feature, I was reminded how frustratingly awkward the current implementation is 😮‍💨

So I've detoured to make some changes there:

  • relay.sh: Much better maintainer comments + simplified logic + fixes.
  • Partially contributes towards [TODO]: Refactor Relay host support #3607
  • Minor revisions to check-for-changes.sh + postfix.sh, primarily VHOST_UPDATED addition + comment revisions.
  • Additionally allows DEFAULT_RELAY_HOST to support credentials without redundantly needing RELAY_HOST, which should better help cater to this recent use-case bug report (the opposite, RELAY_HOST when set enforced credentials).

Changes have been staged out into scoped commits with individual commit messages for added context. If you want an easier set of diffs to review through, that'd be a nicer experience to work through 👍

Two other docs pages for the relay host feature will be revised as a separate follow-up PR.

Context

Type of change

  • Bug fix (non-breaking change which fixes an issue)
  • Improvement (non-breaking change that does improve existing functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • 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
  • I have added information about changes made in this PR to CHANGELOG.md

@polarathene polarathene added service/postfix area/scripts area/features kind/improvement Improve an existing feature, configuration file or the documentation kind/bug/fix A fix (PR) for a confirmed bug labels Jan 28, 2024
@polarathene polarathene added this to the v14.0.0 milestone Jan 28, 2024
@polarathene polarathene self-assigned this Jan 28, 2024
The functionality is effectively the same for the two configs for the most part when it comes to parsing out a domain from the target value.

Virtual aliases is more flexible in value, which may not have a domain-part present (manual user edit).
@polarathene polarathene force-pushed the docs/refactor-relayhosts-feature branch from 012815c to 366da36 Compare January 28, 2024 22:30
- Moves the "handle changes" logic into it's own scoped function, out of the main change detection loop logic.
- This will be benefit a future commit change that will rely on `VHOST_UPDATED=1`.
- Better phrasing of the current logic comments.
- Regex patterns assigned to variables (easier to grok intention)
- Bulk of the logic for generating `/etc/postfix/relayhost_map` wrapped into a separate function with Postfix config setting handled separately.
- Split the two distinct features that configure `/etc/postfix/relayhost_map` into separate functions (_`MATCH_VALID` var no longer needed for legacy support_).
- Instead of extracting domains from `postfix-accounts.cf` + `postfix-virtual.cf`, this has already been handled at `/etc/postfix/vhost`, sourcing from there is far less complicated.
- Rename loop var `DOMAIN_PART`to `SENDER_DOMAIN` for better context of what it represents when appended to the config file.
- Revised maintenance notes + guidance towards a future refactor of this relayhost feature support.
- Remove comment regarding `smtp_sasl_password_maps = static:${RELAY_USER}:${RELAY_PASSWORD}`, it could be used but `main.cf` presently has `644` permissions vs the `sasl_passwd` file permissions of `600`, less secure at preventing leaking of secrets (ignoring the ENV exposure itself).
- Move the `main.cf` settings specific to relayhost credentials support / security into to the relevant function scope instead. This also allows for the configuration to be applied by a change detection event without container restart requirement.
- Outer functions for setup and change detection to call have a clearer config dependency guard, as does the `_legacy_support()`.
- These changes now support `DEFAULT_RELAY_HOST` to leverage the relay credentials ENV as well.
- `DATABASE_RELAYHOSTS` is available in scope to the functions called here that reference it.
@polarathene polarathene force-pushed the docs/refactor-relayhosts-feature branch from 366da36 to 02ec9d7 Compare January 28, 2024 23:18
@polarathene
Copy link
Member Author

polarathene commented Jan 28, 2024

If necessary I have added tests that prove my fix is effective or that my feature works

Tests are a bit lacking for this feature presently, although I'm fairly confident the PR isn't doing anything not covered in the changelog.

target/scripts/helpers/relay.sh Outdated Show resolved Hide resolved
docs/content/config/environment.md Show resolved Hide resolved
target/scripts/helpers/postfix.sh Show resolved Hide resolved
@polarathene
Copy link
Member Author

ENV docs visual comparison

Before

image

After

image

@georglauterbach
Copy link
Member

I will review in an hour or so 🚀

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.

Overall LGTM 👍🏼 Much cleaner to read now! I have some nitpicks in the scripts for you to address still :)

target/scripts/helpers/postfix.sh Outdated Show resolved Hide resolved
target/scripts/helpers/postfix.sh Outdated Show resolved Hide resolved
target/scripts/helpers/postfix.sh Outdated Show resolved Hide resolved
target/scripts/helpers/relay.sh Outdated Show resolved Hide resolved
target/scripts/helpers/relay.sh Outdated Show resolved Hide resolved
target/scripts/helpers/relay.sh Outdated Show resolved Hide resolved
target/scripts/helpers/relay.sh Outdated Show resolved Hide resolved
target/scripts/helpers/relay.sh Outdated Show resolved Hide resolved
target/scripts/helpers/relay.sh Show resolved Hide resolved
Co-authored-by: Georg Lauterbach <44545919+georglauterbach@users.noreply.github.com>
@polarathene

This comment was marked as resolved.

@georglauterbach

This comment was marked as resolved.

target/scripts/helpers/relay.sh Outdated Show resolved Hide resolved
Copy link
Contributor

Documentation preview for this PR is ready! 🎉

Built with commit: 59f5638

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

Labels

area/features area/scripts kind/bug/fix A fix (PR) for a confirmed bug kind/improvement Improve an existing feature, configuration file or the documentation service/postfix

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants

Morty Proxy This is a proxified and sanitized view of the page, visit original site.