annotate src/alias.c @ 89:a917cb178ca7

what about the `rmail' alias?
author meillo@marmaro.de
date Sat, 19 Jun 2010 19:00:04 +0200 (2010-06-19)
parents a8f3424347dc
children a80ebfa16cd5
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
08114f7dcc23 this is masqmail-0.2.21 from oliver kurth
meillo@marmaro.de
parents:
diff changeset
1 /* MasqMail
08114f7dcc23 this is masqmail-0.2.21 from oliver kurth
meillo@marmaro.de
parents:
diff changeset
2 Copyright (C) 2000-2001 Oliver Kurth
08114f7dcc23 this is masqmail-0.2.21 from oliver kurth
meillo@marmaro.de
parents:
diff changeset
3
08114f7dcc23 this is masqmail-0.2.21 from oliver kurth
meillo@marmaro.de
parents:
diff changeset
4 This program is free software; you can redistribute it and/or modify
08114f7dcc23 this is masqmail-0.2.21 from oliver kurth
meillo@marmaro.de
parents:
diff changeset
5 it under the terms of the GNU General Public License as published by
08114f7dcc23 this is masqmail-0.2.21 from oliver kurth
meillo@marmaro.de
parents:
diff changeset
6 the Free Software Foundation; either version 2 of the License, or
08114f7dcc23 this is masqmail-0.2.21 from oliver kurth
meillo@marmaro.de
parents:
diff changeset
7 (at your option) any later version.
08114f7dcc23 this is masqmail-0.2.21 from oliver kurth
meillo@marmaro.de
parents:
diff changeset
8
08114f7dcc23 this is masqmail-0.2.21 from oliver kurth
meillo@marmaro.de
parents:
diff changeset
9 This program is distributed in the hope that it will be useful,
08114f7dcc23 this is masqmail-0.2.21 from oliver kurth
meillo@marmaro.de
parents:
diff changeset
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
08114f7dcc23 this is masqmail-0.2.21 from oliver kurth
meillo@marmaro.de
parents:
diff changeset
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
08114f7dcc23 this is masqmail-0.2.21 from oliver kurth
meillo@marmaro.de
parents:
diff changeset
12 GNU General Public License for more details.
08114f7dcc23 this is masqmail-0.2.21 from oliver kurth
meillo@marmaro.de
parents:
diff changeset
13
08114f7dcc23 this is masqmail-0.2.21 from oliver kurth
meillo@marmaro.de
parents:
diff changeset
14 You should have received a copy of the GNU General Public License
08114f7dcc23 this is masqmail-0.2.21 from oliver kurth
meillo@marmaro.de
parents:
diff changeset
15 along with this program; if not, write to the Free Software
08114f7dcc23 this is masqmail-0.2.21 from oliver kurth
meillo@marmaro.de
parents:
diff changeset
16 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
08114f7dcc23 this is masqmail-0.2.21 from oliver kurth
meillo@marmaro.de
parents:
diff changeset
17 */
08114f7dcc23 this is masqmail-0.2.21 from oliver kurth
meillo@marmaro.de
parents:
diff changeset
18
08114f7dcc23 this is masqmail-0.2.21 from oliver kurth
meillo@marmaro.de
parents:
diff changeset
19 #include "masqmail.h"
08114f7dcc23 this is masqmail-0.2.21 from oliver kurth
meillo@marmaro.de
parents:
diff changeset
20 #include <fnmatch.h>
08114f7dcc23 this is masqmail-0.2.21 from oliver kurth
meillo@marmaro.de
parents:
diff changeset
21
10
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
22 gboolean
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
23 addr_is_local(address * addr)
0
08114f7dcc23 this is masqmail-0.2.21 from oliver kurth
meillo@marmaro.de
parents:
diff changeset
24 {
10
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
25 GList *dom_node;
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
26 GList *addr_node;
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
27 address *a;
0
08114f7dcc23 this is masqmail-0.2.21 from oliver kurth
meillo@marmaro.de
parents:
diff changeset
28
10
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
29 foreach(conf.local_hosts, dom_node) {
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
30 if (addr->domain == NULL)
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
31 return TRUE;
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
32 if (fnmatch(dom_node->data, addr->domain, FNM_CASEFOLD) == 0) {
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
33 foreach(conf.not_local_addresses, addr_node) {
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
34 a = create_address_qualified(addr_node->data, TRUE, conf.host_name);
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
35 if (addr_isequal(a, addr)) {
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
36 destroy_address(a);
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
37 return FALSE;
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
38 }
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
39 destroy_address(a);
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
40 }
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
41 return TRUE;
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
42 }
0
08114f7dcc23 this is masqmail-0.2.21 from oliver kurth
meillo@marmaro.de
parents:
diff changeset
43 }
10
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
44 foreach(conf.local_addresses, addr_node) {
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
45 a = create_address_qualified(addr_node->data, TRUE, conf.host_name);
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
46 if (addr_isequal(a, addr)) {
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
47 destroy_address(a);
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
48 return TRUE;
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
49 }
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
50 destroy_address(a);
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
51 }
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
52 return FALSE;
0
08114f7dcc23 this is masqmail-0.2.21 from oliver kurth
meillo@marmaro.de
parents:
diff changeset
53 }
08114f7dcc23 this is masqmail-0.2.21 from oliver kurth
meillo@marmaro.de
parents:
diff changeset
54
10
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
55 static gboolean
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
56 addr_isequal_alias(address * addr1, address * addr2)
0
08114f7dcc23 this is masqmail-0.2.21 from oliver kurth
meillo@marmaro.de
parents:
diff changeset
57 {
10
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
58 return (conf.alias_local_cmp(addr1->local_part, addr2->local_part) == 0)
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
59 && (strcasecmp(addr1->domain, addr2->domain) == 0);
0
08114f7dcc23 this is masqmail-0.2.21 from oliver kurth
meillo@marmaro.de
parents:
diff changeset
60 }
08114f7dcc23 this is masqmail-0.2.21 from oliver kurth
meillo@marmaro.de
parents:
diff changeset
61
10
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
62 static GList*
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
63 parse_list(gchar * line)
0
08114f7dcc23 this is masqmail-0.2.21 from oliver kurth
meillo@marmaro.de
parents:
diff changeset
64 {
10
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
65 GList *list = NULL;
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
66 gchar buf[256];
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
67 gchar *p, *q;
0
08114f7dcc23 this is masqmail-0.2.21 from oliver kurth
meillo@marmaro.de
parents:
diff changeset
68
10
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
69 p = line;
14
a8f3424347dc replaced number 0 with character \0 where appropriate
meillo@marmaro.de
parents: 10
diff changeset
70 while (*p != '\0') {
10
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
71 q = buf;
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
72 while (isspace(*p))
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
73 p++;
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
74 if (*p != '\"') {
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
75 while (*p && (*p != ',') && (q < buf + 255))
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
76 *(q++) = *(p++);
14
a8f3424347dc replaced number 0 with character \0 where appropriate
meillo@marmaro.de
parents: 10
diff changeset
77 *q = '\0';
10
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
78 } else {
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
79 gboolean escape = FALSE;
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
80 p++;
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
81 while (*p && (*p != '\"' || escape) && (q < buf + 255)) {
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
82 if ((*p == '\\') && !escape)
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
83 escape = TRUE;
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
84 else {
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
85 escape = FALSE;
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
86 *(q++) = *p;
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
87 }
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
88 p++;
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
89 }
14
a8f3424347dc replaced number 0 with character \0 where appropriate
meillo@marmaro.de
parents: 10
diff changeset
90 *q = '\0';
10
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
91 while (*p && (*p != ','))
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
92 p++;
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
93 }
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
94 list = g_list_append(list, g_strdup(g_strchomp(buf)));
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
95 if (*p)
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
96 p++;
0
08114f7dcc23 this is masqmail-0.2.21 from oliver kurth
meillo@marmaro.de
parents:
diff changeset
97 }
10
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
98 return list;
0
08114f7dcc23 this is masqmail-0.2.21 from oliver kurth
meillo@marmaro.de
parents:
diff changeset
99 }
08114f7dcc23 this is masqmail-0.2.21 from oliver kurth
meillo@marmaro.de
parents:
diff changeset
100
10
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
101 GList*
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
102 alias_expand(GList * alias_table, GList * rcpt_list, GList * non_rcpt_list)
0
08114f7dcc23 this is masqmail-0.2.21 from oliver kurth
meillo@marmaro.de
parents:
diff changeset
103 {
10
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
104 GList *done_list = NULL;
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
105 GList *rcpt_node = g_list_copy(rcpt_list);
0
08114f7dcc23 this is masqmail-0.2.21 from oliver kurth
meillo@marmaro.de
parents:
diff changeset
106
10
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
107 while (rcpt_node != NULL) {
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
108 address *addr = (address *) (rcpt_node->data);
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
109 DEBUG(5) debugf("alias_expand begin: '%s@%s'\n", addr->local_part, addr->domain);
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
110 /* if(addr_is_local(addr) && (addr->local_part[0] != '|') && */
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
111 if (addr_is_local(addr) && !(addr->flags & ADDR_FLAG_NOEXPAND)) {
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
112 gchar *val;
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
113
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
114 /* special handling for postmaster */
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
115 if (strcasecmp(addr->local_part, "postmaster") == 0)
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
116 val = (gchar *) table_find_func(alias_table, addr->local_part, strcasecmp);
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
117 else
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
118 val = (gchar *) table_find_func(alias_table, addr->local_part, conf.alias_local_cmp);
0
08114f7dcc23 this is masqmail-0.2.21 from oliver kurth
meillo@marmaro.de
parents:
diff changeset
119
10
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
120 DEBUG(5) debugf("alias: '%s' is local\n", addr->local_part);
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
121 if (val != NULL) {
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
122 GList *val_list = parse_list(val);
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
123 GList *val_node;
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
124 GList *alias_list = NULL;
0
08114f7dcc23 this is masqmail-0.2.21 from oliver kurth
meillo@marmaro.de
parents:
diff changeset
125
10
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
126 DEBUG(5) debugf("alias: '%s' -> '%s'\n", addr->local_part, val);
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
127 foreach(val_list, val_node) {
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
128 gchar *val = (gchar *) (val_node->data);
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
129 address *alias_addr;
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
130 address *addr_parent = NULL;
0
08114f7dcc23 this is masqmail-0.2.21 from oliver kurth
meillo@marmaro.de
parents:
diff changeset
131
10
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
132 if (val[0] == '|') {
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
133 DEBUG(5) debugf("alias: %s is a pipe address\n", val);
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
134 alias_addr = create_address_pipe(val);
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
135 DEBUG(5) debugf("alias_pipe: %s is a pipe address\n", alias_addr->local_part);
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
136 } else if (val[0] == '\\') {
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
137 DEBUG(5) debugf("alias: shall not be expanded: '%s'\n", val);
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
138 alias_addr = create_address_qualified(&(val[1]), TRUE, conf.host_name);
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
139 alias_addr->flags |= ADDR_FLAG_NOEXPAND;
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
140 DEBUG(5) debugf("alias: not expanded: '%s'\n", alias_addr->local_part);
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
141 } else {
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
142 alias_addr = create_address_qualified(val, TRUE, conf.host_name);
0
08114f7dcc23 this is masqmail-0.2.21 from oliver kurth
meillo@marmaro.de
parents:
diff changeset
143
10
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
144 /* search in parents for loops: */
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
145 for (addr_parent = addr; addr_parent; addr_parent = addr_parent->parent) {
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
146 if (addr_isequal_alias (alias_addr, addr_parent)) {
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
147 logwrite(LOG_ALERT,
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
148 "detected alias loop, (ignoring): %s@%s -> %s@%s\n",
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
149 addr_parent->local_part,
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
150 addr_parent->domain,
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
151 addr->local_part, addr->domain);
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
152 break;
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
153 }
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
154 }
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
155 }
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
156 if (!addr_parent) {
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
157 alias_list = g_list_append(alias_list, alias_addr);
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
158 alias_addr->parent = addr;
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
159 }
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
160 g_free(val);
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
161 }
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
162 g_list_free(val_list);
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
163 addr->children = g_list_copy(alias_list);
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
164 rcpt_node = g_list_concat(rcpt_node, alias_list);
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
165 } else {
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
166 DEBUG(5) debugf("alias: '%s' is completed\n", addr->local_part);
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
167 done_list = g_list_append(done_list, addr);
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
168 }
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
169 } else {
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
170 DEBUG(5) debugf("alias: '%s@%s' is not local\n", addr->local_part, addr->domain);
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
171 done_list = g_list_append(done_list, addr);
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
172 }
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
173 rcpt_node = g_list_next(rcpt_node);
0
08114f7dcc23 this is masqmail-0.2.21 from oliver kurth
meillo@marmaro.de
parents:
diff changeset
174 }
10
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
175
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
176 /* delete addresses from done_list if they are in the non_rcpt_list */
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
177 if (non_rcpt_list) {
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
178 GList *rcpt_node_next;
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
179 for (rcpt_node = g_list_first(done_list); rcpt_node; rcpt_node = rcpt_node_next) {
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
180 address *addr = (address *) (rcpt_node->data);
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
181 GList *non_node;
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
182
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
183 rcpt_node_next = g_list_next(rcpt_node);
0
08114f7dcc23 this is masqmail-0.2.21 from oliver kurth
meillo@marmaro.de
parents:
diff changeset
184
10
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
185 foreach(non_rcpt_list, non_node) {
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
186 address *non_addr = (address *) (non_node->data);
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
187 if (addr_isequal(addr, non_addr)) {
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
188 done_list = g_list_remove_link(done_list, rcpt_node);
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
189 g_list_free_1(rcpt_node);
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
190 addr_mark_delivered(addr); /* this address is still in the children lists of the original address */
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
191 break;
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
192 }
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
193 }
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
194 }
0
08114f7dcc23 this is masqmail-0.2.21 from oliver kurth
meillo@marmaro.de
parents:
diff changeset
195 }
10
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
196 return done_list;
0
08114f7dcc23 this is masqmail-0.2.21 from oliver kurth
meillo@marmaro.de
parents:
diff changeset
197 }