From 273f34d076393a3df1b85a93f10d16f1a68f66a1 Mon Sep 17 00:00:00 2001 From: Philip Hazel Date: Thu, 25 Jan 2007 15:51:28 +0000 Subject: [PATCH] Ensure acl_not_smtp_start is called for -bS input. --- doc/doc-txt/ChangeLog | 8 ++++- src/src/exim.c | 59 +++++++++++++++++++++--------------- test/confs/0535 | 1 + test/confs/0548 | 1 + test/log/0535 | 6 ++++ test/mail/0535.userx | 20 ++++++++++++ test/scripts/0000-Basic/0535 | 12 ++++++++ test/stderr/0381 | 1 + test/stderr/0386 | 1 + test/stderr/0465 | 3 ++ test/stderr/0487 | 1 + test/stderr/3400 | 1 + 12 files changed, 89 insertions(+), 25 deletions(-) diff --git a/doc/doc-txt/ChangeLog b/doc/doc-txt/ChangeLog index 4a7f77c7a..1f9911d16 100644 --- a/doc/doc-txt/ChangeLog +++ b/doc/doc-txt/ChangeLog @@ -1,4 +1,4 @@ -$Cambridge: exim/doc/doc-txt/ChangeLog,v 1.462 2007/01/23 15:08:45 ph10 Exp $ +$Cambridge: exim/doc/doc-txt/ChangeLog,v 1.463 2007/01/25 15:51:28 ph10 Exp $ Change log file for Exim from version 4.21 ------------------------------------------- @@ -54,6 +54,12 @@ PH/08 Added $smtp_count_at_connection_start, deliberately with a long name. PH/09 Installed PCRE release 7.0. +PH/10 The acl_not_smtp_start ACL was, contrary to the documentation, not being + run for batched SMTP input. It is now run at the start of every message + in the batch. While fixing this I discovered that the process information + (output by running exiwhat) was not always getting set for -bs and -bS + input. This is fixed, and it now also says "batched" for BSMTP. + Exim version 4.66 ----------------- diff --git a/src/src/exim.c b/src/src/exim.c index 553f47d99..6f80dd131 100644 --- a/src/src/exim.c +++ b/src/src/exim.c @@ -1,4 +1,4 @@ -/* $Cambridge: exim/src/src/exim.c,v 1.53 2007/01/17 11:29:39 ph10 Exp $ */ +/* $Cambridge: exim/src/src/exim.c,v 1.54 2007/01/25 15:51:28 ph10 Exp $ */ /************************************************* * Exim - an Internet mail transport agent * @@ -4487,16 +4487,17 @@ but fd 1 will not be set. This also happens for passed SMTP channels. */ if (fstat(1, &statbuf) < 0) (void)dup2(0, 1); -/* Set up the incoming protocol name and the state of the program. Root -is allowed to force received protocol via the -oMr option above, and if we are -in a non-local SMTP state it means we have come via inetd and the process info -has already been set up. We don't set received_protocol here for smtp input, -as it varies according to batch/HELO/EHLO/AUTH/TLS. */ +/* Set up the incoming protocol name and the state of the program. Root is +allowed to force received protocol via the -oMr option above. If we have come +via inetd, the process info has already been set up. We don't set +received_protocol here for smtp input, as it varies according to +batch/HELO/EHLO/AUTH/TLS. */ if (smtp_input) { - if (sender_local) set_process_info("accepting a local SMTP message from <%s>", - sender_address); + if (!is_inetd) set_process_info("accepting a local %sSMTP message from <%s>", + smtp_batched_input? "batched " : "", + (sender_address!= NULL)? sender_address : originator_login); } else { @@ -4523,8 +4524,8 @@ if ((!smtp_input || smtp_batched_input) && !receive_check_fs(0)) return EXIT_FAILURE; } -/* If this is smtp input of any kind, handle the start of the SMTP -session. +/* If this is smtp input of any kind, real or batched, handle the start of the +SMTP session. NOTE: We do *not* call smtp_log_no_mail() if smtp_start_session() fails, because a log line has already been written for all its failure exists @@ -4617,20 +4618,13 @@ while (more) store_reset(reset_point); message_id[0] = 0; - /* In the SMTP case, we have to handle the initial SMTP input and build the - recipients list, before calling receive_msg() to read the message proper. - Whatever sender address is actually given in the SMTP transaction is - actually ignored for local senders - we use the actual sender, which is - normally either the underlying user running this process or a -f argument - provided by a trusted caller. It is saved in real_sender_address. - - However, if this value is NULL, we are dealing with a trusted caller when - -f was not used; in this case, the SMTP sender is allowed to stand. - - Also, if untrusted_set_sender is set, we permit sender addresses that match - anything in its list. - - The variable raw_sender_address holds the sender address before rewriting. */ + /* Handle the SMTP case; call smtp_setup_mst() to deal with the initial SMTP + input and build the recipients list, before calling receive_msg() to read the + message proper. Whatever sender address is given in the SMTP transaction is + often ignored for local senders - we use the actual sender, which is normally + either the underlying user running this process or a -f argument provided by + a trusted caller. It is saved in real_sender_address. The test for whether to + accept the SMTP sender is encapsulated in receive_check_set_sender(). */ if (smtp_input) { @@ -4643,6 +4637,23 @@ while (more) sender_address = raw_sender = real_sender_address; sender_address_unrewritten = NULL; } + + /* For batched SMTP, we have to run the acl_not_smtp_start ACL, since it + isn't really SMTP, so no other ACL will run until the acl_not_smtp one at + the very end. The result of the ACL is ignored (as for other non-SMTP + messages). It is run for its potential side effects. */ + + if (smtp_batched_input && acl_not_smtp_start != NULL) + { + uschar *user_msg, *log_msg; + enable_dollar_recipients = TRUE; + (void)acl_check(ACL_WHERE_NOTSMTP_START, NULL, acl_not_smtp_start, + &user_msg, &log_msg); + enable_dollar_recipients = FALSE; + } + + /* Now get the data for the message */ + more = receive_msg(extract_recipients); if (message_id[0] == 0) { diff --git a/test/confs/0535 b/test/confs/0535 index 6504807f9..a45a374b7 100644 --- a/test/confs/0535 +++ b/test/confs/0535 @@ -24,6 +24,7 @@ one: control = suppress_local_fixups add_header = X-Added: $recipients + # ----- Routers ----- begin routers diff --git a/test/confs/0548 b/test/confs/0548 index 18ef2abdd..6306943de 100644 --- a/test/confs/0548 +++ b/test/confs/0548 @@ -15,6 +15,7 @@ gecos_name = CALLER_NAME acl_smtp_connect = acl_connect acl_smtp_rcpt = acl_rcpt qualify_domain = test.ex +queue_run_in_order # ----- ACLs ----- diff --git a/test/log/0535 b/test/log/0535 index e737ee232..b4e13c806 100644 --- a/test/log/0535 +++ b/test/log/0535 @@ -4,3 +4,9 @@ 1999-03-02 09:44:33 10HmaY-0005vi-00 <= nofix@test.ex U=CALLER P=local S=sss 1999-03-02 09:44:33 10HmaY-0005vi-00 => userx R=r1 T=t1 1999-03-02 09:44:33 10HmaY-0005vi-00 Completed +1999-03-02 09:44:33 10HmaZ-0005vi-00 <= x@y U=CALLER P=local-bsmtp S=sss +1999-03-02 09:44:33 10HmaZ-0005vi-00 => userx R=r1 T=t1 +1999-03-02 09:44:33 10HmaZ-0005vi-00 Completed +1999-03-02 09:44:33 10HmbA-0005vi-00 <= nofix@test.ex U=CALLER P=local-bsmtp S=sss +1999-03-02 09:44:33 10HmbA-0005vi-00 => userx R=r1 T=t1 +1999-03-02 09:44:33 10HmbA-0005vi-00 Completed diff --git a/test/mail/0535.userx b/test/mail/0535.userx index 4ca2d6156..e3994508e 100644 --- a/test/mail/0535.userx +++ b/test/mail/0535.userx @@ -18,3 +18,23 @@ X-Added: userx@test.ex No headers supplied. +From x@y Tue Mar 02 09:44:33 1999 +Received: from CALLER by myhost.test.ex with local-bsmtp (Exim x.yz) + (envelope-from ) + id 10HmaZ-0005vi-00 + for userx@test.ex; Tue, 2 Mar 1999 09:44:33 +0000 +Message-Id: +From: x@y +Date: Tue, 2 Mar 1999 09:44:33 +0000 + +No headers supplied. + +From nofix@test.ex Tue Mar 02 09:44:33 1999 +Received: from CALLER by myhost.test.ex with local-bsmtp (Exim x.yz) + (envelope-from ) + id 10HmbA-0005vi-00 + for userx@test.ex; Tue, 2 Mar 1999 09:44:33 +0000 +X-Added: userx@test.ex + +No headers supplied. + diff --git a/test/scripts/0000-Basic/0535 b/test/scripts/0000-Basic/0535 index 237fa4c9c..72a1a1533 100644 --- a/test/scripts/0000-Basic/0535 +++ b/test/scripts/0000-Basic/0535 @@ -5,3 +5,15 @@ No headers supplied. exim -odi -f nofix@test.ex userx@test.ex No headers supplied. **** +exim -odi -bS +mail from: +rcpt to: +data +No headers supplied. +. +mail from: +rcpt to: +data +No headers supplied. +. +**** diff --git a/test/stderr/0381 b/test/stderr/0381 index bca2de5bf..a026767b8 100644 --- a/test/stderr/0381 +++ b/test/stderr/0381 @@ -13,6 +13,7 @@ sender address = NULL sender_fullhost = [V4NET.99.99.97] sender_rcvhost = [V4NET.99.99.97] (ident=CALLER) set_process_info: pppp handling incoming connection from [V4NET.99.99.97] via -oMa +set_process_info: pppp accepting a local SMTP message from host in hosts_connection_nolog? no (option unset) LOG: smtp_connection MAIN SMTP connection from CALLER diff --git a/test/stderr/0386 b/test/stderr/0386 index 8ff9bda89..a06f5294a 100644 --- a/test/stderr/0386 +++ b/test/stderr/0386 @@ -133,6 +133,7 @@ sender address = NULL sender_fullhost = [V4NET.11.12.13] sender_rcvhost = [V4NET.11.12.13] (ident=CALLER) set_process_info: pppp handling incoming connection from [V4NET.11.12.13] via -oMa +set_process_info: pppp accepting a local SMTP message from host in hosts_connection_nolog? no (option unset) LOG: smtp_connection MAIN SMTP connection from CALLER diff --git a/test/stderr/0465 b/test/stderr/0465 index f429e3c47..4c84b1453 100644 --- a/test/stderr/0465 +++ b/test/stderr/0465 @@ -10,6 +10,7 @@ changed uid/gid: privilege not needed uid=EXIM_UID gid=EXIM_GID pid=pppp originator: uid=CALLER_UID gid=CALLER_GID login=CALLER name=CALLER_NAME sender address = NULL +set_process_info: pppp accepting a local SMTP message from in hosts_connection_nolog? no (option unset) LOG: smtp_connection MAIN SMTP connection from CALLER @@ -40,6 +41,7 @@ changed uid/gid: privilege not needed uid=EXIM_UID gid=EXIM_GID pid=pppp originator: uid=CALLER_UID gid=CALLER_GID login=CALLER name=CALLER_NAME sender address = NULL +set_process_info: pppp accepting a local SMTP message from in hosts_connection_nolog? no (option unset) LOG: smtp_connection MAIN SMTP connection from CALLER @@ -101,6 +103,7 @@ changed uid/gid: privilege not needed uid=EXIM_UID gid=EXIM_GID pid=pppp originator: uid=CALLER_UID gid=CALLER_GID login=CALLER name=CALLER_NAME sender address = NULL +set_process_info: pppp accepting a local SMTP message from in hosts_connection_nolog? no (option unset) LOG: smtp_connection MAIN SMTP connection from CALLER diff --git a/test/stderr/0487 b/test/stderr/0487 index 584672a7e..73c10e891 100644 --- a/test/stderr/0487 +++ b/test/stderr/0487 @@ -12,6 +12,7 @@ seeking password data for user "CALLER": using cached result getpwnam() succeeded uid=CALLER_UID gid=CALLER_GID originator: uid=CALLER_UID gid=CALLER_GID login=CALLER name=CALLER_NAME sender address = NULL +set_process_info: pppp accepting a local SMTP message from in hosts_connection_nolog? no (option unset) LOG: smtp_connection MAIN SMTP connection from CALLER diff --git a/test/stderr/3400 b/test/stderr/3400 index a2cc076ef..896c60266 100644 --- a/test/stderr/3400 +++ b/test/stderr/3400 @@ -368,6 +368,7 @@ sender address = NULL sender_fullhost = [10.0.0.5] sender_rcvhost = [10.0.0.5] (ident=CALLER) set_process_info: pppp handling incoming connection from [10.0.0.5] via -oMa +set_process_info: pppp accepting a local SMTP message from host in hosts_connection_nolog? no (option unset) LOG: smtp_connection MAIN SMTP connection from CALLER -- 2.30.2