X-Git-Url: https://git.exim.org/exim.git/blobdiff_plain/a96603a0e5a7283a9275fb090dac95a42e05a423..80a47a2c9633437d4ceebd214cd44abfbd4f4543:/src/src/exim.c diff --git a/src/src/exim.c b/src/src/exim.c index 3a89d8b91..77d27ab53 100644 --- a/src/src/exim.c +++ b/src/src/exim.c @@ -1,4 +1,4 @@ -/* $Cambridge: exim/src/src/exim.c,v 1.56 2007/06/19 14:41:31 ph10 Exp $ */ +/* $Cambridge: exim/src/src/exim.c,v 1.62 2009/06/10 07:34:04 tom Exp $ */ /************************************************* * Exim - an Internet mail transport agent * @@ -905,6 +905,9 @@ fprintf(f, "Support for:"); #ifdef WITH_CONTENT_SCAN fprintf(f, " Content_Scanning"); #endif +#ifndef DISABLE_DKIM + fprintf(f, " DKIM"); +#endif #ifdef WITH_OLD_DEMIME fprintf(f, " Old_Demime"); #endif @@ -917,8 +920,8 @@ fprintf(f, "Support for:"); #ifdef EXPERIMENTAL_BRIGHTMAIL fprintf(f, " Experimental_Brightmail"); #endif -#ifdef EXPERIMENTAL_DOMAINKEYS - fprintf(f, " Experimental_DomainKeys"); +#ifdef EXPERIMENTAL_DCC + fprintf(f, " Experimental_DCC"); #endif fprintf(f, "\n"); @@ -1232,6 +1235,43 @@ return yield; +/************************************************* +* Output usage information for the program * +*************************************************/ + +/* This function is called when there are no recipients + or a specific --help argument was added. + +Arguments: + progname information on what name we were called by + +Returns: DOES NOT RETURN +*/ + +static void +exim_usage(uschar *progname) +{ + +/* Handle specific program invocation varients */ +if (Ustrcmp(progname, US"-mailq") == 0) + { + fprintf(stderr, + "mailq - list the contents of the mail queue\n\n" + "For a list of options, see the Exim documentation.\n"); + exit(EXIT_FAILURE); + } + +/* Generic usage - we output this whatever happens */ +fprintf(stderr, + "Exim is a Mail Transfer Agent. It is normally called by Mail User Agents,\n" + "not directly from a shell command line. Options and/or arguments control\n" + "what it does when called. For a list of options, see the Exim documentation.\n"); + +exit(EXIT_FAILURE); +} + + + /************************************************* * Entry point and high-level code * *************************************************/ @@ -1291,8 +1331,10 @@ BOOL one_msg_action = FALSE; BOOL queue_only_set = FALSE; BOOL receiving_message = TRUE; BOOL sender_ident_set = FALSE; +BOOL session_local_queue_only; BOOL unprivileged; BOOL removed_privilege = FALSE; +BOOL usage_wanted = FALSE; BOOL verify_address_mode = FALSE; BOOL verify_as_sender = FALSE; BOOL version_printed = FALSE; @@ -1587,10 +1629,15 @@ running in an unprivileged state. */ unprivileged = (real_uid != root_uid && original_euid != root_uid); -/* If the first argument is --help, pretend there are no arguments. This will -cause a brief message to be given. */ +/* If the first argument is --help, set usage_wanted and pretend there +are no arguments. This will cause a brief message to be given. We do +the message generation downstream so we can pick up how we were invoked */ -if (argc > 1 && Ustrcmp(argv[1], "--help") == 0) argc = 1; +if (argc > 1 && Ustrcmp(argv[1], "--help") == 0) + { + argc = 1; + usage_wanted = TRUE; + } /* Scan the program's arguments. Some can be dealt with right away; others are simply recorded for checking and handling afterwards. Do a high-level switch @@ -2925,9 +2972,11 @@ if ((deliver_selectstring != NULL || deliver_selectstring_sender != NULL) && queue_interval < 0) queue_interval = 0; -/* Arguments have been processed. Check for incompatibilities. */ - END_ARG: +/* If usage_wanted is set we call the usage function - which never returns */ +if (usage_wanted) exim_usage(called_as); + +/* Arguments have been processed. Check for incompatibilities. */ if (( (smtp_input || extract_recipients || recipients_arg < argc) && (daemon_listen || queue_interval >= 0 || bi_option || @@ -3643,7 +3692,7 @@ if (receiving_message && (is_inetd && smtp_load_reserve >= 0) )) { - load_average = os_getloadavg(); + load_average = OS_GETLOADAVG(); } #endif @@ -4423,14 +4472,9 @@ if (recipients_arg >= argc && !extract_recipients && !smtp_input) printf("Configuration file is %s\n", config_main_filename); return EXIT_SUCCESS; } + if (filter_test == FTEST_NONE) - { - fprintf(stderr, -"Exim is a Mail Transfer Agent. It is normally called by Mail User Agents,\n" -"not directly from a shell command line. Options and/or arguments control\n" -"what it does when called. For a list of options, see the Exim documentation.\n"); - return EXIT_FAILURE; - } + exim_usage(called_as); } @@ -4528,11 +4572,11 @@ else sender_address); } -/* Initialize the local_queue-only flag (this will be ignored if mua_wrapper is -set) */ +/* Initialize the session_local_queue-only flag (this will be ignored if +mua_wrapper is set) */ queue_check_only(); -local_queue_only = queue_only; +session_local_queue_only = queue_only; /* For non-SMTP and for batched SMTP input, check that there is enough space on the spool if so configured. On failure, we must not attempt to send an error @@ -4891,27 +4935,36 @@ while (more) } /* Else act on the result of message reception. We should not get here unless - message_id[0] is non-zero. If queue_only is set, local_queue_only will be - TRUE. If it is not, check on the number of messages received in this - connection. If that's OK and queue_only_load is set, check that the load - average is below it. If it is not, set local_queue_only TRUE. Note that it - then remains this way for any subsequent messages on the same SMTP connection. - This is a deliberate choice; even though the load average may fall, it - doesn't seem right to deliver later messages on the same call when not - delivering earlier ones. */ - - if (!local_queue_only) + message_id[0] is non-zero. If queue_only is set, session_local_queue_only + will be TRUE. If it is not, check on the number of messages received in this + connection. */ + + if (!session_local_queue_only && + smtp_accept_queue_per_connection > 0 && + receive_messagecount > smtp_accept_queue_per_connection) { - if (smtp_accept_queue_per_connection > 0 && - receive_messagecount > smtp_accept_queue_per_connection) - { - local_queue_only = TRUE; - queue_only_reason = 2; - } - else if (queue_only_load >= 0) + session_local_queue_only = TRUE; + queue_only_reason = 2; + } + + /* Initialize local_queue_only from session_local_queue_only. If it is false, + and queue_only_load is set, check that the load average is below it. If it is + not, set local_queue_only TRUE. If queue_only_load_latch is true (the + default), we put the whole session into queue_only mode. It then remains this + way for any subsequent messages on the same SMTP connection. This is a + deliberate choice; even though the load average may fall, it doesn't seem + right to deliver later messages on the same call when not delivering earlier + ones. However, there are odd cases where this is not wanted, so this can be + changed by setting queue_only_load_latch false. */ + + local_queue_only = session_local_queue_only; + if (!local_queue_only && queue_only_load >= 0) + { + local_queue_only = (load_average = OS_GETLOADAVG()) > queue_only_load; + if (local_queue_only) { - local_queue_only = (load_average = os_getloadavg()) > queue_only_load; - if (local_queue_only) queue_only_reason = 3; + queue_only_reason = 3; + if (queue_only_load_latch) session_local_queue_only = TRUE; } }