Hi,
while investigation unexpected bounces, I noticed that the unionmap did not
handle errors of submaps properly. If a submap generated an error, the
unionmap would not.
I tested this with an LDAP map, where the LDAP server was *not* reachable.
Configuring virtual_alias_maps as:
virtual_alias_maps = ldap:/etc/postfix/ldap-virtual.cf
would result in '451 Temporary lookup failure', while configuring it as
virtual_alias_maps = unionmap:{ldap:/etc/postfix/ldap-virtual.cf}
would result in '550 Recipient address rejected: User unknown in virtual
alias table'.
The attached patch fixes that, by making the unionmap return the first
error it gets from one of the submaps.
Thanks,
Roel
diff -pruN a/src/util/dict_union.c b/src/util/dict_union.c
--- a/src/util/dict_union.c 2014-10-21 01:53:04.000000000 +0200
+++ b/src/util/dict_union.c 2016-09-15 11:35:47.669767063 +0200
@@ -81,8 +81,11 @@ static const char *dict_union_lookup(DIC
for (cpp = dict_union->map_union->argv; (dict_type_name = *cpp) != 0;
cpp++) {
if ((map = dict_handle(dict_type_name)) == 0)
msg_panic("%s: dictionary \"%s\" not found", myname,
dict_type_name);
- if ((result = dict_get(map, query)) == 0)
- continue;
+ result = dict_get(map, query);
+ if (map->error < 0)
+ DICT_ERR_VAL_RETURN(dict, map->error, 0);
+ if (result == 0)
+ return;
if (VSTRING_LEN(dict_union->re_buf) > 0)
VSTRING_ADDCH(dict_union->re_buf, ',');
vstring_strcat(dict_union->re_buf, result);