# HG changeset patch # User markus schnalke # Date 1291421134 10800 # Node ID 1abc1faeb45ddcbea75acc2208e58088c2710d0c # Parent 1405012509e320eecd4ebaf05246e50c01391023 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. diff -r 1405012509e3 -r 1abc1faeb45d man/masqmail.8 --- a/man/masqmail.8 Fri Dec 03 19:35:34 2010 -0300 +++ b/man/masqmail.8 Fri Dec 03 21:05:34 2010 -0300 @@ -203,17 +203,28 @@ .TP \fB\-t\fR -Read recipients from headers. -If any arguments are given, these are interpreted as recipient addresses -and the message will not be sent to these, -although they might appear in To:, Cc:, or Bcc: headers. -I.e. the set of argument recipients is ``substracted'' from the set of header recipients. +Read recipients from mail headers and add them to the ones specified on the +command line. +(Only To:, Cc:, and Bcc: headers are regarded.) -This behavior is similar to exim's and smail's. -Postfix, in contrast, adds the arguments to the set of header recipients. +.B WARNING: The behavior changed with version 0.3.1! + +In earlier versions command line argument addresses were ``substracted'' +from header addresses. + +The old behavior was similar to exim's and smail's +(which are anchesters of masqmail). +The new behavior is similar to the one of current postfix versions, +which add the arguments to the set of header recipients. +(Earlier postfix failed in case of address arguments with \-t.) Sendmail seems to behave differently, depending on the version. See exim(8) for further information. +For masqmail the most simple approach had been taken. + +As the behavior of \-t together with command line address arguments +differs among MTAs, one better not steps into this corner case. + .TP \fB\-v\fR diff -r 1405012509e3 -r 1abc1faeb45d src/accept.c --- a/src/accept.c Fri Dec 03 19:35:34 2010 -0300 +++ b/src/accept.c Fri Dec 03 21:05:34 2010 -0300 @@ -55,12 +55,10 @@ } /* accept message from anywhere. - A locally originating message is indicated by msg->recieved_host == NULL + A message from local is indicated by msg->recieved_host == NULL - The -t option: - The ACC_RCPT_FROM_HEAD flag adds the recipients found in To/Cc/Bcc - headers to the recipients list. The recipients given on the - command line are removed from the ones given in headers. + The -t option: With the ACC_RCPT_FROM_HEAD flag the addrs found found + in To/Cc/Bcc headers are added to the recipient list. */ accept_error @@ -187,7 +185,6 @@ accept_message_prepare(message * msg, guint flags) { struct passwd *passwd = NULL; - GList *non_rcpt_list = NULL; time_t rec_time = time(NULL); DEBUG(5) debugf("accept_message_prepare()\n"); @@ -216,12 +213,6 @@ g_free(path); } - /* -t option (see comment above) */ - if (flags & ACC_RCPT_FROM_HEAD) { - non_rcpt_list = msg->rcpt_list; - msg->rcpt_list = NULL; - } - /* scan headers */ { gboolean has_id = FALSE; @@ -273,7 +264,7 @@ if (flags & ACC_SAVE_ENVELOPE_TO) { DEBUG(3) debugf("creating 'X-Orig-Envelope-To' header\n"); msg->hdr_list = g_list_prepend(msg->hdr_list, create_header(HEAD_UNKNOWN, - "X-Orig-Envelope-to: %s", hdr->value)); + "X-Orig-Envelope-To: %s", hdr->value)); } DEBUG(3) debugf("removing 'Envelope-To' header\n"); msg->hdr_list = g_list_remove_link(msg->hdr_list, hdr_node); @@ -331,25 +322,8 @@ } } - if (flags & ACC_RCPT_FROM_HEAD) { - /* remove the recipients given on the command line - from the ones given in headers - -t option (see comment above) */ - GList *rcpt_node; - foreach(non_rcpt_list, rcpt_node) { - address *rcpt = (address *) (rcpt_node->data); - GList *node; - if ((node = g_list_find_custom(msg->rcpt_list, rcpt, _g_list_addr_isequal))) { - DEBUG(3) debugf("removing rcpt address %s\n", addr_string(node->data)); - msg->rcpt_list = g_list_remove_link(msg->rcpt_list, node); - destroy_address((address *) (node->data)); - g_list_free_1(node); - } - } - } - /* here we should have our recipients, fail if not: */ - if (msg->rcpt_list == NULL) { + if (!msg->rcpt_list) { logwrite(LOG_WARNING, "no recipients found in message\n"); return AERR_NORCPT; } diff -r 1405012509e3 -r 1abc1faeb45d src/masqmail.c --- a/src/masqmail.c Fri Dec 03 19:35:34 2010 -0300 +++ b/src/masqmail.c Fri Dec 03 21:05:34 2010 -0300 @@ -223,9 +223,18 @@ DEBUG(5) debugf("accepting message on stdin\n"); msg->received_prot = PROT_LOCAL; + + /* warn if -t option and cmdline addr args */ + if (addr_cnt && (accept_flags & ACC_RCPT_FROM_HEAD)) { + logwrite(LOG_ALERT, "command line address arguments are now *added* to the mail header\\\n"); + logwrite(LOG_ALERT, " recipient addresses (instead of substracted) when -t is given.\\\n"); + logwrite(LOG_ALERT, " this changed with version 0.3.1\n"); + } + for (i = 0; i < addr_cnt; i++) { if (addresses[i][0] == '|') { logwrite(LOG_ALERT, "no pipe allowed as recipient address: %s\n", addresses[i]); + /* should we better ignore this one addr? */ exit(1); } msg->rcpt_list = g_list_append(msg->rcpt_list, create_address_qualified(addresses[i], TRUE, conf.host_name));