masqmail

diff src/alias.c @ 242:bc9d9cd9ee8e

made addr_isequal() and addr_isequal_parent() more flexible refactored various bits of this stuff. addr_isequal_alias() had become needless now and was removed. In fail_msg.c: postmaster is now matched caseless, like required by RFC.
author markus schnalke <meillo@marmaro.de>
date Mon, 25 Oct 2010 17:42:48 -0300
parents 31ee44f45787
children 7082044c05c6
line diff
     1.1 --- a/src/alias.c	Mon Oct 25 15:41:48 2010 -0300
     1.2 +++ b/src/alias.c	Mon Oct 25 17:42:48 2010 -0300
     1.3 @@ -40,7 +40,7 @@
     1.4  			a = create_address_qualified(addr_node->data, TRUE, conf.host_name);
     1.5  			DEBUG(6) debugf("not_local_addresses: addr_node->data=%s a->address=%s\n",
     1.6  			                addr_node->data, a->address);
     1.7 -			if (addr_isequal(a, addr)) {
     1.8 +			if (addr_isequal(a, addr, conf.alias_local_cmp)) {
     1.9  				destroy_address(a);
    1.10  				/* in local_hosts but also in not_local_addresses */
    1.11  				return FALSE;
    1.12 @@ -54,7 +54,7 @@
    1.13  		a = create_address_qualified(addr_node->data, TRUE, conf.host_name);
    1.14  		DEBUG(6) debugf("local_addresses: addr_node->data=%s a->address=%s\n",
    1.15  		                addr_node->data, a->address);
    1.16 -		if (addr_isequal(a, addr)) {
    1.17 +		if (addr_isequal(a, addr, conf.alias_local_cmp)) {
    1.18  			destroy_address(a);
    1.19  			/* in local_addresses */
    1.20  			return TRUE;
    1.21 @@ -64,13 +64,6 @@
    1.22  	return FALSE;
    1.23  }
    1.24  
    1.25 -static gboolean
    1.26 -addr_isequal_alias(address * addr1, address * addr2)
    1.27 -{
    1.28 -	return (conf.alias_local_cmp(addr1->local_part, addr2->local_part) == 0)
    1.29 -	       && (strcasecmp(addr1->domain, addr2->domain) == 0);
    1.30 -}
    1.31 -
    1.32  static GList*
    1.33  parse_list(gchar * line)
    1.34  {
    1.35 @@ -180,18 +173,12 @@
    1.36  			continue;
    1.37  		}
    1.38  
    1.39 -		/* addr is local, so let's go into recursion and expand again,
    1.40 -		   but first ...  search in parents for loops: */
    1.41 -		for (addr_parent=addr; addr_parent; addr_parent=addr_parent->parent) {
    1.42 -			if (addr_isequal_alias(alias_addr, addr_parent)) {
    1.43 -				break;
    1.44 -			}
    1.45 -		}
    1.46 -		if (addr_parent) {
    1.47 +		/* addr is local and to expand at this point */
    1.48 +		/* but first ... search in parents for loops: */
    1.49 +		if (addr_isequal_parent(addr, alias_addr, conf.alias_local_cmp)) {
    1.50  			/* loop detected, ignore this path */
    1.51 -			logwrite(LOG_ALERT,
    1.52 -			         "alias: detected loop (%s -> %s), hence ignoring\n",
    1.53 -			         addr_parent->local_part, addr->local_part);
    1.54 +			logwrite(LOG_ALERT, "alias: detected loop, hence ignoring '%s'\n",
    1.55 +			         alias_addr->local_part);
    1.56  			continue;
    1.57  		}
    1.58  		alias_addr->parent = addr;
    1.59 @@ -251,7 +238,7 @@
    1.60  		rcpt_node_next = g_list_next(rcpt_node);
    1.61  		foreach(non_rcpt_list, non_node) {
    1.62  			address *non_addr = (address *) (non_node->data);
    1.63 -			if (addr_isequal(addr, non_addr)) {
    1.64 +			if (addr_isequal(addr, non_addr, conf.alias_local_cmp)) {
    1.65  				done_list = g_list_remove_link(done_list, rcpt_node);
    1.66  				g_list_free_1(rcpt_node);
    1.67  				/* this address is still in the children lists