X-Git-Url: https://git.netwichtig.de/gitweb/?a=blobdiff_plain;f=src%2Fsrc%2Ftransports%2Fsmtp.c;h=9f86033231d093f5a750f6bf0d05eb8836a38570;hb=30795c5e77e21e90f3c695e6274bc9b4a9b68900;hp=03243f3fc7dd35258db4ef6ee323262a2a8eea7e;hpb=14ca5d2ac6c3536fe189435269a302ef14e972cf;p=user%2Fhenk%2Fcode%2Fexim.git diff --git a/src/src/transports/smtp.c b/src/src/transports/smtp.c index 03243f3fc..9f8603323 100644 --- a/src/src/transports/smtp.c +++ b/src/src/transports/smtp.c @@ -281,7 +281,7 @@ smtp_transport_options_block smtp_transport_option_defaults = { .gethostbyname = FALSE, .dns_qualify_single = TRUE, .dns_search_parents = FALSE, - .dnssec = { .request=NULL, .require=NULL }, + .dnssec = { .request= US"*", .require=NULL }, .delay_after_cutoff = TRUE, .hosts_override = FALSE, .hosts_randomize = FALSE, @@ -814,6 +814,10 @@ if (!smtp_read_response(sx, sx->buffer, sizeof(sx->buffer), '2', #ifdef EXPERIMENTAL_DSN_INFO sx->helo_response = string_copy(sx->buffer); #endif +#ifndef DISABLE_EVENT +(void) event_raise(sx->conn_args.tblock->event_action, + US"smtp:ehlo", sx->buffer); +#endif return TRUE; } @@ -1609,77 +1613,6 @@ return FALSE; -#ifdef SUPPORT_DANE -/* Lookup TLSA record for host/port. -Return: OK success with dnssec; DANE mode - DEFER Do not use this host now, may retry later - FAIL_FORCED No TLSA record; DANE not usable - FAIL Do not use this connection -*/ - -int -tlsa_lookup(const host_item * host, dns_answer * dnsa, BOOL dane_required) -{ -/* move this out to host.c given the similarity to dns_lookup() ? */ -uschar buffer[300]; -const uschar * fullname = buffer; -int rc; -BOOL sec; - -/* TLSA lookup string */ -(void)sprintf(CS buffer, "_%d._tcp.%.256s", host->port, host->name); - -rc = dns_lookup(dnsa, buffer, T_TLSA, &fullname); -sec = dns_is_secure(dnsa); -DEBUG(D_transport) - debug_printf("TLSA lookup ret %d %sDNSSEC\n", rc, sec ? "" : "not "); - -switch (rc) - { - case DNS_AGAIN: - return DEFER; /* just defer this TLS'd conn */ - - case DNS_SUCCEED: - if (sec) - { - DEBUG(D_transport) - { - dns_scan dnss; - for (dns_record * rr = dns_next_rr(dnsa, &dnss, RESET_ANSWERS); rr; - rr = dns_next_rr(dnsa, &dnss, RESET_NEXT)) - if (rr->type == T_TLSA && rr->size > 3) - { - uint16_t payload_length = rr->size - 3; - uschar s[MAX_TLSA_EXPANDED_SIZE], * sp = s, * p = US rr->data; - - sp += sprintf(CS sp, "%d ", *p++); /* usage */ - sp += sprintf(CS sp, "%d ", *p++); /* selector */ - sp += sprintf(CS sp, "%d ", *p++); /* matchtype */ - while (payload_length-- > 0 && sp-s < (MAX_TLSA_EXPANDED_SIZE - 4)) - sp += sprintf(CS sp, "%02x", *p++); - - debug_printf(" %s\n", s); - } - } - return OK; - } - log_write(0, LOG_MAIN, - "DANE error: TLSA lookup for %s not DNSSEC", host->name); - /*FALLTRHOUGH*/ - - case DNS_NODATA: /* no TLSA RR for this lookup */ - case DNS_NOMATCH: /* no records at all for this lookup */ - return dane_required ? FAIL : FAIL_FORCED; - - default: - case DNS_FAIL: - return dane_required ? FAIL : DEFER; - } -} -#endif - - - typedef struct smtp_compare_s { uschar *current_sender_address; @@ -1963,7 +1896,6 @@ smtp_transport_options_block * ob = sx->conn_args.tblock->options_block; BOOL pass_message = FALSE; uschar * message = NULL; int yield = OK; -int rc; #ifndef DISABLE_TLS uschar * tls_errstr; #endif @@ -2074,6 +2006,7 @@ if (!continue_hostname) if (sx->conn_args.host->dnssec == DS_YES) { + int rc; if( sx->dane_required || verify_check_given_host(CUSS &ob->hosts_try_dane, sx->conn_args.host) == OK ) @@ -3336,7 +3269,7 @@ if ((rc = fork())) _exit(rc < 0 ? EXIT_FAILURE : EXIT_SUCCESS); } -if (f.running_in_test_harness) millisleep(100); /* let parent debug out */ +testharness_pause_ms(100); /* let parent debug out */ set_process_info("proxying TLS connection for continued transport"); FD_ZERO(&rfds); FD_SET(tls_out.active.sock, &rfds); @@ -3410,7 +3343,7 @@ for (int fd_bits = 3; fd_bits; ) } done: - if (f.running_in_test_harness) millisleep(100); /* let logging complete */ + testharness_pause_ms(100); /* let logging complete */ exim_exit(0, US"TLS proxy"); } #endif @@ -3638,7 +3571,8 @@ for handling the SMTP dot-handling protocol, flagging to apply to headers as well as body. Set the appropriate timeout value to be used for each chunk. (Haven't been able to make it work using select() for writing yet.) */ -if (!(sx.peer_offered & OPTION_CHUNKING) && !sx.ok) +if ( !sx.ok + && (!(sx.peer_offered & OPTION_CHUNKING) || !pipelining_active)) { /* Save the first address of the next batch. */ sx.first_addr = sx.next_addr; @@ -3699,6 +3633,11 @@ else transport_count = 0; #ifndef DISABLE_DKIM + { +# ifdef MEASURE_TIMING + struct timeval t0; + gettimeofday(&t0, NULL); +# endif dkim_exim_sign_init(); # ifdef EXPERIMENTAL_ARC { @@ -3723,6 +3662,10 @@ else } } # endif +# ifdef MEASURE_TIMING + report_time_since(&t0, US"dkim_exim_sign_init (delta)"); +# endif + } sx.ok = dkim_transport_write_message(&tctx, &ob->dkim, CUSS &message); #else sx.ok = transport_write_message(&tctx, 0); @@ -4272,7 +4215,7 @@ if (sx.completed_addr && sx.ok && sx.send_quit) /* Set up a pipe for proxying TLS for the new transport process */ smtp_peer_options |= OPTION_TLS; - if (sx.ok = (socketpair(AF_UNIX, SOCK_STREAM, 0, pfd) == 0)) + if ((sx.ok = socketpair(AF_UNIX, SOCK_STREAM, 0, pfd) == 0)) socket_fd = pfd[1]; else set_errno(sx.first_addr, errno, US"internal allocation problem", @@ -4309,7 +4252,7 @@ propagate it from the initial int pid = fork(); if (pid == 0) /* child; fork again to disconnect totally */ { - if (f.running_in_test_harness) millisleep(100); /* let parent debug out */ + testharness_pause_ms(100); /* let parent debug out */ /* does not return */ smtp_proxy_tls(sx.cctx.tls_ctx, sx.buffer, sizeof(sx.buffer), pfd, ob->command_timeout); @@ -4390,7 +4333,8 @@ HDEBUG(D_transport|D_acl|D_v) debug_printf_indent(" SMTP(close)>>\n"); if (sx.send_quit) { shutdown(sx.cctx.sock, SHUT_WR); - millisleep(f.running_in_test_harness ? 200 : 20); + millisleep(20); + testharness_pause_ms(200); if (fcntl(sx.cctx.sock, F_SETFL, O_NONBLOCK) == 0) for (int i = 16; read(sx.cctx.sock, sx.inbuffer, sizeof(sx.inbuffer)) > 0 && i > 0;) i--; /* drain socket */ @@ -5344,7 +5288,7 @@ retry_non_continued: ob->hosts_max_try_hardlimit); } - if (f.running_in_test_harness) millisleep(500); /* let server debug out */ + testharness_pause_ms(500); /* let server debug out */ } /* End of loop for trying multiple hosts. */ /* If we failed to find a matching host in the list, for an already-open