masqmail
diff src/conf.c @ 317:55b7bde95d37
reworked allowed and denied addrs for routes
The following refactorings had been made:
- allowed_mail_locals + allowed_return_paths -> allowed_senders
- not_allowed_mail_locals + not_allowed_return_paths -> denied_senders
- allowed_rcpt_domains -> allowed_recipients
- not_allowed_rcpt_domains -> denied_recipients
The new options allow more consistent and more flexible matching.
author | meillo@marmaro.de |
---|---|
date | Thu, 28 Apr 2011 09:55:06 +0200 |
parents | e230bcd0f1c6 |
children | d41fb3b9ed3e |
line diff
1.1 --- a/src/conf.c Mon Apr 25 15:17:30 2011 +0200 1.2 +++ b/src/conf.c Thu Apr 28 09:55:06 2011 +0200 1.3 @@ -142,8 +142,14 @@ 1.4 return list; 1.5 } 1.6 1.7 +/* Split the addrs at '@' into local_part and domain. Without an '@' 1.8 + everything is local_part. Create address structs, which are put 1.9 + into a list and returned. 1.10 + This funktion is used for lists of addrs containing globbing chars (* and ?). 1.11 + We don't need valid RFC821 addresses here, just patterns to match against. 1.12 +*/ 1.13 static GList* 1.14 -parse_address_list(gchar * line, gboolean read_file) 1.15 +parse_address_glob_list(gchar * line, gboolean read_file) 1.16 { 1.17 GList *plain_list = parse_list(line, read_file); 1.18 GList *node; 1.19 @@ -151,13 +157,32 @@ 1.20 1.21 foreach(plain_list, node) { 1.22 gchar *item = (gchar *) (node->data); 1.23 - address *addr = create_address(item, TRUE); 1.24 - if (addr) 1.25 - list = g_list_append(list, addr); 1.26 + char* at; 1.27 + char* p; 1.28 + address *addr = calloc(1, sizeof(address)); 1.29 + 1.30 + for (p=item+strlen(item)-1; isspace(*p) || *p=='>'; p--) { 1.31 + *p = '\0'; 1.32 + } 1.33 + for (p=item; isspace(*p) || *p=='<'; p++) { 1.34 + } 1.35 + 1.36 + addr->address = strdup(p); 1.37 + at = strrchr(p, '@'); 1.38 + if (at) { 1.39 + *at = '\0'; 1.40 + addr->local_part = strdup(p); 1.41 + addr->domain = strdup(at+1); 1.42 + } else { 1.43 + addr->local_part = strdup(p); 1.44 + addr->domain = ""; 1.45 + } 1.46 + list = g_list_append(list, addr); 1.47 + DEBUG(6) debugf("parse_address_glob_list: read pattern `%s' `%s'\n", 1.48 + addr->local_part, addr->domain); 1.49 g_free(item); 1.50 } 1.51 g_list_free(plain_list); 1.52 - 1.53 return list; 1.54 } 1.55 1.56 @@ -648,18 +673,16 @@ 1.57 route->instant_helo = parse_boolean(rval); 1.58 else if (strcmp(lval, "do_pipelining") == 0) 1.59 route->do_pipelining = parse_boolean(rval); 1.60 - else if (strcmp(lval, "allowed_return_paths") == 0) 1.61 - route->allowed_return_paths = parse_address_list(rval, TRUE); 1.62 - else if (strcmp(lval, "allowed_mail_locals") == 0) 1.63 - route->allowed_mail_locals = parse_list(rval, TRUE); 1.64 - else if (strcmp(lval, "not_allowed_return_paths") == 0) 1.65 - route->not_allowed_return_paths = parse_address_list(rval, TRUE); 1.66 - else if (strcmp(lval, "not_allowed_mail_locals") == 0) 1.67 - route->not_allowed_mail_locals = parse_list(rval, TRUE); 1.68 - else if (strcmp(lval, "allowed_rcpt_domains") == 0) 1.69 - route->allowed_rcpt_domains = parse_list(rval, TRUE); 1.70 - else if (strcmp(lval, "not_allowed_rcpt_domains") == 0) 1.71 - route->not_allowed_rcpt_domains = parse_list(rval, TRUE); 1.72 + 1.73 + else if (strcmp(lval, "allowed_senders") == 0) 1.74 + route->allowed_senders = parse_address_glob_list(rval, TRUE); 1.75 + else if (strcmp(lval, "denied_senders") == 0) 1.76 + route->denied_senders = parse_address_glob_list(rval, TRUE); 1.77 + else if (strcmp(lval, "allowed_recipients") == 0) 1.78 + route->allowed_recipients = parse_address_glob_list(rval, TRUE); 1.79 + else if (strcmp(lval, "denied_recipients") == 0) 1.80 + route->denied_recipients = parse_address_glob_list(rval, TRUE); 1.81 + 1.82 else if (strcmp(lval, "set_h_from_domain") == 0) 1.83 route->set_h_from_domain = g_strdup(rval); 1.84 else if (strcmp(lval, "set_h_reply_to_domain") == 0) 1.85 @@ -808,10 +831,10 @@ 1.86 g_free(r->wrapper); 1.87 if (r->helo_name) 1.88 g_free(r->helo_name); 1.89 - _g_list_free_all(r->allowed_mail_locals); 1.90 - _g_list_free_all(r->not_allowed_mail_locals); 1.91 - _g_list_free_all(r->allowed_rcpt_domains); 1.92 - _g_list_free_all(r->not_allowed_rcpt_domains); 1.93 + _g_list_free_all(r->allowed_senders); 1.94 + _g_list_free_all(r->denied_senders); 1.95 + _g_list_free_all(r->allowed_recipients); 1.96 + _g_list_free_all(r->denied_recipients); 1.97 if (r->set_h_from_domain) 1.98 g_free(r->set_h_from_domain); 1.99 if (r->set_h_reply_to_domain)