masqmail
changeset 416:ddac877ced95
Fixed the globalias mechanism.
We cannot operate on addr->address because that's the address string how
it was received, we need to use addr->local_part and addr->domain to build
a full address.
author | markus schnalke <meillo@marmaro.de> |
---|---|
date | Wed, 29 Feb 2012 18:14:32 +0100 |
parents | 0430194f7ef8 |
children | 8fedb93e9b72 |
files | src/alias.c |
diffstat | 1 files changed, 19 insertions(+), 16 deletions(-) [+] |
line diff
1.1 --- a/src/alias.c Wed Feb 29 14:36:07 2012 +0100 1.2 +++ b/src/alias.c Wed Feb 29 18:14:32 2012 +0100 1.3 @@ -138,33 +138,39 @@ 1.4 GList *alias_list = NULL; 1.5 GList *alias_node; 1.6 gchar *val; 1.7 + char addrstr[BUFSIZ]; 1.8 + 1.9 + if (doglob) { 1.10 + snprintf(addrstr, sizeof addrstr, "%s@%s", 1.11 + addr->local_part, addr->domain); 1.12 + } else { 1.13 + snprintf(addrstr, sizeof addrstr, "%s", addr->local_part); 1.14 + } 1.15 1.16 /* expand the local alias */ 1.17 DEBUG(6) debugf("alias: '%s' is local and will get expanded\n", 1.18 - doglob ? addr->address : addr->local_part); 1.19 + addrstr); 1.20 1.21 if (doglob) { 1.22 - val = (gchar *) table_find_func(alias_table, addr->address, 1.23 + val = (gchar *) table_find_func(alias_table, addrstr, 1.24 globaliascmp); 1.25 1.26 } else if (strcasecmp(addr->local_part, "postmaster") == 0) { 1.27 /* postmaster must always be matched caseless 1.28 ** see RFC 822 and RFC 5321 */ 1.29 - val = (gchar *) table_find_func(alias_table, addr->local_part, 1.30 + val = (gchar *) table_find_func(alias_table, addrstr, 1.31 strcasecmp); 1.32 } else { 1.33 - val = (gchar *) table_find_func(alias_table, addr->local_part, 1.34 + val = (gchar *) table_find_func(alias_table, addrstr, 1.35 conf.localpartcmp); 1.36 } 1.37 if (!val) { 1.38 DEBUG(5) debugf("alias: '%s' is fully expanded, hence " 1.39 - "completed\n", 1.40 - doglob ? addr->address : addr->local_part); 1.41 + "completed\n", addrstr); 1.42 return g_list_append(NULL, addr); 1.43 } 1.44 1.45 - DEBUG(5) debugf("alias: '%s' -> '%s'\n", 1.46 - doglob ? addr->address : addr->local_part, val); 1.47 + DEBUG(5) debugf("alias: '%s' -> '%s'\n", addrstr, val); 1.48 val_list = parse_list(val); 1.49 alias_list = NULL; 1.50 1.51 @@ -215,7 +221,7 @@ 1.52 /* loop detected, ignore this path */ 1.53 logwrite(LOG_ALERT, "alias: detected loop, " 1.54 "hence ignoring '%s'\n", 1.55 - alias_addr->local_part); 1.56 + alias_addr->address); 1.57 continue; 1.58 } 1.59 alias_addr->parent = addr; 1.60 @@ -249,19 +255,16 @@ 1.61 1.62 addr = (address *) (rcpt_node->data); 1.63 if (addr_is_local(addr)) { 1.64 - DEBUG(5) debugf("alias: (orig rcpt addr) " 1.65 - "expand local '%s'\n", 1.66 - doglob ? addr->address : 1.67 - addr->local_part); 1.68 + DEBUG(5) debugf("alias: expand local '%s' " 1.69 + "(orig rcpt addr)\n", addr->address); 1.70 alias_list = expand_one(alias_table, addr, doglob); 1.71 if (alias_list) { 1.72 done_list = g_list_concat(done_list, 1.73 alias_list); 1.74 } 1.75 } else { 1.76 - DEBUG(5) debugf("alias: (orig rcpt addr) don't " 1.77 - "expand non-local '%s'\n", 1.78 - addr->address); 1.79 + DEBUG(5) debugf("alias: don't expand non-local '%s' " 1.80 + "(orig rcpt addr)\n", addr->address); 1.81 done_list = g_list_append(done_list, addr); 1.82 } 1.83 }