From: Jeremy Harris Date: Mon, 1 Aug 2016 17:38:22 +0000 (+0100) Subject: receive with DKIM X-Git-Tag: exim-4_88_RC1~52^2~5 X-Git-Url: https://vcs.fsf.org/?a=commitdiff_plain;h=584e96c65f12aca9414450b656504af6e3f7a399;p=exim.git receive with DKIM --- diff --git a/src/src/dkim.c b/src/src/dkim.c index 24de2bc33..a09ec7eca 100644 --- a/src/src/dkim.c +++ b/src/src/dkim.c @@ -88,6 +88,9 @@ if (dkim_verify_ctx) dkim_verify_ctx = pdkim_init_verify(&dkim_exim_query_dns_txt); dkim_collect_input = !!dkim_verify_ctx; +/* Start feed up with any cached data */ +receive_get_cache(); + store_pool = dkim_verify_oldpool; } diff --git a/src/src/functions.h b/src/src/functions.h index 260b365df..8d47a0da1 100644 --- a/src/src/functions.h +++ b/src/src/functions.h @@ -56,6 +56,7 @@ extern int tls_feof(void); extern int tls_ferror(void); extern void tls_free_cert(void **); extern int tls_getc(void); +extern void tls_get_cache(void); extern int tls_import_cert(const uschar *, void **); extern int tls_read(BOOL, uschar *, size_t); extern int tls_server_start(const uschar *); @@ -390,6 +391,7 @@ extern BOOL smtp_get_interface(uschar *, int, address_item *, uschar **, uschar *); extern BOOL smtp_get_port(uschar *, address_item *, int *, uschar *); extern int smtp_getc(void); +extern void smtp_get_cache(void); extern int smtp_handle_acl_fail(int, int, uschar *, uschar *); extern void smtp_log_no_mail(void); extern void smtp_message_code(uschar **, int *, uschar **, uschar **, BOOL); diff --git a/src/src/globals.c b/src/src/globals.c index 987c717fc..ba1336633 100644 --- a/src/src/globals.c +++ b/src/src/globals.c @@ -188,6 +188,7 @@ stand-alone tests. */ int (*lwr_receive_getc)(void) = stdin_getc; int (*lwr_receive_ungetc)(int) = stdin_ungetc; int (*receive_getc)(void) = stdin_getc; +void (*receive_get_cache)(void)= NULL; int (*receive_ungetc)(int) = stdin_ungetc; int (*receive_feof)(void) = stdin_feof; int (*receive_ferror)(void) = stdin_ferror; diff --git a/src/src/globals.h b/src/src/globals.h index 86ece2f30..f9af38ef5 100644 --- a/src/src/globals.h +++ b/src/src/globals.h @@ -141,6 +141,7 @@ incoming TCP/IP. */ extern int (*lwr_receive_getc)(void); extern int (*lwr_receive_ungetc)(int); extern int (*receive_getc)(void); +extern void (*receive_get_cache)(void); extern int (*receive_ungetc)(int); extern int (*receive_feof)(void); extern int (*receive_ferror)(void); diff --git a/src/src/smtp_in.c b/src/src/smtp_in.c index 3144b39ad..8994c6edb 100644 --- a/src/src/smtp_in.c +++ b/src/src/smtp_in.c @@ -352,6 +352,15 @@ if (smtp_inptr >= smtp_inend) return *smtp_inptr++; } +#ifndef DISABLE_DKIM +void +smtp_get_cache(void) +{ +int n = smtp_inend - smtp_inptr; +if (n > 0) + dkim_exim_verify_feed(smtp_inptr, n); +} +#endif /* Get a byte from the smtp input, in CHUNKING mode. Handle ack of the @@ -386,10 +395,14 @@ for(;;) /* If not the last, ack the received chunk. The last response is delayed until after the data ACL decides on it */ - /*XXX find that "last response" and append the chunk size */ if (chunking_state == CHUNKING_LAST) + { +#ifndef DISABLE_DKIM + dkim_exim_verify_feed(".\r\n", 3); /* for consistency with .-term MAIL */ +#endif return EOD; + } chunking_state = CHUNKING_OFFERED; smtp_printf("250 %u byte chunk received\r\n", chunking_datasize); @@ -2051,6 +2064,7 @@ smtp_inbuffer = (uschar *)malloc(in_buffer_size); if (smtp_inbuffer == NULL) log_write(0, LOG_MAIN|LOG_PANIC_DIE, "malloc() failed for SMTP input buffer"); receive_getc = smtp_getc; +receive_get_cache = smtp_get_cache; receive_ungetc = smtp_ungetc; receive_feof = smtp_feof; receive_ferror = smtp_ferror; diff --git a/src/src/tls-gnu.c b/src/src/tls-gnu.c index c7c6b2674..0774850ca 100644 --- a/src/src/tls-gnu.c +++ b/src/src/tls-gnu.c @@ -1879,6 +1879,7 @@ and initialize appropriately. */ state->xfer_buffer = store_malloc(ssl_xfer_buffer_size); receive_getc = tls_getc; +receive_get_cache = tls_get_cache; receive_ungetc = tls_ungetc; receive_feof = tls_feof; receive_ferror = tls_ferror; @@ -2179,6 +2180,7 @@ if (state->xfer_buffer_lwm >= state->xfer_buffer_hwm) DEBUG(D_tls) debug_printf("Got TLS_EOF\n"); receive_getc = smtp_getc; + receive_get_cache = smtp_get_cache; receive_ungetc = smtp_ungetc; receive_feof = smtp_feof; receive_ferror = smtp_ferror; @@ -2217,6 +2219,17 @@ if (state->xfer_buffer_lwm >= state->xfer_buffer_hwm) return state->xfer_buffer[state->xfer_buffer_lwm++]; } +#ifndef DISABLE_DKIM +void +tls_get_cache() +{ +exim_gnutls_state_st * state = &state_server; +int n = state->xfer_buffer_hwm - state->xfer_buffer_lwm; +if (n > 0) + dkim_exim_verify_feed(state->xfer_buffer+state->xfer_buffer_lwm, n); +} +#endif + diff --git a/src/src/tls-openssl.c b/src/src/tls-openssl.c index c24eb4544..242394f95 100644 --- a/src/src/tls-openssl.c +++ b/src/src/tls-openssl.c @@ -1943,6 +1943,7 @@ ssl_xfer_buffer_lwm = ssl_xfer_buffer_hwm = 0; ssl_xfer_eof = ssl_xfer_error = 0; receive_getc = tls_getc; +receive_get_cache = tls_get_cache; receive_ungetc = tls_ungetc; receive_feof = tls_feof; receive_ferror = tls_ferror; @@ -2313,6 +2314,7 @@ if (ssl_xfer_buffer_lwm >= ssl_xfer_buffer_hwm) DEBUG(D_tls) debug_printf("Got SSL_ERROR_ZERO_RETURN\n"); receive_getc = smtp_getc; + receive_get_cache = smtp_get_cache; receive_ungetc = smtp_ungetc; receive_feof = smtp_feof; receive_ferror = smtp_ferror; @@ -2358,6 +2360,16 @@ if (ssl_xfer_buffer_lwm >= ssl_xfer_buffer_hwm) return ssl_xfer_buffer[ssl_xfer_buffer_lwm++]; } +#ifndef DISABLE_DKIM +void +tls_get_cache() +{ +int n = ssl_xfer_buffer_hwm - ssl_xfer_buffer_lwm; +if (n > 0) + dkim_exim_verify_feed(ssl_xfer_buffer+ssl_xfer_buffer_lwm, n); +} +#endif + /************************************************* diff --git a/test/stderr/0487 b/test/stderr/0487 index b332f7f80..7f2ad5063 100644 --- a/test/stderr/0487 +++ b/test/stderr/0487 @@ -39,6 +39,7 @@ DSN: orcpt: NULL flags: 0 SMTP<< data SMTP>> 354 Enter message, ending with "." on a line by itself search_tidyup called +PDKIM >> Body data for hash, canonicalized >>>>>>>>>>>>>>>>>>>>>> >>Headers received: From: unqualified