Quanah Gibson-Mount:
> Apr 22 14:42:50 zqa-061 postfix/trivial-rewrite[30487]: warning: do not
> list domain zqa-061.eng.vmware.com in BOTH mydestination and
> virtual_mailbox_domains
...
> mydestination = localhost
This may happen with any Postfix release when $myhostname is not
listed in mydestination. This Postfix limitation is easy to fix.
The following requires some patience from the reader.
Normal scenario:
As trivial-rewrite resolves (tries to figure out where to
deliver) an email address, it strips off domains that match
$mydestination, and saves the last stripped-off domain.
If this process reduces the address to just a recipient local-part,
then the resolver concludes that the address is in the "local
address class". At that point we have the recipient localpart
and the saved last stripped-off domain that matched $mydestination.
Error scenario:
In rare cases the trivial-rewrite resolver is given a domain-less
address (for example, the null recipient address). In that
case the resolver concludes that the destination is in the
"local address class" (1). And if the recipient local-part is
empty the resolver replaces it with "mailer-daemon".
At that point we have a recipient localpart, but we don't have
a saved last stripped-off domain. However Postfix does not
work with domain-less addresses, so trivial-rewrite uses
$myhostname as a surrogate for the saved last stripped-off
domain (2).
Trivial-rewrite logs the above warning when the surrogate domain
that was chosen in (2) is not in the address class that was chosen
in (1).
The discrepancy is eliminated by re-resolving the recipient localpart
plus surrogate domain, so that it pops out of the resolver with the
correct address class for the surrogate domain.
The patch below maintains full backwards compatibility; if that
were not a concern it would technically be more correct to call
"rewrite_tree(&local_context, tree);" which appends @myorigin,
instead of the two ad-hoc tok822_sub_append() calls that append
@myhostname.
Wietse
*** ./src/trivial-rewrite/resolve.c- Mon Oct 1 16:57:50 2012
--- ./src/trivial-rewrite/resolve.c Tue Apr 23 13:19:28 2013
***************
*** 324,332 ****
tok822_free(tree->head);
tree->head = 0;
}
! /* XXX must be localpart only, not user@domain form. */
! if (tree->head == 0)
tree->head = tok822_scan(var_empty_addr, &tree->tail);
/*
* We're done. There are no domains left to strip off the address,
--- 324,341 ----
tok822_free(tree->head);
tree->head = 0;
}
! /* XXX Re-resolve the surrogate, in case not in user@domain form. */
! if (tree->head == 0) {
tree->head = tok822_scan(var_empty_addr, &tree->tail);
+ continue;
+ }
+
+ /* XXX Re-resolve with myhostname for backwards compatibility. */
+ if (domain == 0 && saved_domain == 0) {
+ tok822_sub_append(tree, tok822_alloc('@', (char *) 0));
+ tok822_sub_append(tree, tok822_scan(var_myhostname, (TOK822 **) 0));
+ continue;
+ }
/*
* We're done. There are no domains left to strip off the address,