Closed ian-abbott closed 1 year ago
There is a bit too much pointer arithmetic and confusing logic flow in there for my current taste.
I think we should start by stating what behavior we want regarding masquerade and address.
Clearly the current code (and the proposed change) are agglomerated ad-hoc code, which makes it hard to reason about.
I think we should start by stating what behavior we want regarding masquerade and address.
I think what's documented already in dma.8 is reasonable.
-f sender
Set sender address (envelope-from) to sender. This over‐
rides the value of the EMAIL environment variable, but is
overridden by the ‘MASQUERADE’ config file setting.
and
If ‘MASQUERADE’ does not contain a @ sign, the string is
interpreted as a host name. For example, setting ‘MASQUERADE’ to
‘john@’ on host ‘hamlet’ will send all mails as ‘john@hamlet’;
setting it to ‘percolator’ will send all mails as
‘username@percolator’.
We could do this (and I think the PR does something very similar):
select (incomplete) address (highest priority first):
-f
argEMAIL
envNow split this address into user and host components.
If host is empty, use hostname, set elsewhere
Now apply masquerade:
Now reassemble address and return it.
It feels more intuitive to apply the masquerade last ("overriding") than interspersed with the user and host selection.
What do you think?
I have an improved PR #117 more in line with the comments above.
This PR is stale now that PR #117 has been merged, so closing it.
This allows a MASQUERADE config setting containing only a host name to override any host name set by the -f command line option or by the EMAIL environment variable. Previously, that only worked if the MASQUERADE config setting also overrode the user name.
Fixes #114