transmit peer capability recognition
authorJeremy Harris <jgh146exb@wizmail.org>
Wed, 20 Jul 2016 15:49:24 +0000 (16:49 +0100)
committerJeremy Harris <jgh146exb@wizmail.org>
Tue, 2 Aug 2016 15:46:31 +0000 (16:46 +0100)
src/src/deliver.c
src/src/globals.c
src/src/globals.h
src/src/macros.h
src/src/transports/smtp.c
src/src/transports/smtp.h

index f99aa1819e4b89991fadd3fc498aac9ea24d80e5..450b58098e8f03f2a3d50d0f8d3531c5eb12325b 100644 (file)
@@ -8073,6 +8073,9 @@ if (!regex_STARTTLS) regex_STARTTLS =
   regex_must_compile(US"\\n250[\\s\\-]STARTTLS(\\s|\\n|$)", FALSE, TRUE);
 #endif
 
+if (!regex_CHUNKING) regex_CHUNKING =
+  regex_must_compile(US"\\n250[\\s\\-]CHUNKING(\\s|\\n|$)", FALSE, TRUE);
+
 #ifndef DISABLE_PRDR
 if (!regex_PRDR) regex_PRDR =
   regex_must_compile(US"\\n250[\\s\\-]PRDR(\\s|\\n|$)", FALSE, TRUE);
index c86b9478db6875798a742061db34cdc3dcb82c92..987c717fc7b5d99d9964711ea9ede0bf8b27b97a 100644 (file)
@@ -500,6 +500,7 @@ unsigned chunking_datasize     = 0;
 unsigned chunking_data_left    = 0;
 BOOL    chunking_offered       = FALSE;
 chunking_state_t chunking_state= CHUNKING_NOT_OFFERED;
+const pcre *regex_CHUNKING     = NULL;
 
 uschar *client_authenticator   = NULL;
 uschar *client_authenticated_id = NULL;
index c5767d73a46582368fd627864155f871af2a64ec..86ece2f3065358ac450ff2d5b9a8f4c683b0c09d 100644 (file)
@@ -718,6 +718,7 @@ extern int     recipients_max_reject;  /* If TRUE, reject whole message */
 extern const pcre *regex_AUTH;         /* For recognizing AUTH settings */
 extern const pcre  *regex_check_dns_names; /* For DNS name checking */
 extern const pcre  *regex_From;        /* For recognizing "From_" lines */
+extern const pcre  *regex_CHUNKING;    /* For recognizing CHUNKING (RFC 3030) */
 extern const pcre  *regex_IGNOREQUOTA; /* For recognizing IGNOREQUOTA (LMTP) */
 extern const pcre  *regex_PIPELINING;  /* For recognizing PIPELINING */
 extern const pcre  *regex_SIZE;        /* For recognizing SIZE settings */
index f567c7ec221177bcbfa2d0ae0481315587b27f1d..9b52fb775bacdea4531267761fd37314b2eaf180 100644 (file)
@@ -960,6 +960,7 @@ enum { FILTER_UNSET, FILTER_FORWARD, FILTER_EXIM, FILTER_SIEVE };
 #define PEER_OFFERED_DSN       BIT(4)
 #define PEER_OFFERED_PIPE      BIT(5)
 #define PEER_OFFERED_SIZE      BIT(6)
+#define PEER_OFFERED_CHUNKING  BIT(7)
 
 
 /* End of macros.h */
index 757a837dbc3fe2499a4242b8ab948bfe589a40aa..cd9ac04e2042f8f418d4abdc1fa0bbc1a01ae5c8 100644 (file)
@@ -116,6 +116,8 @@ optionlist smtp_transport_options[] = {
 #endif
   { "hosts_try_auth",       opt_stringptr,
       (void *)offsetof(smtp_transport_options_block, hosts_try_auth) },
+  { "hosts_try_chunking",   opt_stringptr,
+      (void *)offsetof(smtp_transport_options_block, hosts_try_chunking) },
 #if defined(SUPPORT_TLS) && defined(EXPERIMENTAL_DANE)
   { "hosts_try_dane",       opt_stringptr,
       (void *)offsetof(smtp_transport_options_block, hosts_try_dane) },
@@ -200,12 +202,13 @@ smtp_transport_options_block smtp_transport_option_defaults = {
   NULL,                /* serialize_hosts */
   NULL,                /* hosts_try_auth */
   NULL,                /* hosts_require_auth */
+  US"*",               /* hosts_try_chunking */
 #ifdef EXPERIMENTAL_DANE
   NULL,                /* hosts_try_dane */
   NULL,                /* hosts_require_dane */
 #endif
 #ifndef DISABLE_PRDR
-  US"*",                /* hosts_try_prdr */
+  US"*",               /* hosts_try_prdr */
 #endif
 #ifndef DISABLE_OCSP
   US"*",               /* hosts_request_ocsp (except under DANE; tls_client_start()) */
@@ -1325,6 +1328,10 @@ if (  checks & PEER_OFFERED_IGNQ
                PCRE_EOPT, NULL, 0) < 0)
   checks &= ~PEER_OFFERED_IGNQ;
 
+if (  checks & PEER_OFFERED_CHUNKING
+   && pcre_exec(regex_CHUNKING, NULL, CS buf, bsize, 0, PCRE_EOPT, NULL, 0) < 0)
+  checks &= ~PEER_OFFERED_CHUNKING;
+
 #ifndef DISABLE_PRDR
 if (  checks & PEER_OFFERED_PRDR
    && pcre_exec(regex_PRDR, NULL, CS buf, bsize, 0, PCRE_EOPT, NULL, 0) < 0)
@@ -1913,6 +1920,7 @@ if (continue_hostname == NULL
     peer_offered = ehlo_response(buffer, Ustrlen(buffer),
       0 /* no TLS */
       | (lmtp && ob->lmtp_ignore_quota ? PEER_OFFERED_IGNQ : 0)
+      | PEER_OFFERED_CHUNKING
       | PEER_OFFERED_PRDR
 #ifdef SUPPORT_I18N
       | (addrlist->prop.utf8_msg ? PEER_OFFERED_UTF8 : 0)
@@ -1944,6 +1952,13 @@ if (continue_hostname == NULL
   DEBUG(D_transport) debug_printf("%susing PIPELINING\n",
     smtp_use_pipelining ? "" : "not ");
 
+  if (  peer_offered & PEER_OFFERED_CHUNKING
+     && verify_check_given_host(&ob->hosts_try_chunking, host) != OK)
+    peer_offered &= ~PEER_OFFERED_CHUNKING;
+
+  if (peer_offered & PEER_OFFERED_CHUNKING)
+    {DEBUG(D_transport) debug_printf("CHUNKING usable\n");}
+
 #ifndef DISABLE_PRDR
   if (  peer_offered & PEER_OFFERED_PRDR
      && verify_check_given_host(&ob->hosts_try_prdr, host) != OK)
index 804b9942fd30370c840950ccab7a29a90762039a..d3666ae78850cc7df1d8db85dc6ae7a70be0b621 100644 (file)
@@ -21,6 +21,7 @@ typedef struct {
   uschar *serialize_hosts;
   uschar *hosts_try_auth;
   uschar *hosts_require_auth;
+  uschar *hosts_try_chunking;
 #ifdef EXPERIMENTAL_DANE
   uschar *hosts_try_dane;
   uschar *hosts_require_dane;