X-Git-Url: https://vcs.fsf.org/?p=exim.git;a=blobdiff_plain;f=src%2Fsrc%2Fdaemon.c;h=e844403a440e0b53e842a0507c1f59646d98a48a;hp=797a51c20ebae07f0a41cf85de9e0e19ce34571b;hb=ebeaf99687d0fd6545c95983f0d91e2ddee7fbb7;hpb=520de300979cb6cf448cd23f729dd39368202a16 diff --git a/src/src/daemon.c b/src/src/daemon.c index 797a51c20..e844403a4 100644 --- a/src/src/daemon.c +++ b/src/src/daemon.c @@ -1,10 +1,10 @@ -/* $Cambridge: exim/src/src/daemon.c,v 1.17 2006/11/06 11:27:54 ph10 Exp $ */ +/* $Cambridge: exim/src/src/daemon.c,v 1.23 2007/03/14 12:15:56 ph10 Exp $ */ /************************************************* * Exim - an Internet mail transport agent * *************************************************/ -/* Copyright (c) University of Cambridge 1995 - 2006 */ +/* Copyright (c) University of Cambridge 1995 - 2007 */ /* See the file NOTICE for conditions of use and distribution. */ /* Functions concerned with running Exim as a daemon */ @@ -369,6 +369,8 @@ if (pid == 0) struct sigaction act; #endif + smtp_accept_count++; /* So that it includes this process */ + /* May have been modified for the subprocess */ log_write_selector = use_log_write_selector; @@ -459,7 +461,7 @@ if (pid == 0) configured value and may therefore already be TRUE. Leave logging till later so it will have a message id attached. */ - if (smtp_accept_queue > 0 && smtp_accept_count >= smtp_accept_queue) + if (smtp_accept_queue > 0 && smtp_accept_count > smtp_accept_queue) { local_queue_only = TRUE; queue_only_reason = 1; @@ -468,7 +470,12 @@ if (pid == 0) /* Handle the start of the SMTP session, then loop, accepting incoming messages from the SMTP connection. The end will come at the QUIT command, when smtp_setup_msg() returns 0. A break in the connection causes the - process to die (see accept.c). */ + process to die (see accept.c). + + 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 + (usually "connection refused: ") and writing another one is + unnecessary clutter. */ if (!smtp_start_session()) { @@ -500,6 +507,7 @@ if (pid == 0) if (!ok) /* Connection was dropped */ { mac_smtp_fflush(); + smtp_log_no_mail(); /* Log no mail if configured */ _exit(EXIT_SUCCESS); } if (message_id[0] == 0) continue; /* No message was accepted */ @@ -508,6 +516,7 @@ if (pid == 0) { mac_smtp_fflush(); search_tidyup(); + smtp_log_no_mail(); /* Log no mail if configured */ _exit((rc == 0)? EXIT_SUCCESS : EXIT_FAILURE); } @@ -872,6 +881,7 @@ There are no arguments to this function, and it never returns. */ void daemon_go(void) { +struct passwd *pw; int *listen_sockets = NULL; int listen_socket_count = 0; ip_address_item *addresses = NULL; @@ -1444,6 +1454,14 @@ cannot do this. */ exim_setugid(exim_uid, exim_gid, geteuid()==root_uid, US"running as a daemon"); +/* Update the originator_xxx fields so that received messages as listed as +coming from Exim, not whoever started the daemon. */ + +originator_uid = exim_uid; +originator_gid = exim_gid; +originator_login = ((pw = getpwuid(exim_uid)) != NULL)? + string_copy_malloc(US pw->pw_name) : US"exim"; + /* Get somewhere to keep the list of queue-runner pids if we are keeping track of them (and also if we are doing queue runs). */ @@ -1629,6 +1647,8 @@ for (;;) { uschar opt[8]; uschar *p = opt; + uschar *extra[4]; + int extracount = 1; signal(SIGALRM, SIG_DFL); *p++ = '-'; @@ -1639,8 +1659,29 @@ for (;;) if (deliver_force_thaw) *p++ = 'f'; if (queue_run_local) *p++ = 'l'; *p = 0; + extra[0] = opt; + + /* If -R or -S were on the original command line, ensure they get + passed on. */ + + if (deliver_selectstring != NULL) + { + extra[extracount++] = deliver_selectstring_regex? US"-Rr" : US"-R"; + extra[extracount++] = deliver_selectstring; + } + + if (deliver_selectstring_sender != NULL) + { + extra[extracount++] = deliver_selectstring_sender_regex? + US"-Sr" : US"-S"; + extra[extracount++] = deliver_selectstring_sender; + } + + /* Overlay this process with a new execution. */ + + (void)child_exec_exim(CEE_EXEC_PANIC, FALSE, NULL, TRUE, extracount, + extra[0], extra[1], extra[2], extra[3], extra[4]); - (void)child_exec_exim(CEE_EXEC_PANIC, FALSE, NULL, TRUE, 1, opt); /* Control never returns here. */ }