-/* $Cambridge: exim/src/src/transports/smtp.c,v 1.27 2006/10/09 14:36:25 ph10 Exp $ */
+/* $Cambridge: exim/src/src/transports/smtp.c,v 1.32 2007/01/22 16:29:55 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. */
#include "../exim.h"
to be publicly visible; these are flagged with opt_public. */
optionlist smtp_transport_options[] = {
+ { "address_retry_include_sender", opt_bool,
+ (void *)offsetof(smtp_transport_options_block, address_retry_include_sender) },
{ "allow_localhost", opt_bool,
(void *)offsetof(smtp_transport_options_block, allow_localhost) },
{ "authenticated_sender", opt_stringptr,
(void *)offsetof(smtp_transport_options_block, final_timeout) },
{ "gethostbyname", opt_bool,
(void *)offsetof(smtp_transport_options_block, gethostbyname) },
+ #ifdef SUPPORT_TLS
+ { "gnutls_require_kx", opt_stringptr,
+ (void *)offsetof(smtp_transport_options_block, gnutls_require_kx) },
+ { "gnutls_require_mac", opt_stringptr,
+ (void *)offsetof(smtp_transport_options_block, gnutls_require_mac) },
+ { "gnutls_require_protocols", opt_stringptr,
+ (void *)offsetof(smtp_transport_options_block, gnutls_require_proto) },
+ #endif
{ "helo_data", opt_stringptr,
(void *)offsetof(smtp_transport_options_block, helo_data) },
{ "hosts", opt_stringptr,
1024, /* size_addition */
5, /* hosts_max_try */
50, /* hosts_max_try_hardlimit */
+ TRUE, /* address_retry_include_sender */
FALSE, /* allow_localhost */
FALSE, /* authenticated_sender_force */
FALSE, /* gethostbyname */
NULL, /* tls_crl */
NULL, /* tls_privatekey */
NULL, /* tls_require_ciphers */
+ NULL, /* gnutls_require_kx */
+ NULL, /* gnutls_require_mac */
+ NULL, /* gnutls_require_proto */
NULL, /* tls_verify_certificates */
TRUE /* tls_tempfail_tryclear */
#endif
static uschar *smtp_command; /* Points to last cmd for error messages */
static uschar *mail_command; /* Points to MAIL cmd for error messages */
+static BOOL update_waiting; /* TRUE to update the "wait" database */
/*************************************************
converted to OK at the end.
Arguments:
- addrlist the complete address list
- include_affixes TRUE if affixes include in RCPT
- sync_addr ptr to the ptr of the one to start scanning at (updated)
- host the host we are connected to
- count the number of responses to read
- pending_MAIL true if the first response is for MAIL
- pending_DATA 0 if last command sent was not DATA
- +1 if previously had a good recipient
- -1 if not previously had a good recipient
- inblock incoming SMTP block
- timeout timeout value
- buffer buffer for reading response
- buffsize size of buffer
+ addrlist the complete address list
+ include_affixes TRUE if affixes include in RCPT
+ sync_addr ptr to the ptr of the one to start scanning at (updated)
+ host the host we are connected to
+ count the number of responses to read
+ address_retry_
+ include_sender true if 4xx retry is to include the sender it its key
+ pending_MAIL true if the first response is for MAIL
+ pending_DATA 0 if last command sent was not DATA
+ +1 if previously had a good recipient
+ -1 if not previously had a good recipient
+ inblock incoming SMTP block
+ timeout timeout value
+ buffer buffer for reading response
+ buffsize size of buffer
Returns: 3 if at least one address had 2xx and one had 5xx
2 if at least one address had 5xx but none had 2xx
static int
sync_responses(address_item *addrlist, BOOL include_affixes,
- address_item **sync_addr, host_item *host, int count, BOOL pending_MAIL,
+ address_item **sync_addr, host_item *host, int count,
+ BOOL address_retry_include_sender, BOOL pending_MAIL,
int pending_DATA, smtp_inblock *inblock, int timeout, uschar *buffer,
int buffsize)
{
transport_rcpt_address(addr, include_affixes));
set_errno(addrlist, save_errno, message, DEFER, FALSE);
retry_add_item(addr, addr->address_retry_key, 0);
- host->update_waiting = FALSE;
+ update_waiting = FALSE;
return -1;
}
if (host->next != NULL) log_write(0, LOG_MAIN, "%s", addr->message);
- /* Do not put this message on the list of those waiting for this host,
- as otherwise it is likely to be tried too often. */
+ /* Do not put this message on the list of those waiting for specific
+ hosts, as otherwise it is likely to be tried too often. */
- host->update_waiting = FALSE;
+ update_waiting = FALSE;
- /* Add a retry item for the address so that it doesn't get tried
- again too soon. */
+ /* Add a retry item for the address so that it doesn't get tried again
+ too soon. If address_retry_include_sender is true, add the sender address
+ to the retry key. */
- retry_add_item(addr, addr->address_retry_key, 0);
+ if (address_retry_include_sender)
+ {
+ uschar *altkey = string_sprintf("%s:<%s>", addr->address_retry_key,
+ sender_address);
+ retry_add_item(addr, altkey, 0);
+ }
+ else retry_add_item(addr, addr->address_retry_key, 0);
}
}
} /* Loop for next RCPT response */
else
{
- int rc = tls_client_start(inblock.sock, host, addrlist,
+ int rc = tls_client_start(inblock.sock,
+ host,
+ addrlist,
NULL, /* No DH param */
ob->tls_certificate,
ob->tls_privatekey,
ob->tls_verify_certificates,
ob->tls_crl,
ob->tls_require_ciphers,
+ ob->gnutls_require_mac,
+ ob->gnutls_require_kx,
+ ob->gnutls_require_proto,
ob->command_timeout);
/* TLS negotiation failed; give an error. From outside, this function may
if (count > 0)
{
switch(sync_responses(first_addr, tblock->rcpt_include_affixes,
- &sync_addr, host, count, pending_MAIL, 0, &inblock,
- ob->command_timeout, buffer, sizeof(buffer)))
+ &sync_addr, host, count, ob->address_retry_include_sender,
+ pending_MAIL, 0, &inblock, ob->command_timeout, buffer,
+ sizeof(buffer)))
{
case 3: ok = TRUE; /* 2xx & 5xx => OK & progress made */
case 2: completed_address = TRUE; /* 5xx (only) => progress made */
int count = smtp_write_command(&outblock, FALSE, "DATA\r\n");
if (count < 0) goto SEND_FAILED;
switch(sync_responses(first_addr, tblock->rcpt_include_affixes, &sync_addr,
- host, count, pending_MAIL, ok? +1 : -1, &inblock,
- ob->command_timeout, buffer, sizeof(buffer)))
+ host, count, ob->address_retry_include_sender, pending_MAIL,
+ ok? +1 : -1, &inblock, ob->command_timeout, buffer, sizeof(buffer)))
{
case 3: ok = TRUE; /* 2xx & 5xx => OK & progress made */
case 2: completed_address = TRUE; /* 5xx (only) => progress made */
/* Ensure the journal file is pushed out to disk. */
- if (fsync(journal_fd) < 0)
+ if (EXIMfsync(journal_fd) < 0)
log_write(0, LOG_MAIN|LOG_PANIC, "failed to fsync journal: %s",
strerror(errno));
}
continue_hostname, continue_host_address);
}
+/* Set the flag requesting that these hosts be added to the waiting
+database if the delivery fails temporarily or if we are running with
+queue_smtp or a 2-stage queue run. This gets unset for certain
+kinds of error, typically those that are specific to the message. */
+
+update_waiting = TRUE;
+
/* If a host list is not defined for the addresses - they must all have the
same one in order to be passed to a single transport - or if the transport has
a host list with hosts_override set, use the host list supplied with the
nexthost = host->next;
- /* Set the flag requesting that this host be added to the waiting
- database if the delivery fails temporarily or if we are running with
- queue_smtp or a 2-stage queue run. This gets unset for certain
- kinds of error, typically those that are specific to the message. */
-
- host->update_waiting = TRUE;
-
/* If the address hasn't yet been obtained from the host name, look it up
now, unless the host is already marked as unusable. If it is marked as
unusable, it means that the router was unable to find its IP address (in
/* If there was a retry message key, implying that previously there
was a message-specific defer, we don't want to update the list of
- messages waiting for this host. */
+ messages waiting for these hosts. */
- if (retry_message_key != NULL) host->update_waiting = FALSE;
+ if (retry_message_key != NULL) update_waiting = FALSE;
continue; /* With the next host or IP address */
}
}
to the retry chain. Note that if there was a message defer but now there is
a host defer, the message defer record gets deleted. That seems perfectly
reasonable. Also, stop the message from being remembered as waiting
- for this host. */
+ for specific hosts. */
if (message_defer || retry_message_key != NULL)
{
}
retry_add_item(addrlist, retry_message_key,
rf_message | rf_host | delete_flag);
- host->update_waiting = FALSE;
+ update_waiting = FALSE;
}
/* Any return other than DEFER (that is, OK or ERROR) means that the
}
/* Update the database which keeps information about which messages are waiting
-for which hosts to become available. Each host in the list has a flag which is
-set if the data is to be updated. For some message-specific errors, the flag is
-turned off because we don't want follow-on deliveries in those cases. */
+for which hosts to become available. For some message-specific errors, the
+update_waiting flag is turned off because we don't want follow-on deliveries in
+those cases. */
-transport_update_waiting(hostlist, tblock->name);
+if (update_waiting) transport_update_waiting(hostlist, tblock->name);
END_TRANSPORT: