X-Git-Url: https://git.netwichtig.de/gitweb/?a=blobdiff_plain;f=src%2Fsrc%2Ftransports%2Fsmtp.c;h=509ff1949d589d575814cd0275a49e24d7eb0664;hb=c51b8e75b2fe31282ea1526ed556d7d9402d543f;hp=887b1ff821a897630a95a73d7007e92d5b637de8;hpb=83da1223921fe30362e8374951360dcc8f21c4e7;p=user%2Fhenk%2Fcode%2Fexim.git diff --git a/src/src/transports/smtp.c b/src/src/transports/smtp.c index 887b1ff82..509ff1949 100644 --- a/src/src/transports/smtp.c +++ b/src/src/transports/smtp.c @@ -1,4 +1,4 @@ -/* $Cambridge: exim/src/src/transports/smtp.c,v 1.31 2007/01/18 15:35:43 ph10 Exp $ */ +/* $Cambridge: exim/src/src/transports/smtp.c,v 1.35 2007/02/06 14:49:13 ph10 Exp $ */ /************************************************* * Exim - an Internet mail transport agent * @@ -77,6 +77,8 @@ optionlist smtp_transport_options[] = { (void *)offsetof(smtp_transport_options_block, hosts) }, { "hosts_avoid_esmtp", opt_stringptr, (void *)offsetof(smtp_transport_options_block, hosts_avoid_esmtp) }, + { "hosts_avoid_pipelining", opt_stringptr, + (void *)offsetof(smtp_transport_options_block, hosts_avoid_pipelining) }, #ifdef SUPPORT_TLS { "hosts_avoid_tls", opt_stringptr, (void *)offsetof(smtp_transport_options_block, hosts_avoid_tls) }, @@ -160,6 +162,7 @@ smtp_transport_options_block smtp_transport_option_defaults = { NULL, /* hosts_require_auth */ NULL, /* hosts_require_tls */ NULL, /* hosts_avoid_tls */ + NULL, /* hosts_avoid_pipelining */ NULL, /* hosts_avoid_esmtp */ NULL, /* hosts_nopass_tls */ 5*60, /* command_timeout */ @@ -654,10 +657,16 @@ while (count-- > 0) addr->transport_return = PENDING_OK; /* If af_dr_retry_exists is set, there was a routing delay on this address; - ensure that any address-specific retry record is expunged. */ + ensure that any address-specific retry record is expunged. We do this both + for the basic key and for the version that also includes the sender. */ if (testflag(addr, af_dr_retry_exists)) + { + uschar *altkey = string_sprintf("%s:<%s>", addr->address_retry_key, + sender_address); + retry_add_item(addr, altkey, rf_delete); retry_add_item(addr, addr->address_retry_key, rf_delete); + } } /* Timeout while reading the response */ @@ -848,7 +857,7 @@ smtp_outblock outblock; int max_rcpt = tblock->max_addresses; uschar *igquotstr = US""; uschar *local_authenticated_sender = authenticated_sender; -uschar *helo_data; +uschar *helo_data = NULL; uschar *message = NULL; uschar new_message_id[MESSAGE_ID_LENGTH + 1]; uschar *p; @@ -877,17 +886,6 @@ outblock.ptr = outbuffer; outblock.cmd_count = 0; outblock.authenticating = FALSE; -/* Expand the greeting message */ - -helo_data = expand_string(ob->helo_data); -if (helo_data == NULL) - { - uschar *message = string_sprintf("failed to expand helo_data: %s", - expand_string_message); - set_errno(addrlist, 0, message, DEFER, FALSE); - return ERROR; - } - /* If an authenticated_sender override has been specified for this transport instance, expand it. If the expansion is forced to fail, and there was already an authenticated_sender for this message, the original value will be used. @@ -927,6 +925,12 @@ if (continue_hostname == NULL) return DEFER; } + /* Expand the greeting message while waiting for the initial response. (Makes + sense if helo_data contains ${lookup dnsdb ...} stuff). The expansion is + delayed till here so that $sending_interface and $sending_port are set. */ + + helo_data = expand_string(ob->helo_data); + /* The first thing is to wait for an initial OK response. The dreaded "goto" is nevertheless a reasonably clean way of programming this kind of logic, where you want to escape on any error. */ @@ -934,6 +938,18 @@ if (continue_hostname == NULL) if (!smtp_read_response(&inblock, buffer, sizeof(buffer), '2', ob->command_timeout)) goto RESPONSE_FAILED; + /* Now check if the helo_data expansion went well, and sign off cleanly if it + didn't. */ + + if (helo_data == NULL) + { + uschar *message = string_sprintf("failed to expand helo_data: %s", + expand_string_message); + set_errno(addrlist, 0, message, DEFER, FALSE); + yield = DEFER; + goto SEND_QUIT; + } + /** Debugging without sending a message addrlist->transport_return = DEFER; goto SEND_QUIT; @@ -1103,10 +1119,27 @@ if (tls_offered && !suppress_tls && } } -/* If we started TLS, redo the EHLO/LHLO exchange over the secure channel. */ +/* If we started TLS, redo the EHLO/LHLO exchange over the secure channel. If +helo_data is null, we are dealing with a connection that was passed from +another process, and so we won't have expanded helo_data above. We have to +expand it here. $sending_ip_address and $sending_port are set up right at the +start of the Exim process (in exim.c). */ if (tls_active >= 0) { + if (helo_data == NULL) + { + helo_data = expand_string(ob->helo_data); + if (helo_data == NULL) + { + uschar *message = string_sprintf("failed to expand helo_data: %s", + expand_string_message); + set_errno(addrlist, 0, message, DEFER, FALSE); + yield = DEFER; + goto SEND_QUIT; + } + } + if (smtp_write_command(&outblock, FALSE, "%s %s\r\n", lmtp? "LHLO" : "EHLO", helo_data) < 0) goto SEND_FAILED; @@ -1159,9 +1192,12 @@ if (continue_hostname == NULL PCRE_EOPT, NULL, 0) >= 0; /* Note whether the server supports PIPELINING. If hosts_avoid_esmtp matched - the current host, esmtp will be false, so PIPELINING can never be used. */ + the current host, esmtp will be false, so PIPELINING can never be used. If + the current host matches hosts_avoid_pipelining, don't do it. */ smtp_use_pipelining = esmtp && + verify_check_this_host(&(ob->hosts_avoid_pipelining), NULL, host->name, + host->address, NULL) != OK && pcre_exec(regex_PIPELINING, NULL, CS buffer, Ustrlen(CS buffer), 0, PCRE_EOPT, NULL, 0) >= 0; @@ -1690,7 +1726,7 @@ if (!ok) ok = TRUE; else /* 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)); }