X-Git-Url: https://vcs.fsf.org/?a=blobdiff_plain;f=src%2Fsrc%2Freceive.c;h=efd0766e77ff3ae157f4517808c05d2ddb73f9f1;hb=e0fccd1ddccf02568e9f8e6af38e62513f306fe5;hp=d0fc0c25e8ec94966708e6afd295e112639ffd89;hpb=817d9f576cdfbc27cf0536be348645baf27d7836;p=exim.git diff --git a/src/src/receive.c b/src/src/receive.c index d0fc0c25e..efd0766e7 100644 --- a/src/src/receive.c +++ b/src/src/receive.c @@ -937,6 +937,38 @@ add_acl_headers(uschar *acl_name) header_line *h, *next; header_line *last_received = NULL; +if (acl_removed_headers != NULL) + { + DEBUG(D_receive|D_acl) debug_printf(">>Headers removed by %s ACL:\n", acl_name); + + for (h = header_list; h != NULL; h = h->next) + { + uschar *list; + BOOL include_header; + + if (h->type == htype_old) continue; + + include_header = TRUE; + list = acl_removed_headers; + + int sep = ':'; /* This is specified as a colon-separated list */ + uschar *s; + uschar buffer[128]; + while ((s = string_nextinlist(&list, &sep, buffer, sizeof(buffer))) + != NULL) + { + int len = Ustrlen(s); + if (header_testname(h, s, len, FALSE)) + { + h->type = htype_old; + DEBUG(D_receive|D_acl) debug_printf(" %s", h->text); + } + } + } + acl_removed_headers = NULL; + DEBUG(D_receive|D_acl) debug_printf(">>\n"); + } + if (acl_added_headers == NULL) return; DEBUG(D_receive|D_acl) debug_printf(">>Headers added by %s ACL:\n", acl_name); @@ -1369,7 +1401,7 @@ BOOL resents_exist = FALSE; uschar *resent_prefix = US""; uschar *blackholed_by = NULL; uschar *blackhole_log_msg = US""; -int cutthrough_done; +int cutthrough_done = 0; flock_t lock_data; error_block *bad_addresses = NULL; @@ -1415,7 +1447,7 @@ search_tidyup(); cutthrough delivery with the no-spool option. It shouldn't be possible to set up the combination, but just in case kill any ongoing connection. */ if (extract_recip || !smtp_input) - cancel_cutthrough_connection(); + cancel_cutthrough_connection("not smtp input"); /* Initialize the chain of headers by setting up a place-holder for Received: header. Temporarily mark it as "old", i.e. not to be used. We keep header_last @@ -2003,9 +2035,12 @@ for (h = header_list->next; h != NULL; h = h->next) from_header = h; if (!smtp_input) { + int len; uschar *s = Ustrchr(h->text, ':') + 1; while (isspace(*s)) s++; - if (strncmpic(s, originator_login, h->slen - (s - h->text) - 1) == 0) + len = h->slen - (s - h->text) - 1; + if (Ustrlen(originator_login) == len && + strncmpic(s, originator_login, len) == 0) { uschar *name = is_resent? US"Resent-From" : US"From"; header_add(htype_from, "%s: %s <%s@%s>\n", name, originator_name, @@ -2716,7 +2751,7 @@ if (cutthrough_fd >= 0) { if (received_count > received_headers_max) { - cancel_cutthrough_connection(); + cancel_cutthrough_connection("too many headers"); if (smtp_input) receive_swallow_smtp(); /* Swallow incoming SMTP */ log_write(0, LOG_MAIN|LOG_REJECT, "rejected from <%s>%s%s%s%s: " "Too many \"Received\" headers", @@ -2761,7 +2796,10 @@ if (data_fd < 0) /* Make sure the file's group is the Exim gid, and double-check the mode because the group setting doesn't always get set automatically. */ -(void)fchown(data_fd, exim_uid, exim_gid); +if (fchown(data_fd, exim_uid, exim_gid)) + log_write(0, LOG_MAIN|LOG_PANIC_DIE, + "Failed setting ownership on spool file %s: %s", + spool_name, strerror(errno)); (void)fchmod(data_fd, SPOOL_MODE); /* We now have data file open. Build a stream for it and lock it. We lock only @@ -2791,7 +2829,7 @@ if (next != NULL) { uschar *s = next->text; int len = next->slen; - (void)fwrite(s, 1, len, data_file); + len = fwrite(s, 1, len, data_file); len = len; /* compiler quietening */ body_linecount++; /* Assumes only 1 line */ } @@ -2816,7 +2854,7 @@ if (!ferror(data_file) && !(receive_feof)() && message_ended != END_DOT) if (smtp_input && message_ended == END_EOF) { Uunlink(spool_name); /* Lose data file when closed */ - cancel_cutthrough_connection(); + cancel_cutthrough_connection("sender closed connection"); message_id[0] = 0; /* Indicate no message accepted */ smtp_reply = handle_lost_connection(US""); smtp_yield = FALSE; @@ -2829,7 +2867,7 @@ if (!ferror(data_file) && !(receive_feof)() && message_ended != END_DOT) if (message_ended == END_SIZE) { Uunlink(spool_name); /* Lose the data file when closed */ - cancel_cutthrough_connection(); + cancel_cutthrough_connection("mail too big"); if (smtp_input) receive_swallow_smtp(); /* Swallow incoming SMTP */ log_write(L_size_reject, LOG_MAIN|LOG_REJECT, "rejected from <%s>%s%s%s%s: " @@ -2885,7 +2923,7 @@ if (fflush(data_file) == EOF || ferror(data_file) || log_write(0, LOG_MAIN, "Message abandoned: %s", msg); Uunlink(spool_name); /* Lose the data file */ - cancel_cutthrough_connection(); + cancel_cutthrough_connection("error writing spoolfile"); if (smtp_input) { @@ -3128,7 +3166,7 @@ else { DEBUG(D_receive) debug_printf("acl_smtp_dkim: acl_check returned %d on %s, skipping remaining items\n", rc, item); - cancel_cutthrough_connection(); + cancel_cutthrough_connection("dkim acl not ok"); break; } } @@ -3174,12 +3212,12 @@ else blackholed_by = US"DATA ACL"; if (log_msg != NULL) blackhole_log_msg = string_sprintf(": %s", log_msg); - cancel_cutthrough_connection(); + cancel_cutthrough_connection("data acl discard"); } else if (rc != OK) { Uunlink(spool_name); - cancel_cutthrough_connection(); + cancel_cutthrough_connection("data acl not ok"); #ifdef WITH_CONTENT_SCAN unspool_mbox(); #endif @@ -3570,12 +3608,26 @@ if (sender_host_authenticated != NULL) { s = string_append(s, &size, &sptr, 2, US" A=", sender_host_authenticated); if (authenticated_id != NULL) + { s = string_append(s, &size, &sptr, 2, US":", authenticated_id); + if (log_extra_selector & LX_smtp_mailauth && authenticated_sender != NULL) + s = string_append(s, &size, &sptr, 2, US":", authenticated_sender); + } } sprintf(CS big_buffer, "%d", msg_size); s = string_append(s, &size, &sptr, 2, US" S=", big_buffer); +/* log 8BITMIME mode announced in MAIL_FROM + 0 ... no BODY= used + 7 ... 7BIT + 8 ... 8BITMIME */ +if (log_extra_selector & LX_8bitmime) + { + sprintf(CS big_buffer, "%d", body_8bitmime); + s = string_append(s, &size, &sptr, 2, US" M8S=", big_buffer); + } + /* If an addr-spec in a message-id contains a quoted string, it can contain any characters except " \ and CR and so in particular it can contain NL! Therefore, make sure we use a printing-characters only version for the log. @@ -3756,6 +3808,7 @@ for this message. */ XXX We do not handle queue-only, freezing, or blackholes. */ +cutthrough_done = 0; if(cutthrough_fd >= 0) { uschar * msg= cutthrough_finaldot(); /* Ask the target system to accept the messsage */ @@ -3777,8 +3830,6 @@ if(cutthrough_fd >= 0) break; } } -else - cutthrough_done = 0; if(smtp_reply == NULL) {