masqmail

changeset 258:05fa719b7002

fixed -oem by removing it ;-) The implemenation of -oem had been very weird. docs/oem-option explains the situation and the fix.
author markus schnalke <meillo@marmaro.de>
date Wed, 01 Dec 2010 18:27:46 -0300
parents 8cca5305e4f0
children f4117fd5a163
files ChangeLog NEWS docs/oem-option man/masqmail.8 src/masqmail.c
diffstat 5 files changed, 93 insertions(+), 64 deletions(-) [+]
line diff
     1.1 --- a/ChangeLog	Wed Dec 01 17:29:52 2010 -0300
     1.2 +++ b/ChangeLog	Wed Dec 01 18:27:46 2010 -0300
     1.3 @@ -7,7 +7,7 @@
     1.4  technical speach and with focus on compatibility.
     1.5  
     1.6  
     1.7 -0.3.1   Thu, 04 Nov 2010 13:46:58 -0300
     1.8 +0.3.1   Wed, 01 Dec 2010 18:11:29 -0300
     1.9  	* smtp_out.c: changed the SMTP greeting behavior to match RFC
    1.10  	  2821 (always try EHLO first). Thanks to inne for pointing me
    1.11  	  on that. See also Debian bug #349211
    1.12 @@ -16,6 +16,7 @@
    1.13  	* refactored the cmdline argument processing (-m is recognized,
    1.14  	  unknown -oXXX options are ignored now and some corner-cases
    1.15  	  covered)
    1.16 +	* fixed -oem by removing it ;-) (see NEWS and docs/oem-option)
    1.17  	* created new functions manipulate_queue() and run_queue()
    1.18  	  and moved code from main()
    1.19  	* replaced the loop-based alias_expand() with a new one that
     2.1 --- a/NEWS	Wed Dec 01 17:29:52 2010 -0300
     2.2 +++ b/NEWS	Wed Dec 01 18:27:46 2010 -0300
     2.3 @@ -24,6 +24,12 @@
     2.4  calls the MTA with -m. This is mainly a relict of old sendmail times
     2.5  but needed for compatibility.
     2.6  
     2.7 +- The implementation of the command line option -oem had been
     2.8 +weird. Now specifying -oem or -oee results in a (some kind of dumb but)
     2.9 +logical behavior.  Common users will probably not notice any difference.
    2.10 +The changes affect only the exit code of the corner-case: Calling masqmail
    2.11 +with -oem but without -oi/-i while submitting messages on stdin.
    2.12 +
    2.13  - Renamed the config file option `alias_local_caseless' to
    2.14  `caseless_matching' because the option affects any address matching.
    2.15  
     3.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     3.2 +++ b/docs/oem-option	Wed Dec 01 18:27:46 2010 -0300
     3.3 @@ -0,0 +1,76 @@
     3.4 +-oem
     3.5 +====
     3.6 +
     3.7 +This document explains what I found out about the -oem/-oee options. It
     3.8 +is intended as a knowledge base for further development on this topic.
     3.9 +In version 0.3.0 (2010-11), masqmail's implementation of -oem is
    3.10 +considered broken and -oee is not implemented.
    3.11 +
    3.12 +Following is the behavior masqmail actually had:
    3.13 +
    3.14 +    If -oi/-i is given, -oem is ignored.
    3.15 +    If no -oi/-i is given, always return with a non-zero return code.
    3.16 +
    3.17 +This current behavior is not like it should be.
    3.18 +
    3.19 +
    3.20 +The desired behavior
    3.21 +--------------------
    3.22 +
    3.23 +It had been difficult to identify good explanations.  The problem, as
    3.24 +often, is that sendmail's source would be the definitive definition.
    3.25 +But in which version and what if common behavior differs from sendmail's
    3.26 +(maybe as a result of misunderstanding)?  Exim's documentation has proven
    3.27 +to be a valuable resource.
    3.28 +
    3.29 +In exim the behavior is such:
    3.30 +
    3.31 +    If an error is detected while a non-SMTP message is being received
    3.32 +    (for example, a malformed address), the error is reported to
    3.33 +    the sender in a mail message.  Exim exits with a non-zero return
    3.34 +    code then, no matter if the error message was successful or not.
    3.35 +    (In exim, -oee is similar but exim returns successful if the error
    3.36 +    message had been sent successful.)
    3.37 +
    3.38 +The mutt wiki writes about ``sendmail -oi -oem'':
    3.39 +
    3.40 +    The mail server (in this case sendmail) will receive the message
    3.41 +    in input, and will parse it. In case of a malformed message,
    3.42 +    it will send an error message to the user to whom belongs the
    3.43 +    MUA trasmitting the message (e.g. user@localhost.localdomain),
    3.44 +    and it will exit with a non zero exit code: the -oem flag forces
    3.45 +    the returning of a non zero exit code even in the case the error
    3.46 +    message has been successfully sent to the local server.
    3.47 +
    3.48 +
    3.49 +What does it mean for masqmail?
    3.50 +-------------------------------
    3.51 +
    3.52 +Masqmail does not send error messages on malformed addresses.  It does
    3.53 +not much check for syntax.  It detects general errors (unexpected EOF,
    3.54 +no recipients, max message size exceeded) (see masqmail.c:mode_accept())
    3.55 +but simply prints a message to stderr and exits non-zero.  I think that
    3.56 +currently it is not of need to add some elaborate error handling in
    3.57 +this area.  Hence, for the implementing of -oem and -oee would do assume
    3.58 +that sending the error message does always fail (because we never send
    3.59 +any such message) and hence we exit non-zero on error.  This is the
    3.60 +similar behavior of both options.
    3.61 +
    3.62 +From 0.3.1 on masqmail will not recognize -oem anymore and thus ignore
    3.63 +it like any unknown -oXXX option. It's behavior is then as if error
    3.64 +message sending fails.
    3.65 +
    3.66 +Remind that all this affects only the case of accepting non-SMTP messages
    3.67 +on stdin.
    3.68 +
    3.69 +
    3.70 +On the relationship of -oi and -oem
    3.71 +-----------------------------------
    3.72 +
    3.73 +It seems as if the two options should not affect each other; in contrast
    3.74 +to the behavior in masqmail before 0.3.1.  Their relationship is just
    3.75 +that -oem does only affect non-SMTP messages on stdin, which is the
    3.76 +typical use case of -oi.
    3.77 +
    3.78 +
    3.79 +meillo
     4.1 --- a/man/masqmail.8	Wed Dec 01 17:29:52 2010 -0300
     4.2 +++ b/man/masqmail.8	Wed Dec 01 18:27:46 2010 -0300
     4.3 @@ -128,54 +128,14 @@
     4.4  .TP
     4.5  \fB\-m\fR
     4.6  
     4.7 -Same as \fB\-om\fR, see below.
     4.8 +``Me too''
     4.9 +This switch is ignored as,
    4.10 +masqmail never excludes the sender from any alias expansions.
    4.11 +
    4.12 +\fB\-m\fP is an ancient alias for \fB\-om\fP.
    4.13  Kept for compatibility.
    4.14  
    4.15  .TP
    4.16 -\fB\-oem\fR
    4.17 -
    4.18 -Currently this option makes masqmail behave such:
    4.19 -
    4.20 -If the \fB\-oi\fR ist not also given, always return with a non zero return code.
    4.21 -
    4.22 -It seems as if this current behavior is not like it should be.
    4.23 -
    4.24 -In exim this option makes it behave such:
    4.25 -
    4.26 -.in +4
    4.27 -.ll -4
    4.28 -If an error is detected while a non-SMTP message is being received
    4.29 -(for example, a malformed address),
    4.30 -the error is reported to the sender in a mail message.
    4.31 -Exim exits with a non-zero return code then,
    4.32 -no matter if the error message was successful or not.
    4.33 -(In exim, -oee is similar but exim returns successful
    4.34 -if the error message had been sent successful.)
    4.35 -.ll
    4.36 -.in
    4.37 -
    4.38 -The mutt wiki writes about ``sendmail -oi -oem'':
    4.39 -
    4.40 -.in +4
    4.41 -.ll -4
    4.42 -The mail server (in this case sendmail) will receive the message in input,
    4.43 -and will parse it. In case of a malformed message, it will send an error
    4.44 -message to the user to whom belongs the MUA trasmitting the message
    4.45 -(e.g. user@localhost.localdomain), and it will exit with a non zero exit code:
    4.46 -the -oem flag forces the returning of a non zero exit code even in
    4.47 -the case the error message has been successfully sent to the local server.
    4.48 -.ll
    4.49 -.in
    4.50 -
    4.51 -Masqmail's behavior is different in that:
    4.52 -First, it does not send such error messages.
    4.53 -Second, return non-zero whenever -oem is set (but -oi not).
    4.54 -Third, -oi overrules -oem, though as it seems the two options 
    4.55 -should not affect each other.
    4.56 -(Their relationship is just that -oem does only affect non-SMTP
    4.57 -messages on stdin, which is the typical use of -oi.)
    4.58 -
    4.59 -.TP
    4.60  \fB\-odb\fR
    4.61  
    4.62  ``Deliver in Background''
    4.63 @@ -195,18 +155,13 @@
    4.64  
    4.65  A dot as a single character in a line does not terminate the message.
    4.66  
    4.67 -.TP
    4.68 -\fB\-om\fR
    4.69 -
    4.70 -``Me too''
    4.71 -Masqmail never excludes the sender from any alias expansions,
    4.72 -like if this switch is always set.
    4.73 -Specifying this switch changes nothing.
    4.74 +The same as \fB\-i\fP.
    4.75  
    4.76  .TP
    4.77  \fB\-oXXX\fR
    4.78  
    4.79 -Any other switch starting with `-o' is ignored.
    4.80 +Any other switch starting with `\-o' is ignored.
    4.81 +This especially affects \-om, \-oem, \-oee.
    4.82  
    4.83  .TP
    4.84  \fB\-q [\fIinterval\fB]\fR
     5.1 --- a/src/masqmail.c	Wed Dec 01 17:29:52 2010 -0300
     5.2 +++ b/src/masqmail.c	Wed Dec 01 18:27:46 2010 -0300
     5.3 @@ -391,7 +391,6 @@
     5.4  	gchar *M_cmd = NULL;
     5.5  	gboolean opt_t = FALSE;
     5.6  	gboolean opt_i = FALSE;
     5.7 -	gboolean exit_failure = FALSE;
     5.8  	gint exit_code = EXIT_SUCCESS;
     5.9  	gchar *conf_file = CONF_FILE;
    5.10  	gchar *route_name = NULL;
    5.11 @@ -488,7 +487,6 @@
    5.12  
    5.13  		} else if (strcmp(opt, "i") == 0) {
    5.14  			opt_i = TRUE;
    5.15 -			exit_failure = FALSE;  /* may override -oem */
    5.16  
    5.17  		} else if (strcmp(opt, "m") == 0) {
    5.18  			/* ignore -m (me too) switch (see man page) */
    5.19 @@ -500,15 +498,8 @@
    5.20  		} else if (strcmp(opt, "odq") == 0) {
    5.21  			do_queue = TRUE;
    5.22  
    5.23 -		} else if (strcmp(opt, "oem") == 0) {
    5.24 -			if (!opt_i) {
    5.25 -				/* TODO: Why is this related to -i in any way? */
    5.26 -				exit_failure = TRUE;
    5.27 -			}
    5.28 -
    5.29  		} else if (strcmp(opt, "oi") == 0) {
    5.30  			opt_i = TRUE;
    5.31 -			exit_failure = FALSE;  /* may override -oem */
    5.32  
    5.33  		} else if (strncmp(opt, "o", 1) == 0) {
    5.34  			/* ignore all other -oXXX options */
    5.35 @@ -693,7 +684,7 @@
    5.36  			guint accept_flags = (opt_t ? ACC_DEL_RCPTS | ACC_RCPT_FROM_HEAD : 0)
    5.37  			                     | (opt_i ? ACC_DOT_IGNORE : ACC_NODOT_RELAX);
    5.38  			mode_accept(return_path, full_sender_name, accept_flags, &(argv[arg]), argc - arg);
    5.39 -			exit(exit_failure ? EXIT_FAILURE : EXIT_SUCCESS);
    5.40 +			exit(0);
    5.41  		}
    5.42  		break;
    5.43  	case MODE_NONE: