Mercurial > masqmail
annotate src/route.c @ 348:a7a387253b2f
Argument of read_queue() was unused, thus removed
author | markus schnalke <meillo@marmaro.de> |
---|---|
date | Thu, 14 Jul 2011 11:31:52 +0200 |
parents | 257ffce6c1cd |
children | ddb7b3fd3d08 |
rev | line source |
---|---|
0 | 1 /* MasqMail |
2 Copyright (C) 1999-2001 Oliver Kurth | |
241
87df0aa99cc7
added myself to the copyright notice of route.c
markus schnalke <meillo@marmaro.de>
parents:
237
diff
changeset
|
3 Copyright (C) 2010 markus schnalke <meillo@marmaro.de> |
0 | 4 |
5 This program is free software; you can redistribute it and/or modify | |
6 it under the terms of the GNU General Public License as published by | |
7 the Free Software Foundation; either version 2 of the License, or | |
8 (at your option) any later version. | |
9 | |
10 This program is distributed in the hope that it will be useful, | |
11 but WITHOUT ANY WARRANTY; without even the implied warranty of | |
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
13 GNU General Public License for more details. | |
14 | |
15 You should have received a copy of the GNU General Public License | |
16 along with this program; if not, write to the Free Software | |
17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | |
18 */ | |
19 | |
15 | 20 #include <fnmatch.h> |
21 | |
0 | 22 #include "masqmail.h" |
23 | |
10
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
24 msgout_perhost* |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
25 create_msgout_perhost(gchar * host) |
0 | 26 { |
10
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
27 msgout_perhost *mo_ph = g_malloc(sizeof(msgout_perhost)); |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
28 if (mo_ph) { |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
29 mo_ph->host = g_strdup(host); |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
30 mo_ph->msgout_list = NULL; |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
31 } |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
32 return mo_ph; |
0 | 33 } |
34 | |
10
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
35 void |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
36 destroy_msgout_perhost(msgout_perhost * mo_ph) |
0 | 37 { |
10
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
38 GList *mo_node; |
0 | 39 |
10
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
40 foreach(mo_ph->msgout_list, mo_node) { |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
41 msg_out *mo = (msg_out *) (mo_node->data); |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
42 /* the rcpt_list is owned by the msgout's, but not the rcpt's themselves */ |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
43 g_list_free(mo->rcpt_list); |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
44 g_free(mo); |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
45 } |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
46 g_list_free(mo_ph->msgout_list); |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
47 g_free(mo_ph); |
0 | 48 } |
49 | |
10
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
50 void |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
51 rewrite_headers(msg_out * msgout, connect_route * route) |
0 | 52 { |
10
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
53 /* if set_h_from_domain is set, replace domain in all |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
54 From: headers. |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
55 */ |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
56 msgout->hdr_list = g_list_copy(msgout->msg->hdr_list); |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
57 |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
58 /* map from addresses */ |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
59 if (route->map_h_from_addresses != NULL) { |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
60 GList *hdr_node; |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
61 foreach(msgout->hdr_list, hdr_node) { |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
62 header *hdr = (header *) (hdr_node->data); |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
63 if (hdr->id == HEAD_FROM) { |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
64 header *new_hdr = copy_header(hdr); |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
65 if (map_address_header(new_hdr, route->map_h_from_addresses)) { |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
66 hdr_node->data = new_hdr; |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
67 /* we need this list only to carefully free the extra headers: */ |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
68 msgout->xtra_hdr_list = g_list_append(msgout->xtra_hdr_list, new_hdr); |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
69 } else |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
70 g_free(new_hdr); |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
71 } |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
72 } |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
73 } else { |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
74 /* replace from domain */ |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
75 if (route->set_h_from_domain != NULL) { |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
76 GList *hdr_node; |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
77 |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
78 foreach(msgout->hdr_list, hdr_node) { |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
79 header *hdr = (header *) (hdr_node->data); |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
80 if (hdr->id == HEAD_FROM) { |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
81 header *new_hdr = copy_header(hdr); |
0 | 82 |
10
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
83 DEBUG(5) debugf("setting From: domain to %s\n", route->set_h_from_domain); |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
84 if (set_address_header_domain(new_hdr, route->set_h_from_domain)) { |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
85 hdr_node->data = new_hdr; |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
86 /* we need this list only to carefully free the extra headers: */ |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
87 DEBUG(6) debugf("header = %s\n", new_hdr->header); |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
88 msgout->xtra_hdr_list = g_list_append(msgout->xtra_hdr_list, new_hdr); |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
89 } else { |
15 | 90 logwrite(LOG_ALERT, "error in set_address_header_domain(%s, %s)\n", |
91 new_hdr->value, route->set_h_from_domain); | |
10
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
92 } |
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 } |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
95 } |
0 | 96 } |
10
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
97 |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
98 /* map reply-to addresses */ |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
99 if (route->map_h_reply_to_addresses != NULL) { |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
100 GList *hdr_node; |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
101 foreach(msgout->hdr_list, hdr_node) { |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
102 header *hdr = (header *) (hdr_node->data); |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
103 if (hdr->id == HEAD_REPLY_TO) { |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
104 header *new_hdr = copy_header(hdr); |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
105 if (map_address_header |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
106 (new_hdr, route->map_h_reply_to_addresses)) { |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
107 hdr_node->data = new_hdr; |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
108 /* we need this list only to carefully free the extra headers: */ |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
109 msgout->xtra_hdr_list = g_list_append(msgout->xtra_hdr_list, new_hdr); |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
110 } else |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
111 g_free(new_hdr); |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
112 } |
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 } else { |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
115 /* replace Reply-to domain */ |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
116 if (route->set_h_reply_to_domain != NULL) { |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
117 GList *hdr_node; |
0 | 118 |
10
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
119 foreach(msgout->hdr_list, hdr_node) { |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
120 header *hdr = (header *) (hdr_node->data); |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
121 if (hdr->id == HEAD_REPLY_TO) { |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
122 header *new_hdr = copy_header(hdr); |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
123 |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
124 set_address_header_domain(new_hdr, route-> set_h_reply_to_domain); |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
125 hdr_node->data = new_hdr; |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
126 /* we need this list only to carefully free the extra headers: */ |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
127 msgout->xtra_hdr_list = g_list_append(msgout->xtra_hdr_list, new_hdr); |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
128 } |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
129 } |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
130 } |
0 | 131 } |
10
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
132 |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
133 /* map Mail-Followup-To addresses */ |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
134 if (route->map_h_mail_followup_to_addresses != NULL) { |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
135 GList *hdr_node; |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
136 foreach(msgout->hdr_list, hdr_node) { |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
137 header *hdr = (header *) (hdr_node->data); |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
138 if (strncasecmp(hdr->header, "Mail-Followup-To", 16) == 0) { |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
139 header *new_hdr = copy_header(hdr); |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
140 if (map_address_header(new_hdr, route->map_h_mail_followup_to_addresses)) { |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
141 hdr_node->data = new_hdr; |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
142 /* we need this list only to carefully free the extra headers: */ |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
143 msgout->xtra_hdr_list = g_list_append(msgout->xtra_hdr_list, new_hdr); |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
144 } else |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
145 g_free(new_hdr); |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
146 } |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
147 } |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
148 } |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
149 |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
150 /* set Sender: domain to return_path->domain */ |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
151 if (route->expand_h_sender_domain) { |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
152 GList *hdr_node; |
0 | 153 |
10
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
154 foreach(msgout->hdr_list, hdr_node) { |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
155 header *hdr = (header *) (hdr_node->data); |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
156 if (hdr->id == HEAD_SENDER) { |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
157 header *new_hdr = copy_header(hdr); |
0 | 158 |
10
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
159 set_address_header_domain(new_hdr, msgout->return_path->domain); |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
160 hdr_node->data = new_hdr; |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
161 /* we need this list only to carefully free the extra headers: */ |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
162 msgout->xtra_hdr_list = g_list_append(msgout->xtra_hdr_list, new_hdr); |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
163 } |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
164 } |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
165 } |
0 | 166 |
10
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
167 /* set Sender: domain to return_path->domain */ |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
168 if (route->expand_h_sender_address) { |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
169 GList *hdr_node; |
0 | 170 |
10
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
171 foreach(msgout->hdr_list, hdr_node) { |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
172 header *hdr = (header *) (hdr_node->data); |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
173 if (hdr->id == HEAD_SENDER) { |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
174 header *new_hdr; |
0 | 175 |
15 | 176 new_hdr = create_header(HEAD_SENDER, "Sender: %s@%s\n", |
177 msgout->return_path->local_part, msgout->return_path->domain); | |
10
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
178 hdr_node->data = new_hdr; |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
179 /* we need this list only to carefully free the extra headers: */ |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
180 msgout->xtra_hdr_list = g_list_append(msgout->xtra_hdr_list, new_hdr); |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
181 } |
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 } |
0 | 184 |
10
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
185 if (msgout->xtra_hdr_list == NULL) { |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
186 /* nothing was changed */ |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
187 g_list_free(msgout->hdr_list); |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
188 msgout->hdr_list = NULL; |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
189 } |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
190 DEBUG(5) debugf("rewrite_headers() returning\n"); |
0 | 191 } |
192 | |
237
5f9f3a65032e
refactoring: new function split_rcpts() replaces two others
markus schnalke <meillo@marmaro.de>
parents:
114
diff
changeset
|
193 /* |
5f9f3a65032e
refactoring: new function split_rcpts() replaces two others
markus schnalke <meillo@marmaro.de>
parents:
114
diff
changeset
|
194 Split a recipient list into the three groups: |
5f9f3a65032e
refactoring: new function split_rcpts() replaces two others
markus schnalke <meillo@marmaro.de>
parents:
114
diff
changeset
|
195 - local recipients |
5f9f3a65032e
refactoring: new function split_rcpts() replaces two others
markus schnalke <meillo@marmaro.de>
parents:
114
diff
changeset
|
196 - local net recipients |
5f9f3a65032e
refactoring: new function split_rcpts() replaces two others
markus schnalke <meillo@marmaro.de>
parents:
114
diff
changeset
|
197 - other/remote/online recipients |
5f9f3a65032e
refactoring: new function split_rcpts() replaces two others
markus schnalke <meillo@marmaro.de>
parents:
114
diff
changeset
|
198 It should be possible to call the function like: |
5f9f3a65032e
refactoring: new function split_rcpts() replaces two others
markus schnalke <meillo@marmaro.de>
parents:
114
diff
changeset
|
199 split_rcpts(rcpts, hostlist, local, others, others); |
5f9f3a65032e
refactoring: new function split_rcpts() replaces two others
markus schnalke <meillo@marmaro.de>
parents:
114
diff
changeset
|
200 This would split online between local and localnet+online recipients. |
5f9f3a65032e
refactoring: new function split_rcpts() replaces two others
markus schnalke <meillo@marmaro.de>
parents:
114
diff
changeset
|
201 (untested yet; remove this line if you saw it worked -- meillo 2010-10-21) |
5f9f3a65032e
refactoring: new function split_rcpts() replaces two others
markus schnalke <meillo@marmaro.de>
parents:
114
diff
changeset
|
202 If host_list is NULL, only splitting between local and other is done. |
5f9f3a65032e
refactoring: new function split_rcpts() replaces two others
markus schnalke <meillo@marmaro.de>
parents:
114
diff
changeset
|
203 */ |
10
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
204 void |
237
5f9f3a65032e
refactoring: new function split_rcpts() replaces two others
markus schnalke <meillo@marmaro.de>
parents:
114
diff
changeset
|
205 split_rcpts(GList* rcpt_list, GList* localnets, GList** rl_local, GList** rl_localnet, GList** rl_others) |
0 | 206 { |
10
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
207 GList *rcpt_node; |
237
5f9f3a65032e
refactoring: new function split_rcpts() replaces two others
markus schnalke <meillo@marmaro.de>
parents:
114
diff
changeset
|
208 GList *host_node = NULL; |
5f9f3a65032e
refactoring: new function split_rcpts() replaces two others
markus schnalke <meillo@marmaro.de>
parents:
114
diff
changeset
|
209 address *rcpt = NULL; |
0 | 210 |
10
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
211 if (rcpt_list == NULL) |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
212 return; |
0 | 213 |
10
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
214 foreach(rcpt_list, rcpt_node) { |
237
5f9f3a65032e
refactoring: new function split_rcpts() replaces two others
markus schnalke <meillo@marmaro.de>
parents:
114
diff
changeset
|
215 rcpt = (address *) (rcpt_node->data); |
5f9f3a65032e
refactoring: new function split_rcpts() replaces two others
markus schnalke <meillo@marmaro.de>
parents:
114
diff
changeset
|
216 host_node = NULL; |
0 | 217 |
10
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
218 if (addr_is_local(rcpt)) { |
237
5f9f3a65032e
refactoring: new function split_rcpts() replaces two others
markus schnalke <meillo@marmaro.de>
parents:
114
diff
changeset
|
219 if (rl_local) |
5f9f3a65032e
refactoring: new function split_rcpts() replaces two others
markus schnalke <meillo@marmaro.de>
parents:
114
diff
changeset
|
220 *rl_local = g_list_append(*rl_local, rcpt); |
10
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
221 } else { |
237
5f9f3a65032e
refactoring: new function split_rcpts() replaces two others
markus schnalke <meillo@marmaro.de>
parents:
114
diff
changeset
|
222 /* if localnets is NULL, host_node will be NULL, |
5f9f3a65032e
refactoring: new function split_rcpts() replaces two others
markus schnalke <meillo@marmaro.de>
parents:
114
diff
changeset
|
223 hence all non-locals are put to others */ |
5f9f3a65032e
refactoring: new function split_rcpts() replaces two others
markus schnalke <meillo@marmaro.de>
parents:
114
diff
changeset
|
224 foreach(localnets, host_node) { |
5f9f3a65032e
refactoring: new function split_rcpts() replaces two others
markus schnalke <meillo@marmaro.de>
parents:
114
diff
changeset
|
225 gchar *host = (gchar *) (host_node->data); |
5f9f3a65032e
refactoring: new function split_rcpts() replaces two others
markus schnalke <meillo@marmaro.de>
parents:
114
diff
changeset
|
226 if (fnmatch(host, rcpt->domain, FNM_CASEFOLD) == 0) |
5f9f3a65032e
refactoring: new function split_rcpts() replaces two others
markus schnalke <meillo@marmaro.de>
parents:
114
diff
changeset
|
227 break; |
5f9f3a65032e
refactoring: new function split_rcpts() replaces two others
markus schnalke <meillo@marmaro.de>
parents:
114
diff
changeset
|
228 } |
5f9f3a65032e
refactoring: new function split_rcpts() replaces two others
markus schnalke <meillo@marmaro.de>
parents:
114
diff
changeset
|
229 if (host_node) { |
5f9f3a65032e
refactoring: new function split_rcpts() replaces two others
markus schnalke <meillo@marmaro.de>
parents:
114
diff
changeset
|
230 if (rl_localnet) |
5f9f3a65032e
refactoring: new function split_rcpts() replaces two others
markus schnalke <meillo@marmaro.de>
parents:
114
diff
changeset
|
231 *rl_localnet = g_list_append(*rl_localnet, rcpt); |
5f9f3a65032e
refactoring: new function split_rcpts() replaces two others
markus schnalke <meillo@marmaro.de>
parents:
114
diff
changeset
|
232 } else { |
5f9f3a65032e
refactoring: new function split_rcpts() replaces two others
markus schnalke <meillo@marmaro.de>
parents:
114
diff
changeset
|
233 if (rl_others) |
5f9f3a65032e
refactoring: new function split_rcpts() replaces two others
markus schnalke <meillo@marmaro.de>
parents:
114
diff
changeset
|
234 *rl_others = g_list_append(*rl_others, rcpt); |
5f9f3a65032e
refactoring: new function split_rcpts() replaces two others
markus schnalke <meillo@marmaro.de>
parents:
114
diff
changeset
|
235 } |
10
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
236 } |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
237 } |
0 | 238 } |
239 | |
345
257ffce6c1cd
added local_rcpts() and remote_rcpts() for later use
markus schnalke <meillo@marmaro.de>
parents:
317
diff
changeset
|
240 /* |
257ffce6c1cd
added local_rcpts() and remote_rcpts() for later use
markus schnalke <meillo@marmaro.de>
parents:
317
diff
changeset
|
241 Return a new list of the local rcpts in the rcpt_list |
257ffce6c1cd
added local_rcpts() and remote_rcpts() for later use
markus schnalke <meillo@marmaro.de>
parents:
317
diff
changeset
|
242 TODO: This function is almost exactly the same as remote_rcpts(). Merge? |
257ffce6c1cd
added local_rcpts() and remote_rcpts() for later use
markus schnalke <meillo@marmaro.de>
parents:
317
diff
changeset
|
243 */ |
257ffce6c1cd
added local_rcpts() and remote_rcpts() for later use
markus schnalke <meillo@marmaro.de>
parents:
317
diff
changeset
|
244 GList* |
257ffce6c1cd
added local_rcpts() and remote_rcpts() for later use
markus schnalke <meillo@marmaro.de>
parents:
317
diff
changeset
|
245 local_rcpts(GList* rcpt_list) |
257ffce6c1cd
added local_rcpts() and remote_rcpts() for later use
markus schnalke <meillo@marmaro.de>
parents:
317
diff
changeset
|
246 { |
257ffce6c1cd
added local_rcpts() and remote_rcpts() for later use
markus schnalke <meillo@marmaro.de>
parents:
317
diff
changeset
|
247 GList *rcpt_node; |
257ffce6c1cd
added local_rcpts() and remote_rcpts() for later use
markus schnalke <meillo@marmaro.de>
parents:
317
diff
changeset
|
248 GList *local_rcpts = NULL; |
257ffce6c1cd
added local_rcpts() and remote_rcpts() for later use
markus schnalke <meillo@marmaro.de>
parents:
317
diff
changeset
|
249 address *rcpt = NULL; |
257ffce6c1cd
added local_rcpts() and remote_rcpts() for later use
markus schnalke <meillo@marmaro.de>
parents:
317
diff
changeset
|
250 |
257ffce6c1cd
added local_rcpts() and remote_rcpts() for later use
markus schnalke <meillo@marmaro.de>
parents:
317
diff
changeset
|
251 if (!rcpt_list) { |
257ffce6c1cd
added local_rcpts() and remote_rcpts() for later use
markus schnalke <meillo@marmaro.de>
parents:
317
diff
changeset
|
252 return NULL; |
257ffce6c1cd
added local_rcpts() and remote_rcpts() for later use
markus schnalke <meillo@marmaro.de>
parents:
317
diff
changeset
|
253 } |
257ffce6c1cd
added local_rcpts() and remote_rcpts() for later use
markus schnalke <meillo@marmaro.de>
parents:
317
diff
changeset
|
254 foreach(rcpt_list, rcpt_node) { |
257ffce6c1cd
added local_rcpts() and remote_rcpts() for later use
markus schnalke <meillo@marmaro.de>
parents:
317
diff
changeset
|
255 rcpt = (address *) (rcpt_node->data); |
257ffce6c1cd
added local_rcpts() and remote_rcpts() for later use
markus schnalke <meillo@marmaro.de>
parents:
317
diff
changeset
|
256 if (addr_is_local(rcpt)) { |
257ffce6c1cd
added local_rcpts() and remote_rcpts() for later use
markus schnalke <meillo@marmaro.de>
parents:
317
diff
changeset
|
257 local_rcpts = g_list_append(local_rcpts, rcpt); |
257ffce6c1cd
added local_rcpts() and remote_rcpts() for later use
markus schnalke <meillo@marmaro.de>
parents:
317
diff
changeset
|
258 } |
257ffce6c1cd
added local_rcpts() and remote_rcpts() for later use
markus schnalke <meillo@marmaro.de>
parents:
317
diff
changeset
|
259 } |
257ffce6c1cd
added local_rcpts() and remote_rcpts() for later use
markus schnalke <meillo@marmaro.de>
parents:
317
diff
changeset
|
260 return local_rcpts; |
257ffce6c1cd
added local_rcpts() and remote_rcpts() for later use
markus schnalke <meillo@marmaro.de>
parents:
317
diff
changeset
|
261 } |
257ffce6c1cd
added local_rcpts() and remote_rcpts() for later use
markus schnalke <meillo@marmaro.de>
parents:
317
diff
changeset
|
262 |
257ffce6c1cd
added local_rcpts() and remote_rcpts() for later use
markus schnalke <meillo@marmaro.de>
parents:
317
diff
changeset
|
263 /* |
257ffce6c1cd
added local_rcpts() and remote_rcpts() for later use
markus schnalke <meillo@marmaro.de>
parents:
317
diff
changeset
|
264 Return a new list of non-local rcpts in the rcpt_list |
257ffce6c1cd
added local_rcpts() and remote_rcpts() for later use
markus schnalke <meillo@marmaro.de>
parents:
317
diff
changeset
|
265 TODO: This function is almost exactly the same as local_rcpts(). Merge? |
257ffce6c1cd
added local_rcpts() and remote_rcpts() for later use
markus schnalke <meillo@marmaro.de>
parents:
317
diff
changeset
|
266 */ |
257ffce6c1cd
added local_rcpts() and remote_rcpts() for later use
markus schnalke <meillo@marmaro.de>
parents:
317
diff
changeset
|
267 GList* |
257ffce6c1cd
added local_rcpts() and remote_rcpts() for later use
markus schnalke <meillo@marmaro.de>
parents:
317
diff
changeset
|
268 remote_rcpts(GList* rcpt_list) |
257ffce6c1cd
added local_rcpts() and remote_rcpts() for later use
markus schnalke <meillo@marmaro.de>
parents:
317
diff
changeset
|
269 { |
257ffce6c1cd
added local_rcpts() and remote_rcpts() for later use
markus schnalke <meillo@marmaro.de>
parents:
317
diff
changeset
|
270 GList *rcpt_node; |
257ffce6c1cd
added local_rcpts() and remote_rcpts() for later use
markus schnalke <meillo@marmaro.de>
parents:
317
diff
changeset
|
271 GList *remote_rcpts = NULL; |
257ffce6c1cd
added local_rcpts() and remote_rcpts() for later use
markus schnalke <meillo@marmaro.de>
parents:
317
diff
changeset
|
272 address *rcpt = NULL; |
257ffce6c1cd
added local_rcpts() and remote_rcpts() for later use
markus schnalke <meillo@marmaro.de>
parents:
317
diff
changeset
|
273 |
257ffce6c1cd
added local_rcpts() and remote_rcpts() for later use
markus schnalke <meillo@marmaro.de>
parents:
317
diff
changeset
|
274 if (!rcpt_list) { |
257ffce6c1cd
added local_rcpts() and remote_rcpts() for later use
markus schnalke <meillo@marmaro.de>
parents:
317
diff
changeset
|
275 return NULL; |
257ffce6c1cd
added local_rcpts() and remote_rcpts() for later use
markus schnalke <meillo@marmaro.de>
parents:
317
diff
changeset
|
276 } |
257ffce6c1cd
added local_rcpts() and remote_rcpts() for later use
markus schnalke <meillo@marmaro.de>
parents:
317
diff
changeset
|
277 foreach(rcpt_list, rcpt_node) { |
257ffce6c1cd
added local_rcpts() and remote_rcpts() for later use
markus schnalke <meillo@marmaro.de>
parents:
317
diff
changeset
|
278 rcpt = (address *) (rcpt_node->data); |
257ffce6c1cd
added local_rcpts() and remote_rcpts() for later use
markus schnalke <meillo@marmaro.de>
parents:
317
diff
changeset
|
279 if (!addr_is_local(rcpt)) { |
257ffce6c1cd
added local_rcpts() and remote_rcpts() for later use
markus schnalke <meillo@marmaro.de>
parents:
317
diff
changeset
|
280 remote_rcpts = g_list_append(remote_rcpts, rcpt); |
257ffce6c1cd
added local_rcpts() and remote_rcpts() for later use
markus schnalke <meillo@marmaro.de>
parents:
317
diff
changeset
|
281 } |
257ffce6c1cd
added local_rcpts() and remote_rcpts() for later use
markus schnalke <meillo@marmaro.de>
parents:
317
diff
changeset
|
282 } |
257ffce6c1cd
added local_rcpts() and remote_rcpts() for later use
markus schnalke <meillo@marmaro.de>
parents:
317
diff
changeset
|
283 return remote_rcpts; |
257ffce6c1cd
added local_rcpts() and remote_rcpts() for later use
markus schnalke <meillo@marmaro.de>
parents:
317
diff
changeset
|
284 } |
257ffce6c1cd
added local_rcpts() and remote_rcpts() for later use
markus schnalke <meillo@marmaro.de>
parents:
317
diff
changeset
|
285 |
10
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
286 static gint |
317
55b7bde95d37
reworked allowed and denied addrs for routes
meillo@marmaro.de
parents:
241
diff
changeset
|
287 _g_list_addrcmp(gconstpointer pattern, gconstpointer addr) |
0 | 288 { |
317
55b7bde95d37
reworked allowed and denied addrs for routes
meillo@marmaro.de
parents:
241
diff
changeset
|
289 int res; |
55b7bde95d37
reworked allowed and denied addrs for routes
meillo@marmaro.de
parents:
241
diff
changeset
|
290 address* patternaddr = (address*) pattern; |
55b7bde95d37
reworked allowed and denied addrs for routes
meillo@marmaro.de
parents:
241
diff
changeset
|
291 address* stringaddr = (address*) addr; |
55b7bde95d37
reworked allowed and denied addrs for routes
meillo@marmaro.de
parents:
241
diff
changeset
|
292 |
55b7bde95d37
reworked allowed and denied addrs for routes
meillo@marmaro.de
parents:
241
diff
changeset
|
293 DEBUG(6) debugf("_g_list_addrcmp: pattern `%s' `%s' on string `%s' `%s'\n", |
55b7bde95d37
reworked allowed and denied addrs for routes
meillo@marmaro.de
parents:
241
diff
changeset
|
294 patternaddr->local_part, patternaddr->domain, |
55b7bde95d37
reworked allowed and denied addrs for routes
meillo@marmaro.de
parents:
241
diff
changeset
|
295 stringaddr->local_part, stringaddr->domain); |
55b7bde95d37
reworked allowed and denied addrs for routes
meillo@marmaro.de
parents:
241
diff
changeset
|
296 /* TODO: check if we should match here dependent on caseless_matching */ |
55b7bde95d37
reworked allowed and denied addrs for routes
meillo@marmaro.de
parents:
241
diff
changeset
|
297 res = fnmatch(patternaddr->local_part, stringaddr->local_part, 0); |
55b7bde95d37
reworked allowed and denied addrs for routes
meillo@marmaro.de
parents:
241
diff
changeset
|
298 if (res != 0) { |
55b7bde95d37
reworked allowed and denied addrs for routes
meillo@marmaro.de
parents:
241
diff
changeset
|
299 DEBUG(6) debugf("_g_list_addrcmp: ... failed on local_part\n"); |
55b7bde95d37
reworked allowed and denied addrs for routes
meillo@marmaro.de
parents:
241
diff
changeset
|
300 return res; |
55b7bde95d37
reworked allowed and denied addrs for routes
meillo@marmaro.de
parents:
241
diff
changeset
|
301 } |
55b7bde95d37
reworked allowed and denied addrs for routes
meillo@marmaro.de
parents:
241
diff
changeset
|
302 res = fnmatch(patternaddr->domain, stringaddr->domain, FNM_CASEFOLD); |
55b7bde95d37
reworked allowed and denied addrs for routes
meillo@marmaro.de
parents:
241
diff
changeset
|
303 DEBUG(6) debugf("_g_list_addrcmp: ... %s\n", (res==0) ? "matched" : "failed on domain"); |
55b7bde95d37
reworked allowed and denied addrs for routes
meillo@marmaro.de
parents:
241
diff
changeset
|
304 return res; |
0 | 305 } |
306 | |
10
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
307 gboolean |
317
55b7bde95d37
reworked allowed and denied addrs for routes
meillo@marmaro.de
parents:
241
diff
changeset
|
308 route_sender_is_allowed(connect_route * route, address * ret_path) |
0 | 309 { |
317
55b7bde95d37
reworked allowed and denied addrs for routes
meillo@marmaro.de
parents:
241
diff
changeset
|
310 if (route->denied_senders && g_list_find_custom(route->denied_senders, ret_path, _g_list_addrcmp)) { |
55b7bde95d37
reworked allowed and denied addrs for routes
meillo@marmaro.de
parents:
241
diff
changeset
|
311 return FALSE; |
10
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
312 } |
317
55b7bde95d37
reworked allowed and denied addrs for routes
meillo@marmaro.de
parents:
241
diff
changeset
|
313 if (route->allowed_senders) { |
55b7bde95d37
reworked allowed and denied addrs for routes
meillo@marmaro.de
parents:
241
diff
changeset
|
314 if (g_list_find_custom(route->allowed_senders, ret_path, _g_list_addrcmp)) { |
10
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
315 return TRUE; |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
316 } else { |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
317 return FALSE; |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
318 } |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
319 } |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
320 return TRUE; |
0 | 321 } |
322 | |
10
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
323 /* |
0 | 324 Make lists of matching/not matching rcpts. |
325 Local domains are NOT regared here, these should be sorted out previously | |
326 */ | |
10
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
327 void |
317
55b7bde95d37
reworked allowed and denied addrs for routes
meillo@marmaro.de
parents:
241
diff
changeset
|
328 route_split_rcpts(connect_route * route, GList * rcpt_list, GList ** p_rcpt_list, GList ** p_non_rcpt_list) |
0 | 329 { |
10
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
330 GList *tmp_list = NULL; |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
331 /* sort out those domains that can be sent over this connection: */ |
317
55b7bde95d37
reworked allowed and denied addrs for routes
meillo@marmaro.de
parents:
241
diff
changeset
|
332 if (route->allowed_recipients) { |
55b7bde95d37
reworked allowed and denied addrs for routes
meillo@marmaro.de
parents:
241
diff
changeset
|
333 DEBUG(5) debugf("testing for route->allowed_recipients\n"); |
55b7bde95d37
reworked allowed and denied addrs for routes
meillo@marmaro.de
parents:
241
diff
changeset
|
334 split_rcpts(rcpt_list, route->allowed_recipients, NULL, &tmp_list, p_non_rcpt_list); |
10
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
335 } else { |
317
55b7bde95d37
reworked allowed and denied addrs for routes
meillo@marmaro.de
parents:
241
diff
changeset
|
336 DEBUG(5) debugf("route->allowed_recipients == NULL\n"); |
10
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
337 tmp_list = g_list_copy(rcpt_list); |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
338 } |
0 | 339 |
10
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
340 /* sort out those domains that cannot be sent over this connection: */ |
317
55b7bde95d37
reworked allowed and denied addrs for routes
meillo@marmaro.de
parents:
241
diff
changeset
|
341 split_rcpts(tmp_list, route->denied_recipients, NULL, p_non_rcpt_list, p_rcpt_list); |
10
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
342 g_list_free(tmp_list); |
0 | 343 } |
344 | |
10
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
345 msg_out* |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
346 route_prepare_msgout(connect_route * route, msg_out * msgout) |
0 | 347 { |
10
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
348 message *msg = msgout->msg; |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
349 GList *rcpt_list = msgout->rcpt_list; |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
350 |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
351 if (rcpt_list != NULL) { |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
352 /* found a few */ |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
353 DEBUG(5) { |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
354 GList *node; |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
355 debugf("rcpts for routed delivery, route = %s, id = %s\n", route->name, msg->uid); |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
356 foreach(rcpt_list, node) { |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
357 address *rcpt = (address *) (node->data); |
114 | 358 debugf(" rcpt for routed delivery: <%s@%s>\n", |
359 rcpt->local_part, rcpt->domain); | |
10
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
360 } |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
361 } |
0 | 362 |
15 | 363 /* rewrite return path if there is a table, use that |
10
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
364 if an address is found and if it has a domain, use that |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
365 */ |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
366 if (route->map_return_path_addresses) { |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
367 address *ret_path = NULL; |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
368 DEBUG(5) debugf("looking up %s in map_return_path_addresses\n", msg->return_path->local_part); |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
369 ret_path = (address *) table_find_fnmatch(route->map_return_path_addresses, msg->return_path->local_part); |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
370 if (ret_path) { |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
371 DEBUG(5) debugf("found <%s@%s>\n", ret_path->local_part, ret_path->domain); |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
372 if (ret_path->domain == NULL) |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
373 ret_path->domain = route->set_return_path_domain |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
374 ? route->set_return_path_domain |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
375 : msg->return_path->domain; |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
376 msgout->return_path = copy_address(ret_path); |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
377 } |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
378 } |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
379 if (msgout->return_path == NULL) { |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
380 DEBUG(5) debugf("setting return path to %s\n", route->set_return_path_domain); |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
381 msgout->return_path = copy_modify_address(msg->return_path, NULL, route->set_return_path_domain); |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
382 } |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
383 rewrite_headers(msgout, route); |
0 | 384 |
10
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
385 return msgout; |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
386 } |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
387 return NULL; |
0 | 388 } |
389 | |
390 /* put msgout's is msgout_list into bins (msgout_perhost structs) for each | |
391 host. Used if there is no mail_host. | |
392 route param is not used, we leave it here because that may change. | |
393 */ | |
394 | |
10
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
395 GList* |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
396 route_msgout_list(connect_route * route, GList * msgout_list) |
0 | 397 { |
10
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
398 GList *mo_ph_list = NULL; |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
399 GList *msgout_node; |
0 | 400 |
10
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
401 foreach(msgout_list, msgout_node) { |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
402 msg_out *msgout = (msg_out *) (msgout_node->data); |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
403 msg_out *msgout_new; |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
404 GList *rcpt_list = msgout->rcpt_list; |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
405 GList *rcpt_node; |
0 | 406 |
10
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
407 foreach(rcpt_list, rcpt_node) { |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
408 address *rcpt = rcpt_node->data; |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
409 msgout_perhost *mo_ph = NULL; |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
410 GList *mo_ph_node = NULL; |
0 | 411 |
10
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
412 /* search host in mo_ph_list */ |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
413 foreach(mo_ph_list, mo_ph_node) { |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
414 mo_ph = (msgout_perhost *) (mo_ph_node->data); |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
415 if (strcasecmp(mo_ph->host, rcpt->domain) == 0) |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
416 break; |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
417 } |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
418 if (mo_ph_node != NULL) { |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
419 /* there is already a rcpt for this host */ |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
420 msg_out *msgout_last = (msg_out *) ((g_list_last(mo_ph->msgout_list))->data); |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
421 if (msgout_last->msg == msgout->msg) { |
15 | 422 /* if it is also the same message, it must be the last one appended |
423 to mo_ph->msgout_list (since outer loop goes through msgout_list) */ | |
10
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
424 msgout_last->rcpt_list = g_list_append(msgout_last->rcpt_list, rcpt); |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
425 } else { |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
426 /* if not, we append a new msgout */ |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
427 /* make a copy of msgout */ |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
428 msgout_new = create_msg_out(msgout->msg); |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
429 msgout_new->return_path = msgout->return_path; |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
430 msgout_new->hdr_list = msgout->hdr_list; |
0 | 431 |
10
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
432 /* append our rcpt to it */ |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
433 /* It is the 1st rcpt for this msg to this host, therefore we safely give NULL */ |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
434 msgout_new->rcpt_list = g_list_append(NULL, rcpt); |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
435 mo_ph->msgout_list = g_list_append(mo_ph->msgout_list, msgout_new); |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
436 } |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
437 } else { |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
438 /* this rcpt to goes to another host */ |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
439 mo_ph = create_msgout_perhost(rcpt->domain); |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
440 mo_ph_list = g_list_append(mo_ph_list, mo_ph); |
0 | 441 |
10
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
442 /* make a copy of msgout */ |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
443 msgout_new = create_msg_out(msgout->msg); |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
444 msgout_new->return_path = msgout->return_path; |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
445 msgout_new->hdr_list = msgout->hdr_list; |
0 | 446 |
10
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
447 /* append our rcpt to it */ |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
448 /* It is the 1st rcpt for this msg to this host, therefore we safely give NULL */ |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
449 msgout_new->rcpt_list = g_list_append(NULL, rcpt); |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
450 mo_ph->msgout_list = g_list_append(mo_ph->msgout_list, msgout_new); |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
451 } /* if mo_ph != NULL */ |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
452 } /* foreach(rcpt_list, ... */ |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
453 } /* foreach(msgout_list, ... */ |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
454 |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
455 return mo_ph_list; |
0 | 456 } |