Skip to content

Populate relayhost_map from virtual accounts (and other fixes)#1596

Merged
erik-wramner merged 3 commits intomasterfrom
unknown repository
Sep 5, 2020
Merged

Populate relayhost_map from virtual accounts (and other fixes)#1596
erik-wramner merged 3 commits intomasterfrom
unknown repository

Conversation

@ghost
Copy link
Copy Markdown

@ghost ghost commented Aug 24, 2020

I started this branch to enable relaying through virtual account domains (before, only domains found in postfix-accounts.cf and postfix-relaymap.cf were taken into account). I bumped into some bugs along the way so I ended up having to do a bit of fixing and refactoring (see first two commits).

@erik-wramner
Copy link
Copy Markdown
Contributor

I think I will need some time to review this (unless you beat me to it @fbartels). One question though. You start by writing to the checksum file without sleep, but that should already have been done in _setup_chksum_file in the startup script which runs before this script is allowed to start. Moving the write to before the sleep just overwrites the file produced by the startup script.

That is unnecessary work, but it can also hide changes. Assume that there were changes after the startup script ran and before the change script created the file. We would not act on them as the checksum file says that nothing has changed.

In short I'd like to remove that first step and use the file created by the startup script to eliminate the risk for race conditions.

@ghost
Copy link
Copy Markdown
Author

ghost commented Aug 26, 2020 via email

@fbartels fbartels self-requested a review August 27, 2020 06:36
Copy link
Copy Markdown
Member

@fbartels fbartels left a comment

Choose a reason for hiding this comment

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

helper_functions.sh while I'm at it?

yes, sounds like a good idea.

If first glance I could not see anything else, than what was already said about the checksum function. lgtm

mwnx added 3 commits August 28, 2020 14:57
If a change to one of the tracked files happened soon after (<1 second?)
a previously detected change, it could end up going undetected. In
particular, this could cause integration tests to fail (see next
commits).

Fixed by computing the new checksum file _before_ checking for changes.
check-for-changes.sh did not have a special case to handle lines in
postfix-relaymap.cf consisting of only a domain (indicating that said
domain should never be relayed). This case is handled by
start-mailserver.sh so when such a line existed, things would work well
until a config file update was detected by check-for-changes.sh. After
that, the generated relayhost_map file would be corrupted.

Fixed by factoring a 'populate_relayhost_map' function out of
start-mailserver.sh and into helper_functions.sh and reusing it in
check-for-changes.sh.

Note: There are certainly quite a few more pieces of code that could be
refactored in a similar fashion.

Note2: check-for-changes.sh would previously never update the
relayhost_map file when $ENABLE_LDAP was set to 1. I don't think this
was intended —there is after all no such condition in
start-mailserver.sh— and so this condition no longer applies.
Previously, only postfix-relaymap.cf and postfix-accounts.cf would be
used to populate the relayhost_map file.

Now, also use postfix-virtual.cf when present. To me, there is nothing
absurd about sending mail "From:" a virtual account (or more
specifically its domain) so it makes sense that when a $RELAY_HOST is
defined it should be used for virtual accounts as well.
@ghost
Copy link
Copy Markdown
Author

ghost commented Aug 28, 2020

I updated the first commit with the changes we talked about, so it should be ready for merging.

Copy link
Copy Markdown
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.

Looks fine.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants