Mercurial > masqmail
comparison src/accept.c @ 276:1abc1faeb45d
for -t cmdline args are now added to the rcpt list instead of substracted
Please read the diff and the section about -t in man/masqmail.8.
Masqmail's behavior had been like the one of exim/smail, now it's
similar to postfix.
Masqmail does it now the most simple way, regarding the code.
Also, addr args are always recipients, -t does not change their meaning.
-t makes the addrs from rcpt hdrs, rcpt addrs too.
It would have been logical too, to ignore the cmdline args,
in the sense of ``headers *instead of* args'' but none of the
popular MTAs does it that way and it would have been a bit more
complicated in the code.
Anyway, this is a corner-case that should better be avoided completely.
author | markus schnalke <meillo@marmaro.de> |
---|---|
date | Fri, 03 Dec 2010 21:05:34 -0300 |
parents | 1405012509e3 |
children | bb3005ce0837 |
comparison
equal
deleted
inserted
replaced
275:1405012509e3 | 276:1abc1faeb45d |
---|---|
53 } | 53 } |
54 return ret; | 54 return ret; |
55 } | 55 } |
56 | 56 |
57 /* accept message from anywhere. | 57 /* accept message from anywhere. |
58 A locally originating message is indicated by msg->recieved_host == NULL | 58 A message from local is indicated by msg->recieved_host == NULL |
59 | 59 |
60 The -t option: | 60 The -t option: With the ACC_RCPT_FROM_HEAD flag the addrs found found |
61 The ACC_RCPT_FROM_HEAD flag adds the recipients found in To/Cc/Bcc | 61 in To/Cc/Bcc headers are added to the recipient list. |
62 headers to the recipients list. The recipients given on the | |
63 command line are removed from the ones given in headers. | |
64 */ | 62 */ |
65 | 63 |
66 accept_error | 64 accept_error |
67 accept_message_stream(FILE * in, message * msg, guint flags) | 65 accept_message_stream(FILE * in, message * msg, guint flags) |
68 { | 66 { |
185 | 183 |
186 accept_error | 184 accept_error |
187 accept_message_prepare(message * msg, guint flags) | 185 accept_message_prepare(message * msg, guint flags) |
188 { | 186 { |
189 struct passwd *passwd = NULL; | 187 struct passwd *passwd = NULL; |
190 GList *non_rcpt_list = NULL; | |
191 time_t rec_time = time(NULL); | 188 time_t rec_time = time(NULL); |
192 | 189 |
193 DEBUG(5) debugf("accept_message_prepare()\n"); | 190 DEBUG(5) debugf("accept_message_prepare()\n"); |
194 | 191 |
195 /* create unique message id */ | 192 /* create unique message id */ |
212 if (msg->return_path == NULL && msg->received_host == NULL) { | 209 if (msg->return_path == NULL && msg->received_host == NULL) { |
213 gchar *path = g_strdup_printf("<%s@%s>", passwd->pw_name, conf.host_name); | 210 gchar *path = g_strdup_printf("<%s@%s>", passwd->pw_name, conf.host_name); |
214 DEBUG(3) debugf("setting return_path for local accept: %s\n", path); | 211 DEBUG(3) debugf("setting return_path for local accept: %s\n", path); |
215 msg->return_path = create_address(path, TRUE); | 212 msg->return_path = create_address(path, TRUE); |
216 g_free(path); | 213 g_free(path); |
217 } | |
218 | |
219 /* -t option (see comment above) */ | |
220 if (flags & ACC_RCPT_FROM_HEAD) { | |
221 non_rcpt_list = msg->rcpt_list; | |
222 msg->rcpt_list = NULL; | |
223 } | 214 } |
224 | 215 |
225 /* scan headers */ | 216 /* scan headers */ |
226 { | 217 { |
227 gboolean has_id = FALSE; | 218 gboolean has_id = FALSE; |
271 break; | 262 break; |
272 case HEAD_ENVELOPE_TO: | 263 case HEAD_ENVELOPE_TO: |
273 if (flags & ACC_SAVE_ENVELOPE_TO) { | 264 if (flags & ACC_SAVE_ENVELOPE_TO) { |
274 DEBUG(3) debugf("creating 'X-Orig-Envelope-To' header\n"); | 265 DEBUG(3) debugf("creating 'X-Orig-Envelope-To' header\n"); |
275 msg->hdr_list = g_list_prepend(msg->hdr_list, create_header(HEAD_UNKNOWN, | 266 msg->hdr_list = g_list_prepend(msg->hdr_list, create_header(HEAD_UNKNOWN, |
276 "X-Orig-Envelope-to: %s", hdr->value)); | 267 "X-Orig-Envelope-To: %s", hdr->value)); |
277 } | 268 } |
278 DEBUG(3) debugf("removing 'Envelope-To' header\n"); | 269 DEBUG(3) debugf("removing 'Envelope-To' header\n"); |
279 msg->hdr_list = g_list_remove_link(msg->hdr_list, hdr_node); | 270 msg->hdr_list = g_list_remove_link(msg->hdr_list, hdr_node); |
280 g_list_free_1(hdr_node); | 271 g_list_free_1(hdr_node); |
281 destroy_header(hdr); | 272 destroy_header(hdr); |
329 msg->hdr_list = g_list_append(msg->hdr_list, create_header(HEAD_UNKNOWN, | 320 msg->hdr_list = g_list_append(msg->hdr_list, create_header(HEAD_UNKNOWN, |
330 "X-Warning: real return path is unknown\n")); | 321 "X-Warning: real return path is unknown\n")); |
331 } | 322 } |
332 } | 323 } |
333 | 324 |
334 if (flags & ACC_RCPT_FROM_HEAD) { | |
335 /* remove the recipients given on the command line | |
336 from the ones given in headers | |
337 -t option (see comment above) */ | |
338 GList *rcpt_node; | |
339 foreach(non_rcpt_list, rcpt_node) { | |
340 address *rcpt = (address *) (rcpt_node->data); | |
341 GList *node; | |
342 if ((node = g_list_find_custom(msg->rcpt_list, rcpt, _g_list_addr_isequal))) { | |
343 DEBUG(3) debugf("removing rcpt address %s\n", addr_string(node->data)); | |
344 msg->rcpt_list = g_list_remove_link(msg->rcpt_list, node); | |
345 destroy_address((address *) (node->data)); | |
346 g_list_free_1(node); | |
347 } | |
348 } | |
349 } | |
350 | |
351 /* here we should have our recipients, fail if not: */ | 325 /* here we should have our recipients, fail if not: */ |
352 if (msg->rcpt_list == NULL) { | 326 if (!msg->rcpt_list) { |
353 logwrite(LOG_WARNING, "no recipients found in message\n"); | 327 logwrite(LOG_WARNING, "no recipients found in message\n"); |
354 return AERR_NORCPT; | 328 return AERR_NORCPT; |
355 } | 329 } |
356 | 330 |
357 if (!(has_sender || has_from)) { | 331 if (!(has_sender || has_from)) { |