masqmail

changeset 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 5f559921391a
files man/masqmail.8 src/accept.c src/masqmail.c
diffstat 3 files changed, 32 insertions(+), 38 deletions(-) [+]
line diff
     1.1 --- a/man/masqmail.8	Fri Dec 03 19:35:34 2010 -0300
     1.2 +++ b/man/masqmail.8	Fri Dec 03 21:05:34 2010 -0300
     1.3 @@ -203,17 +203,28 @@
     1.4  .TP
     1.5  \fB\-t\fR
     1.6  
     1.7 -Read recipients from headers.
     1.8 -If any arguments are given, these are interpreted as recipient addresses
     1.9 -and the message will not be sent to these,
    1.10 -although they might appear in To:, Cc:, or Bcc: headers.
    1.11 -I.e. the set of argument recipients is ``substracted'' from the set of header recipients.
    1.12 +Read recipients from mail headers and add them to the ones specified on the
    1.13 +command line.
    1.14 +(Only To:, Cc:, and Bcc: headers are regarded.)
    1.15  
    1.16 -This behavior is similar to exim's and smail's.
    1.17 -Postfix, in contrast, adds the arguments to the set of header recipients.
    1.18 +.B WARNING: The behavior changed with version 0.3.1!
    1.19 +
    1.20 +In earlier versions command line argument addresses were ``substracted''
    1.21 +from header addresses.
    1.22 +
    1.23 +The old behavior was similar to exim's and smail's
    1.24 +(which are anchesters of masqmail).
    1.25 +The new behavior is similar to the one of current postfix versions,
    1.26 +which add the arguments to the set of header recipients.
    1.27 +(Earlier postfix failed in case of address arguments with \-t.)
    1.28  Sendmail seems to behave differently, depending on the version.
    1.29  See exim(8) for further information.
    1.30  
    1.31 +For masqmail the most simple approach had been taken.
    1.32 +
    1.33 +As the behavior of \-t together with command line address arguments
    1.34 +differs among MTAs, one better not steps into this corner case.
    1.35 +
    1.36  .TP
    1.37  \fB\-v\fR
    1.38  
     2.1 --- a/src/accept.c	Fri Dec 03 19:35:34 2010 -0300
     2.2 +++ b/src/accept.c	Fri Dec 03 21:05:34 2010 -0300
     2.3 @@ -55,12 +55,10 @@
     2.4  }
     2.5  
     2.6  /* accept message from anywhere.
     2.7 -   A locally originating message is indicated by msg->recieved_host == NULL
     2.8 +   A message from local is indicated by msg->recieved_host == NULL
     2.9  
    2.10 -   The -t option:
    2.11 -   The ACC_RCPT_FROM_HEAD flag adds the recipients found in To/Cc/Bcc
    2.12 -   headers to the recipients list. The recipients given on the
    2.13 -   command line are removed from the ones given in headers.
    2.14 +   The -t option: With the ACC_RCPT_FROM_HEAD flag the addrs found found
    2.15 +   in To/Cc/Bcc headers are added to the recipient list.
    2.16  */
    2.17  
    2.18  accept_error
    2.19 @@ -187,7 +185,6 @@
    2.20  accept_message_prepare(message * msg, guint flags)
    2.21  {
    2.22  	struct passwd *passwd = NULL;
    2.23 -	GList *non_rcpt_list = NULL;
    2.24  	time_t rec_time = time(NULL);
    2.25  
    2.26  	DEBUG(5) debugf("accept_message_prepare()\n");
    2.27 @@ -216,12 +213,6 @@
    2.28  		g_free(path);
    2.29  	}
    2.30  
    2.31 -	/* -t option (see comment above) */
    2.32 -	if (flags & ACC_RCPT_FROM_HEAD) {
    2.33 -		non_rcpt_list = msg->rcpt_list;
    2.34 -		msg->rcpt_list = NULL;
    2.35 -	}
    2.36 -
    2.37  	/* scan headers */
    2.38  	{
    2.39  		gboolean has_id = FALSE;
    2.40 @@ -273,7 +264,7 @@
    2.41  				if (flags & ACC_SAVE_ENVELOPE_TO) {
    2.42  					DEBUG(3) debugf("creating 'X-Orig-Envelope-To' header\n");
    2.43  					msg->hdr_list = g_list_prepend(msg->hdr_list, create_header(HEAD_UNKNOWN,
    2.44 -					                               "X-Orig-Envelope-to: %s", hdr->value));
    2.45 +					                               "X-Orig-Envelope-To: %s", hdr->value));
    2.46  				}
    2.47  				DEBUG(3) debugf("removing 'Envelope-To' header\n");
    2.48  				msg->hdr_list = g_list_remove_link(msg->hdr_list, hdr_node);
    2.49 @@ -331,25 +322,8 @@
    2.50  			}
    2.51  		}
    2.52  
    2.53 -		if (flags & ACC_RCPT_FROM_HEAD) {
    2.54 -			/* remove the recipients given on the command line
    2.55 -			   from the ones given in headers
    2.56 -			   -t option (see comment above) */
    2.57 -			GList *rcpt_node;
    2.58 -			foreach(non_rcpt_list, rcpt_node) {
    2.59 -				address *rcpt = (address *) (rcpt_node->data);
    2.60 -				GList *node;
    2.61 -				if ((node = g_list_find_custom(msg->rcpt_list, rcpt, _g_list_addr_isequal))) {
    2.62 -					DEBUG(3) debugf("removing rcpt address %s\n", addr_string(node->data));
    2.63 -					msg->rcpt_list = g_list_remove_link(msg->rcpt_list, node);
    2.64 -					destroy_address((address *) (node->data));
    2.65 -					g_list_free_1(node);
    2.66 -				}
    2.67 -			}
    2.68 -		}
    2.69 -
    2.70  		/* here we should have our recipients, fail if not: */
    2.71 -		if (msg->rcpt_list == NULL) {
    2.72 +		if (!msg->rcpt_list) {
    2.73  			logwrite(LOG_WARNING, "no recipients found in message\n");
    2.74  			return AERR_NORCPT;
    2.75  		}
     3.1 --- a/src/masqmail.c	Fri Dec 03 19:35:34 2010 -0300
     3.2 +++ b/src/masqmail.c	Fri Dec 03 21:05:34 2010 -0300
     3.3 @@ -223,9 +223,18 @@
     3.4  	DEBUG(5) debugf("accepting message on stdin\n");
     3.5  
     3.6  	msg->received_prot = PROT_LOCAL;
     3.7 +
     3.8 +	/* warn if -t option and cmdline addr args */
     3.9 +	if (addr_cnt && (accept_flags & ACC_RCPT_FROM_HEAD)) {
    3.10 +		logwrite(LOG_ALERT, "command line address arguments are now *added*  to the mail header\\\n");
    3.11 +		logwrite(LOG_ALERT, "  recipient addresses (instead of substracted)  when -t is given.\\\n");
    3.12 +		logwrite(LOG_ALERT, "  this changed with version 0.3.1\n");
    3.13 +	}
    3.14 +
    3.15  	for (i = 0; i < addr_cnt; i++) {
    3.16  		if (addresses[i][0] == '|') {
    3.17  			logwrite(LOG_ALERT, "no pipe allowed as recipient address: %s\n", addresses[i]);
    3.18 +			/* should we better ignore this one addr? */
    3.19  			exit(1);
    3.20  		}
    3.21  		msg->rcpt_list = g_list_append(msg->rcpt_list, create_address_qualified(addresses[i], TRUE, conf.host_name));