Do not permit multi-component wildcards on certificate names (OpenSSL, EXPERIMENTAL_C...
authorJeremy Harris <jgh146exb@wizmail.org>
Wed, 5 Nov 2014 18:24:00 +0000 (18:24 +0000)
committerJeremy Harris <jgh146exb@wizmail.org>
Wed, 5 Nov 2014 19:02:19 +0000 (19:02 +0000)
27 files changed:
doc/doc-docbook/spec.xfpt
doc/doc-txt/ChangeLog
doc/doc-txt/experimental-spec.txt
src/src/deliver.c
src/src/exim.c
src/src/functions.h
src/src/host.c
src/src/route.c
src/src/smtp_out.c
src/src/tls-gnu.c
src/src/tls-openssl.c
src/src/transports/smtp.c
src/src/verify.c
test/README
test/aux-fixed/showenv
test/log/1008
test/runtest
test/scripts/0000-Basic/0390
test/scripts/1000-Basic-ipv6/1006
test/scripts/5420-cutthrough-GnuTLS/5420
test/src/client.c
test/src/fakens.c
test/src/mtpscript.c
test/src/server.c
test/stderr/5420
test/stdout/1006
test/stdout/1008

index 8552400cf9d75bba73eba66974548044050f0882..20bfb406ca04be42956d391bb3033a240ac38ef1 100644 (file)
@@ -12152,8 +12152,9 @@ the &%-bs%& or &%-bS%& options.
 
 .vitem &$sender_host_address$&
 .vindex "&$sender_host_address$&"
-When a message is received from a remote host, this variable contains that
-host's IP address. For locally submitted messages, it is empty.
+When a message is received from a remote host using SMTP,
+this variable contains that
+host's IP address. For locally non-SMTP submitted messages, it is empty.
 
 .vitem &$sender_host_authenticated$&
 .vindex "&$sender_host_authenticated$&"
@@ -15061,16 +15062,21 @@ yourself in the foot in various unpleasant ways.  This option should not be
 adjusted lightly.  An unrecognised item will be detected at startup, by
 invoking Exim with the &%-bV%& flag.
 
+The option affects Exim operating both as a server and as a client.
+
 Historical note: prior to release 4.80, Exim defaulted this value to
 "+dont_insert_empty_fragments", which may still be needed for compatibility
 with some clients, but which lowers security by increasing exposure to
 some now infamous attacks.
 
-An example:
+Examples:
 .code
 # Make both old MS and old Eudora happy:
 openssl_options = -all +microsoft_big_sslv3_buffer \
                        +dont_insert_empty_fragments
+
+# Disable older protocol versions:
+openssl_options = +no_sslv2 +no_sslv3
 .endd
 
 Possible options may include:
@@ -26130,7 +26136,8 @@ The GnuTLS library allows the caller to provide a "priority string", documented
 as part of the &[gnutls_priority_init]& function.  This is very similar to the
 ciphersuite specification in OpenSSL.
 
-The &%tls_require_ciphers%& option is treated as the GnuTLS priority string.
+The &%tls_require_ciphers%& option is treated as the GnuTLS priority string
+and controls both protocols and ciphers.
 
 The &%tls_require_ciphers%& option is available both as an global option,
 controlling how Exim behaves as a server, and also as an option of the
@@ -26147,6 +26154,12 @@ installed on your system.  If you are using GnuTLS 3,
 &url(http://www.gnutls.org/manual/gnutls.html#Listing-the-ciphersuites-in-a-priority-string, then the example code)
 on that site can be used to test a given string.
 
+For example:
+.code
+# Disable older versions of protocols
+tls_require_ciphers = NORMAL:%LATEST_RECORD_VERSION:-VERS-SSL3.0
+.endd
+
 Prior to Exim 4.80, an older API of GnuTLS was used, and Exim supported three
 additional options, "&%gnutls_require_kx%&", "&%gnutls_require_mac%&" and
 "&%gnutls_require_protocols%&".  &%tls_require_ciphers%& was an Exim list.
index b389a7deb6353b023b06dd24074fd4b8ebf14710..997a459c80fa35adbce2f5f6550299b0af5ba4c5 100644 (file)
@@ -59,6 +59,9 @@ JH/08 Rename the TPDA expermimental facility to Event Actions.  The #ifdef
       raised for inbound connections, if the main configuration event_action
       option is defined.
 
+TL/06 In test suite, disable OCSP for old versions of openssl which contained
+      early OCSP support, but no stapling (appears to be less than 1.0.0).
+
 JH/09 When compiled with OpenSSL and EXPERIMENTAL_CERTNAMES, the checks on
       server certificate names available under the smtp transport option
       "tls_verify_cert_hostname" now do not permit multi-component wildcard
index 8192f3d76ac4a190fbd67892a6e49e085093435d..266e198914d9e8b35ca5b1f8b9b2a095724d7ec7 100644 (file)
@@ -1154,9 +1154,13 @@ support to date has not made these checks.
 
 If built with EXPERIMENTAL_CERTNAMES defined, code is
 included to do so for server certificates, and a new smtp transport option
-"tls_verify_cert_hostname" supported which takes a list of
-names for which the checks must be made.  The host must
-also be in "tls_verify_hosts".
+"tls_verify_cert_hostnames" supported which takes a list of
+names for which the additional checks must be made.
+The option currently defaults to empty, but this may change in
+the future.  "*" is probably a suitable value.
+Whether certificate verification is done at all, and the result of
+it failing, is stll under the control of "tls_verify_hosts" nad
+"tls_try_verify_hosts".
 
 Both Subject and Subject-Alternate-Name certificate fields
 are supported, as are wildcard certificates (limited to
index 4cc05b4aed28fb55e31aab2b44d042ac185cd946..27a4344c50ce0aa751c2a8cdb63895018b614381 100644 (file)
@@ -719,7 +719,7 @@ d_tlslog(uschar * s, int * sizep, int * ptrp, address_item * addr)
 
 
 #ifdef EXPERIMENTAL_EVENT
-int
+uschar *
 event_raise(uschar * action, uschar * event, uschar * ev_data)
 {
 uschar * s;
@@ -747,10 +747,10 @@ if (action)
     {
     DEBUG(D_deliver)
       debug_printf("Event(%s): event_action returned \"%s\"\n", event, s);
-    return DEFER;
+    return s;
     }
   }
-return OK;
+return NULL;
 }
 
 static void
index 5faa6f97f16ae641de2d3b914b773fbdd97bc488..102d8504ca3df52ccf2539b8a03ab28e543d325e 100644 (file)
@@ -12,6 +12,13 @@ Also a few functions that don't naturally fit elsewhere. */
 
 #include "exim.h"
 
+#ifdef USE_GNUTLS
+# include <gnutls/gnutls.h>
+# if GNUTLS_VERSION_NUMBER < 0x030103 && !defined(DISABLE_OCSP)
+#  define DISABLE_OCSP
+# endif
+#endif
+
 extern void init_lookup_list(void);
 
 
index ba4760f7ac433a8fafcd0070e020d4ed5f0ef2f4..07d0eb4133b3466a2813e853a7170a16f06fbd55 100644 (file)
@@ -158,7 +158,7 @@ extern BOOL    dscp_lookup(const uschar *, int, int *, int *, int *);
 extern void    enq_end(uschar *);
 extern BOOL    enq_start(uschar *);
 #ifdef EXPERIMENTAL_EVENT
-extern int     event_raise(uschar *, uschar *, uschar *);
+extern uschar *event_raise(uschar *, uschar *, uschar *);
 #endif
 extern void    exim_exit(int);
 extern void    exim_nullstd(void);
index 2eef0ba700ee2e25e993c2555d5a356a138ffce3..7737704cdf3fffa0889784a9e9224f2f0dfb8aff 100644 (file)
@@ -3068,8 +3068,9 @@ DEBUG(D_host_lookup)
     yield);
   for (h = host; h != last->next; h = h->next)
     {
-    debug_printf("  %s %s MX=%d ", h->name,
-      (h->address == NULL)? US"<null>" : h->address, h->mx);
+    debug_printf("  %s %s MX=%d %s", h->name,
+      !h->address ? US"<null>" : h->address, h->mx,
+      h->dnssec == DS_YES ? US"DNSSEC " : US"");
     if (h->port != PORT_NONE) debug_printf("port=%d ", h->port);
     if (h->status >= hstatus_unusable) debug_printf("*");
     debug_printf("\n");
index 6ba1d9f10d02d83a88e06914ba5573bd7ca6a5ba..3834b836a2ca907e4324013250704c4839770de1 100644 (file)
@@ -1969,7 +1969,7 @@ DEBUG(D_route)
     if (h->mx >= 0) debug_printf(" MX=%d", h->mx);
       else if (h->mx != MX_NONE) debug_printf(" rgroup=%d", h->mx);
     if (h->port != PORT_NONE) debug_printf(" port=%d", h->port);
-    /* if (h->dnssec != DS_UNK) debug_printf(" dnssec=%s", h->dnssec==DS_YES ? "yes" : "no"); */
+    if (h->dnssec != DS_UNK) debug_printf(" dnssec=%s", h->dnssec==DS_YES ? "yes" : "no");
     debug_printf("\n");
     }
   }
index e3f2588d7a4ca6b788dd0a7af940019eb3fb29d5..530fcfec75687954629ba0d9471820191e290bc9 100644 (file)
@@ -204,10 +204,10 @@ HDEBUG(D_transport|D_acl|D_v)
   }
 
 #ifdef EXPERIMENTAL_EVENT
-  /*XXX Called from both delivery and verify.  Is that status observable? */
   deliver_host_address = host->address;
   deliver_host_port = port;
-  if (event_raise(event, US"tcp:connect", NULL) == DEFER) return -1;
+  if (event_raise(event, US"tcp:connect", NULL)) return -1;
+  /* Logging?  Debug? */
 #endif
 
 /* Create the socket */
index 1966c557dc0f440cc1b3d9c93caebd0344aed628..04de02d7431d1f59d64a34719d1033fc6df1c58f 100644 (file)
@@ -1559,6 +1559,7 @@ const gnutls_datum * cert_list;
 unsigned int cert_list_size = 0;
 gnutls_x509_crt_t crt;
 int rc;
+uschar * yield;
 exim_gnutls_state_st * state = gnutls_session_get_ptr(session);
 
 cert_list = gnutls_certificate_get_peers(session, &cert_list_size);
@@ -1574,11 +1575,12 @@ if (cert_list)
     }
 
   state->tlsp->peercert = crt;
-  if (event_raise(state->event_action,
-             US"tls:cert", string_sprintf("%d", cert_list_size)) == DEFER)
+  if ((yield = event_raise(state->event_action,
+             US"tls:cert", string_sprintf("%d", cert_list_size))))
     {
     log_write(0, LOG_MAIN,
-             "SSL verify denied by event-action: depth=%d", cert_list_size);
+             "SSL verify denied by event-action: depth=%d: %s",
+             cert_list_size, yield);
     return 1;                     /* reject */
     }
   state->tlsp->peercert = NULL;
index afc898ca723d6f5aa5ab196076c846ea21f05eea..63bf83b1dddc125ab5e03cea5c35c80676b66ea0 100644 (file)
@@ -294,8 +294,11 @@ verify_callback(int state, X509_STORE_CTX *x509ctx,
 {
 X509 * cert = X509_STORE_CTX_get_current_cert(x509ctx);
 int depth = X509_STORE_CTX_get_error_depth(x509ctx);
-uschar * ev;
 static uschar txt[256];
+#ifdef EXPERIMENTAL_EVENT
+uschar * ev;
+uschar * yield;
+#endif
 
 X509_NAME_oneline(X509_get_subject_name(cert), CS txt, sizeof(txt));
 
@@ -305,7 +308,6 @@ if (state == 0)
     depth,
     X509_verify_cert_error_string(X509_STORE_CTX_get_error(x509ctx)),
     txt);
-  tlsp->certificate_verified = FALSE;
   *calledp = TRUE;
   if (!*optionalp)
     {
@@ -335,13 +337,15 @@ else if (depth != 0)
   if (ev)
     {
     tlsp->peercert = X509_dup(cert);
-    if (event_raise(ev, US"tls:cert", string_sprintf("%d", depth)) == DEFER)
+    if ((yield = event_raise(ev, US"tls:cert", string_sprintf("%d", depth))))
       {
       log_write(0, LOG_MAIN, "SSL verify denied by event-action: "
-                             "depth=%d cert=%s", depth, txt);
-      tlsp->certificate_verified = FALSE;
+                             "depth=%d cert=%s: %s", depth, txt, yield);
       *calledp = TRUE;
-      return 0;                            /* reject */
+      if (!*optionalp)
+       return 0;                           /* reject */
+      DEBUG(D_tls) debug_printf("Event-action verify failure overridden "
+       "(host in tls_try_verify_hosts)\n");
       }
     X509_free(tlsp->peercert);
     tlsp->peercert = NULL;
@@ -390,7 +394,11 @@ else
       {
       log_write(0, LOG_MAIN,
        "SSL verify error: certificate name mismatch: \"%s\"\n", txt);
-      return 0;                                /* reject */
+      *calledp = TRUE;
+      if (!*optionalp)
+       return 0;                           /* reject */
+      DEBUG(D_tls) debug_printf("SSL verify failure overridden (host in "
+       "tls_try_verify_hosts)\n");
       }
     }
 # else
@@ -398,7 +406,11 @@ else
       {
       log_write(0, LOG_MAIN,
        "SSL verify error: certificate name mismatch: \"%s\"\n", txt);
-      return 0;                                /* reject */
+      *calledp = TRUE;
+      if (!*optionalp)
+       return 0;                           /* reject */
+      DEBUG(D_tls) debug_printf("SSL verify failure overridden (host in "
+       "tls_try_verify_hosts)\n");
       }
 # endif
 #endif /*EXPERIMENTAL_CERTNAMES*/
@@ -406,13 +418,15 @@ else
 #ifdef EXPERIMENTAL_EVENT
   ev = tlsp == &tls_out ? client_static_cbinfo->event_action : event_action;
   if (ev)
-    if (event_raise(ev, US"tls:cert", US"0") == DEFER)
+    if ((yield = event_raise(ev, US"tls:cert", US"0")))
       {
       log_write(0, LOG_MAIN, "SSL verify denied by event-action: "
-                             "depth=0 cert=%s", txt);
-      tlsp->certificate_verified = FALSE;
+                             "depth=0 cert=%s: %s", txt, yield);
       *calledp = TRUE;
-      return 0;                            /* reject */
+      if (!*optionalp)
+       return 0;                           /* reject */
+      DEBUG(D_tls) debug_printf("Event-action verify failure overridden "
+       "(host in tls_try_verify_hosts)\n");
       }
 #endif
 
@@ -450,6 +464,7 @@ X509 * cert = X509_STORE_CTX_get_current_cert(x509ctx);
 static uschar txt[256];
 #ifdef EXPERIMENTAL_EVENT
 int depth = X509_STORE_CTX_get_error_depth(x509ctx);
+uschar * yield;
 #endif
 
 X509_NAME_oneline(X509_get_subject_name(cert), CS txt, sizeof(txt));
@@ -461,11 +476,11 @@ tls_out.peercert = X509_dup(cert);
 #ifdef EXPERIMENTAL_EVENT
   if (client_static_cbinfo->event_action)
     {
-    if (event_raise(client_static_cbinfo->event_action,
-                   US"tls:cert", string_sprintf("%d", depth)) == DEFER)
+    if ((yield = event_raise(client_static_cbinfo->event_action,
+                   US"tls:cert", string_sprintf("%d", depth))))
       {
       log_write(0, LOG_MAIN, "DANE verify denied by event-action: "
-                             "depth=%d cert=%s", depth, txt);
+                             "depth=%d cert=%s: %s", depth, txt, yield);
       tls_out.certificate_verified = FALSE;
       return 0;                            /* reject */
       }
index 6886fd5188035c7106322b3dd4a4cf204cd6fa7d..12ae6e14d469df3c3969804a6ad1e317fb4f3f18 100644 (file)
@@ -1414,14 +1414,20 @@ if (continue_hostname == NULL)
       ob->command_timeout)) goto RESPONSE_FAILED;
 
 #ifdef EXPERIMENTAL_EVENT
-    if (event_raise(tblock->event_action, US"smtp:connect", buffer)
-       == DEFER)
+      {
+      uschar * s;
+      lookup_dnssec_authenticated = host->dnssec==DS_YES ? US"yes"
+       : host->dnssec==DS_NO ? US"no" : NULL;
+      s = event_raise(tblock->event_action, US"smtp:connect", buffer);
+      if (s)
        {
-       uschar *message = US"deferred by smtp:connect event expansion";
-       set_errno(addrlist, 0, message, DEFER, FALSE, NULL);
+       set_errno(addrlist, 0,
+         string_sprintf("deferred by smtp:connect event expansion: %s", s),
+         DEFER, FALSE, NULL);
        yield = DEFER;
        goto SEND_QUIT;
        }
+      }
 #endif
 
     /* Now check if the helo_data expansion went well, and sign off cleanly if
index f8e176b27e84047506ed2c58b83fbf155181a624..b74d6ab5e6b40049ba8715688eff40bb4004a882 100644 (file)
@@ -584,12 +584,16 @@ else
         goto RESPONSE_FAILED;
 
 #ifdef EXPERIMENTAL_EVENT
+      lookup_dnssec_authenticated = host->dnssec==DS_YES ? US"yes"
+       : host->dnssec==DS_NO ? US"no" : NULL;
       if (event_raise(addr->transport->event_action,
-                           US"smtp:connect", responsebuffer) == DEFER)
+                           US"smtp:connect", responsebuffer))
        {
+       lookup_dnssec_authenticated = NULL;
        /* Logging?  Debug? */
        goto RESPONSE_FAILED;
        }
+      lookup_dnssec_authenticated = NULL;
 #endif
       }
 
index d4ef72d5e87da4656c2b524fa7ec5bbd89363223..80c35117b4de9f0605df5de522563a19cfa3954a 100644 (file)
@@ -836,7 +836,7 @@ This command runs the auxiliary "client" program that simulates an SMTP client.
 It is controlled by a script read from its standard input, details of which are
 given below. There are two options. One is -t, which must be followed directly
 by a number, to specify the command timeout in seconds (e.g. -t5). The default
-timeout is 1 second. The other option is -tls-on-connect, which causes the
+timeout is 5 seconds. The other option is -tls-on-connect, which causes the
 client to try to start up a TLS session as soon as it has connected, without
 using the STARTTLS command. The client program connects to the given IP address
 and port, using the specified interface, if one is given.
index 5d9ef8f8a34e05ea47fb6b643cd31a8e83c197ea..2d46eefb77a83fe607beea9694bd9073ceca61af 100755 (executable)
@@ -3,7 +3,9 @@
 # This script outputs certain information about the environment, for use when
 # testing pipe transports.
 
-name=`whoami 2>/dev/null` || name=`who . . | awk '{print $1}'`
+cmd=/usr/xpg4/bin/id
+[ -x $cmd ] || cmd=id
+name=`$cmd -un`
 
 echo Test pipe script
 echo Running as: $name
index 1e5f075e9e14986d6f809b759bd34206e2197ed8..4e92c74cbaf8c2b4a880423d61cd6cc2559590b3 100644 (file)
@@ -1,3 +1,3 @@
 1999-03-02 09:44:33 10HmaX-0005vi-00 <= CALLER@the.local.host.name U=CALLER P=local S=sss
-1999-03-02 09:44:33 10HmaX-0005vi-00 SMTP error from remote mail server after MAIL FROM:<CALLER@the.local.host.name>: host 127.0.0.1 [127.0.0.1]: 450 Temporary error
-1999-03-02 09:44:33 10HmaX-0005vi-00 == userx@test.ex R=r1 T=t1 defer (-45): SMTP error from remote mail server after MAIL FROM:<CALLER@the.local.host.name>: host ::1 [::1]: 450 Temporary error
+1999-03-02 09:44:33 10HmaX-0005vi-00 SMTP error from remote mail server after MAIL FROM:<CALLER@the.local.host.name>: 450 Temporary error
+1999-03-02 09:44:33 10HmaX-0005vi-00 == userx@test.ex R=r1 T=t1 defer (-45) H=::1 [::1]: SMTP error from remote mail server after MAIL FROM:<CALLER@the.local.host.name>: 450 Temporary error
index 166a701e1c8266ccc910fde9d206aaacf573508e..c6111678fe1b74a9fd364b6ee32316a56562b151 100755 (executable)
@@ -485,7 +485,7 @@ RESET_AFTER_EXTRA_LINE_READ:
   s/\d\d-[A-Z][a-z]{2}-\d{4}\s\d\d:\d\d:\d\d/07-Mar-2000 12:21:52/g;
 
   # Time on queue tolerance
-  s/QT=1s/QT=0s/;
+  s/(QT|D)=1s/$1=0s/;
 
   # Eximstats heading
   s/Exim\sstatistics\sfrom\s\d{4}-\d\d-\d\d\s\d\d:\d\d:\d\d\sto\s
@@ -896,7 +896,7 @@ RESET_AFTER_EXTRA_LINE_READ:
     # As of Exim 4.74, we log when a setgid fails; because we invoke Exim
     # with -be, privileges will have been dropped, so this will always
     # be the case
-    next if /^changing group to \d+ failed: Operation not permitted/;
+    next if /^changing group to \d+ failed: (Operation not permitted|Not owner)/;
 
     # We might not keep this check; rather than change all the tests, just
     # ignore it as long as it succeeds; then we only need to change the
@@ -1029,6 +1029,14 @@ RESET_AFTER_EXTRA_LINE_READ:
     next;
     }
 
+  # ======== log ========
+
+  elsif ($is_log)
+    {
+    # Berkeley DB version differences
+    next if / Berkeley DB error: /;
+    }
+
   # ======== All files other than stderr ========
 
   print MUNGED;
@@ -1290,6 +1298,7 @@ return 1;
 #  paniclog, rejectlog, mainlog, stdout, stderr, msglog, mail
 # Search strings starting with 's' do substitutions;
 # with '/' do line-skips.
+# Triggered by a scriptfile line "munge <name>"
 ##################################################
 $munges =
   { 'dnssec' =>
@@ -1301,8 +1310,11 @@ $munges =
     'gnutls_handshake' =>
     { 'mainlog' => 's/\(gnutls_handshake\): Error in the push function/\(gnutls_handshake\): A TLS packet with unexpected length was received/', },
 
-    'tpda' =>
-    { 'stdout' => '/tpda_event_action =/', },
+    'optional_events' =>
+    { 'stdout' => '/event_action =/', },
+
+    'optional_ocsp' =>
+    { 'stderr' => '/127.0.0.1 in hosts_requ(ire|est)_ocsp/', },
 
   };
 
@@ -2724,7 +2736,7 @@ $pwcomm = $pwcomm;
 
 $parm_caller_group = getgrgid($parm_caller_gid);
 
-print "Program caller is $parm_caller, whose group is $parm_caller_group\n";
+print "Program caller is $parm_caller ($parm_caller_uid), whose group is $parm_caller_group ($parm_caller_gid)\n";
 print "Home directory is $parm_caller_home\n";
 
 unless (defined $parm_eximgroup)
index 9d3d3ea61601a8a8ea82ae58ce01c20cdd1841e8..8548d8efff87b5202bc8deda99c524df04d78e7a 100644 (file)
@@ -1,5 +1,7 @@
 # .ifdef etc
-munge tpda
+#
+munge optional_events
+#
 exim -bP accept_8bitmime acl_not_smtp acl_smtp_auth acl_smtp_connect acl_smtp_data acl_smtp_etrn acl_smtp_expn acl_smtp_mail acl_smtp_rcpt acl_smtp_vrfy
 ****
 exim -DAA -bP accept_8bitmime acl_not_smtp acl_smtp_auth acl_smtp_connect acl_smtp_data acl_smtp_etrn acl_smtp_expn acl_smtp_mail acl_smtp_rcpt acl_smtp_vrfy
index 365d1c68ceffdf839b94a6f58732b3a858c4d9bc..8b07fde5ed989510672535fad230c9c463f8d35b 100644 (file)
@@ -21,7 +21,7 @@ quit
 killdaemon
 exim -DSERVER=server -DD6=disable_ipv6 -bd -oX PORT_D
 ****
-1
+85
 client HOSTIPV6 PORT_D
 ****
 killdaemon
index 446bcc667f066e4d585816cb23ef8456a8e21d69..001e7ae67d183c8dd865a5300a12b961412b09ab 100644 (file)
@@ -1,4 +1,7 @@
 # cutthrough_delivery to target offering TLS
+#
+munge optional_ocsp
+#
 exim -DSERVER=server -bd -oX PORT_D
 ****
 exim -d-all+acl+transport+expand+lists -bs
index 614c2c557b16bd8d8539d69b81d20cf48a3ebee9..cd2194af126f707f675aeb28283c8c4e040458f1 100644 (file)
@@ -58,7 +58,6 @@ static int sigalrm_seen = 0;
 
 /* TLS support can be optionally included, either for OpenSSL or GnuTLS. The
 latter needs a whole pile of tables. */
-
 #ifdef HAVE_OPENSSL
 # define HAVE_TLS
 # include <openssl/crypto.h>
@@ -67,7 +66,14 @@ latter needs a whole pile of tables. */
 # include <openssl/ssl.h>
 # include <openssl/err.h>
 # include <openssl/rand.h>
-# include <openssl/ocsp.h>
+
+# if OPENSSL_VERSION_NUMBER < 0x0090806fL && !defined(DISABLE_OCSP) && !defined(OPENSSL_NO_TLSEXT)
+#  warning "OpenSSL library version too old; define DISABLE_OCSP in Makefile"
+#  define DISABLE_OCSP
+# endif
+# ifndef DISABLE_OCSP
+#  include <openssl/ocsp.h>
+# endif
 #endif
 
 
@@ -188,6 +194,7 @@ setup_verify(BIO *bp, char *CAfile, char *CApath)
 }
 
 
+#ifndef DISABLE_OCSP
 static int
 tls_client_stapling_cb(SSL *s, void *arg)
 {
@@ -238,6 +245,7 @@ else
 X509_STORE_free(store);
 return ret;
 }
+#endif
 
 
 /*************************************************
@@ -248,21 +256,23 @@ int
 tls_start(int sock, SSL **ssl, SSL_CTX *ctx)
 {
 int rc;
-static const char *sid_ctx = "exim";
+static const unsigned char *sid_ctx = US"exim";
 
 RAND_load_file("client.c", -1);   /* Not *very* random! */
 
 *ssl = SSL_new (ctx);
-SSL_set_session_id_context(*ssl, sid_ctx, strlen(sid_ctx));
+SSL_set_session_id_context(*ssl, sid_ctx, strlen(CS sid_ctx));
 SSL_set_fd (*ssl, sock);
 SSL_set_connect_state(*ssl);
 
+#ifndef DISABLE_OCSP
 if (ocsp_stapling)
   {
   SSL_CTX_set_tlsext_status_cb(ctx, tls_client_stapling_cb);
   SSL_CTX_set_tlsext_status_arg(ctx, BIO_new_fp(stdout, BIO_NOCLOSE));
   SSL_set_tlsext_status_type(*ssl, TLSEXT_STATUSTYPE_ocsp);
   }
+#endif
 
 signal(SIGALRM, sigalrm_handler_flag);
 sigalrm_seen = 0;
@@ -717,7 +727,7 @@ an externally applied timeout if the signal handler has been run. */
 if (rc < 0)
   {
   close(sock);
-  printf("failed: %s\n", strerror(save_errno));
+  printf("connect failed: %s\n", strerror(save_errno));
   exit(85);
   }
 
@@ -818,15 +828,15 @@ if (tls_on_connect)
   }
 #endif
 
-while (fgets(outbuffer, sizeof(outbuffer), stdin) != NULL)
+while (fgets(CS outbuffer, sizeof(outbuffer), stdin) != NULL)
   {
-  int n = (int)strlen(outbuffer);
+  int n = (int)strlen(CS outbuffer);
   while (n > 0 && isspace(outbuffer[n-1])) n--;
   outbuffer[n] = 0;
 
   /* Expect incoming */
 
-  if (strncmp(outbuffer, "??? ", 4) == 0)
+  if (strncmp(CS outbuffer, "??? ", 4) == 0)
     {
     unsigned char *lineptr;
     printf("%s\n", outbuffer);
@@ -876,7 +886,7 @@ while (fgets(outbuffer, sizeof(outbuffer), stdin) != NULL)
       }
 
     printf("<<< %s\n", lineptr);
-    if (strncmp(lineptr, outbuffer + 4, (int)strlen(outbuffer) - 4) != 0)
+    if (strncmp(CS lineptr, CS outbuffer + 4, (int)strlen(CS outbuffer) - 4) != 0)
       {
       printf("\n******** Input mismatch ********\n");
       exit(79);
@@ -958,10 +968,10 @@ int rc;
 
   /* Wait for a bit before proceeding */
 
-  else if (strncmp(outbuffer, "+++ ", 4) == 0)
+  else if (strncmp(CS outbuffer, "+++ ", 4) == 0)
     {
     printf("%s\n", outbuffer);
-    sleep(atoi(outbuffer + 4));
+    sleep(atoi(CS outbuffer + 4));
     }
 
   /* Send outgoing, but barf if unconsumed incoming */
@@ -981,8 +991,8 @@ int rc;
 
     /* Shutdown TLS */
 
-    if (strcmp(outbuffer, "stoptls") == 0 ||
-        strcmp(outbuffer, "STOPTLS") == 0)
+    if (strcmp(CS outbuffer, "stoptls") == 0 ||
+        strcmp(CS outbuffer, "STOPTLS") == 0)
       {
       if (!tls_active)
         {
@@ -1009,14 +1019,14 @@ int rc;
 
     /* Remember that we sent STARTTLS */
 
-    sent_starttls = (strcmp(outbuffer, "starttls") == 0 ||
-                     strcmp(outbuffer, "STARTTLS") == 0);
+    sent_starttls = (strcmp(CS outbuffer, "starttls") == 0 ||
+                     strcmp(CS outbuffer, "STARTTLS") == 0);
 
     /* Fudge: if the command is "starttls_wait", we send the starttls bit,
     but we haven't set the flag, so that there is no negotiation. This is for
     testing the server's timeout. */
 
-    if (strcmp(outbuffer, "starttls_wait") == 0)
+    if (strcmp(CS outbuffer, "starttls_wait") == 0)
       {
       outbuffer[8] = 0;
       n = 8;
@@ -1024,18 +1034,18 @@ int rc;
     #endif
 
     printf(">>> %s\n", outbuffer);
-    strcpy(outbuffer + n, "\r\n");
+    strcpy(CS outbuffer + n, "\r\n");
 
     /* Turn "\n" and "\r" into the relevant characters. This is a hack. */
 
-    while ((escape = strstr(outbuffer, "\\r")) != NULL)
+    while ((escape = US strstr(CS outbuffer, "\\r")) != NULL)
       {
       *escape = '\r';
       memmove(escape + 1, escape + 2,  (n + 2) - (escape - outbuffer) - 2);
       n--;
       }
 
-    while ((escape = strstr(outbuffer, "\\n")) != NULL)
+    while ((escape = US strstr(CS outbuffer, "\\n")) != NULL)
       {
       *escape = '\n';
       memmove(escape + 1, escape + 2,  (n + 2) - (escape - outbuffer) - 2);
index fd3604a3c6c5e2e50617db08b1178a536066fce2..baabf1d30308d4d004fcf6da9458f1603aa25c8a 100644 (file)
@@ -57,6 +57,7 @@ as such then the response will have the "AD" bit set. */
 #include <ctype.h>
 #include <stdarg.h>
 #include <stdio.h>
+#include <stdlib.h>
 #include <string.h>
 #include <netdb.h>
 #include <errno.h>
@@ -156,7 +157,7 @@ uschar *yield;
 char buffer[256];
 va_list ap;
 va_start(ap, format);
-vsprintf(buffer, format, ap);
+vsprintf(buffer, CS format, ap);
 va_end(ap);
 yield = (uschar *)malloc(Ustrlen(buffer) + 1);
 Ustrcpy(yield, buffer);
@@ -420,7 +421,7 @@ while (fgets(CS buffer, sizeof(buffer), f) != NULL)
 
     case ns_t_mx:
     pk = shortfield(&p, pk);
-    if (ep[-1] != '.') sprintf(ep, "%s.", zone);
+    if (ep[-1] != '.') sprintf(CS ep, "%s.", zone);
     pk = packname(p, pk);
     plen = Ustrlen(p);
     break;
@@ -464,7 +465,7 @@ while (fgets(CS buffer, sizeof(buffer), f) != NULL)
     case ns_t_cname:
     case ns_t_ns:
     case ns_t_ptr:
-    if (ep[-1] != '.') sprintf(ep, "%s.", zone);
+    if (ep[-1] != '.') sprintf(CS ep, "%s.", zone);
     pk = packname(p, pk);
     plen = Ustrlen(p);
     break;
@@ -515,7 +516,7 @@ if (argc != 4)
 
 /* Find the zones */
 
-(void)sprintf(buffer, "%s/../dnszones", argv[1]);
+(void)sprintf(CS buffer, "%s/../dnszones", argv[1]);
 
 d = opendir(CCS buffer);
 if (d == NULL)
@@ -527,20 +528,20 @@ if (d == NULL)
 
 while ((de = readdir(d)) != NULL)
   {
-  uschar *name = de->d_name;
+  uschar *name = US de->d_name;
   if (Ustrncmp(name, "qualify.", 8) == 0)
     {
-    qualify = fcopystring("%s", name + 7);
+    qualify = fcopystring(US "%s", name + 7);
     continue;
     }
   if (Ustrncmp(name, "db.", 3) != 0) continue;
   if (Ustrncmp(name + 3, "ip4.", 4) == 0)
-    zones[zonecount].zone = fcopystring("%s.in-addr.arpa", name + 6);
+    zones[zonecount].zone = fcopystring(US "%s.in-addr.arpa", name + 6);
   else if (Ustrncmp(name + 3, "ip6.", 4) == 0)
-    zones[zonecount].zone = fcopystring("%s.ip6.arpa", name + 6);
+    zones[zonecount].zone = fcopystring(US "%s.ip6.arpa", name + 6);
   else
-    zones[zonecount].zone = fcopystring("%s", name + 2);
-  zones[zonecount++].zonefile = fcopystring("%s", name);
+    zones[zonecount].zone = fcopystring(US "%s", name + 2);
+  zones[zonecount++].zonefile = fcopystring(US "%s", name);
   }
 (void)closedir(d);
 
@@ -586,7 +587,7 @@ if (zonefile == NULL)
   return PASS_ON;
   }
 
-(void)sprintf(buffer, "%s/../dnszones/%s", argv[1], zonefile);
+(void)sprintf(CS buffer, "%s/../dnszones/%s", argv[1], zonefile);
 
 /* Initialize the start of the response packet. We don't have to fake up
 everything, because we know that Exim will look only at the answer and
@@ -597,7 +598,7 @@ pk += 12;
 
 /* Open the zone file. */
 
-f = fopen(buffer, "r");
+f = fopen(CS buffer, "r");
 if (f == NULL)
   {
   fprintf(stderr, "fakens: failed to open %s: %s\n", buffer, strerror(errno));
index 2acfa285fe4e208ec6cc9c5c467c324ee1517ff8..a595194336a1147a302c1ec0670684419020e3ba 100644 (file)
@@ -19,6 +19,10 @@ complicated version that does it over a socket. */
 #include <errno.h>
 #include <unistd.h>
 
+#ifndef CS
+# define CS (char *)
+#endif
+
 
 static FILE *log;
 
@@ -86,9 +90,9 @@ signal(SIGALRM, sigalrm_handler);
 
 /* Read the script, and do what it says. */
 
-while (fgets(sbuffer, sizeof(sbuffer), script) != NULL)
+while (fgets(CS sbuffer, sizeof(sbuffer), script) != NULL)
   {
-  int n = (int)strlen(sbuffer);
+  int n = (int)strlen(CS sbuffer);
   while (n > 0 && isspace(sbuffer[n-1])) n--;
   sbuffer[n] = 0;
 
@@ -107,9 +111,9 @@ while (fgets(sbuffer, sizeof(sbuffer), script) != NULL)
   before continuing. Do not write this to the log, as it may not get
   written at the right place in a log that's being shared. */
 
-  else if (strncmp(sbuffer, "*sleep ", 7) == 0)
+  else if (strncmp(CS sbuffer, "*sleep ", 7) == 0)
     {
-    sleep(atoi(sbuffer+7));
+    sleep(atoi(CS sbuffer+7));
     }
 
   /* Otherwise the script line is the start of an input line we are expecting
@@ -119,7 +123,7 @@ while (fgets(sbuffer, sizeof(sbuffer), script) != NULL)
 
   else
     {
-    int data = strcmp(sbuffer, ".") == 0;
+    int data = strcmp(CS sbuffer, ".") == 0;
 
     fprintf(log, "%s\n", sbuffer);
     fflush(log);
@@ -130,23 +134,23 @@ while (fgets(sbuffer, sizeof(sbuffer), script) != NULL)
       {
       int n;
       alarm(5);
-      if (fgets(ibuffer, sizeof(ibuffer), stdin) == NULL)
+      if (fgets(CS ibuffer, sizeof(ibuffer), stdin) == NULL)
         {
         fprintf(log, "%sxpected EOF read from client\n",
-          (strncmp(sbuffer, "*eof", 4) == 0)? "E" : "Une");
+          (strncmp(CS sbuffer, "*eof", 4) == 0)? "E" : "Une");
         goto END_OFF;
         }
       alarm(0);
-      n = (int)strlen(ibuffer);
+      n = (int)strlen(CS ibuffer);
       while (n > 0 && isspace(ibuffer[n-1])) n--;
       ibuffer[n] = 0;
       fprintf(log, "<<< %s\n", ibuffer);
-      if (!data || strcmp(ibuffer, ".") == 0) break;
+      if (!data || strcmp(CS ibuffer, ".") == 0) break;
       }
 
     /* Check received what was expected */
 
-    if (strncmp(sbuffer, ibuffer, (int)strlen(sbuffer)) != 0)
+    if (strncmp(CS sbuffer, CS ibuffer, (int)strlen(CS sbuffer)) != 0)
       {
       fprintf(log, "Comparison failed - bailing out\n");
       goto END_OFF;
index a7e1d2b1d9df5defac1f2014ac9252b3d6b22e7d..0d6e5fe907f7fc44ac3b254749cc1449265a559b 100644 (file)
@@ -43,11 +43,15 @@ on all interfaces, unless the option -noipv6 is given. */
 #include <utime.h>
 
 #ifdef AF_INET6
-#define HAVE_IPV6 1
+# define HAVE_IPV6 1
 #endif
 
 #ifndef S_ADDR_TYPE
-#define S_ADDR_TYPE u_long
+# define S_ADDR_TYPE u_long
+#endif
+
+#ifndef CS
+# define CS (char *)
 #endif
 
 
@@ -379,16 +383,16 @@ because that would cause it to wait for this process, which it doesn't yet want
 to do. The driving script adds the "++++" automatically - it doesn't actually
 appear in the test script. */
 
-while (fgets(buffer, sizeof(buffer), stdin) != NULL)
+while (fgets(CS buffer, sizeof(buffer), stdin) != NULL)
   {
   line *next;
-  int n = (int)strlen(buffer);
+  int n = (int)strlen(CS buffer);
   while (n > 0 && isspace(buffer[n-1])) n--;
   buffer[n] = 0;
-  if (strcmp(buffer, "++++") == 0) break;
+  if (strcmp(CS buffer, "++++") == 0) break;
   next = malloc(sizeof(line) + n);
   next->next = NULL;
-  strcpy(next->line, buffer);
+  strcpy(next->line, CS buffer);
   if (last == NULL) script = last = next;
     else last->next = next;
   last = next;
@@ -464,7 +468,7 @@ for (count = 0; count < connection_count; count++)
   dup_accept_socket = dup(accept_socket);
 
   if (port > 0)
-    printf("\nConnection request from [%s]\n", host_ntoa(&accepted, buffer));
+    printf("\nConnection request from [%s]\n", host_ntoa(&accepted, CS buffer));
   else
     {
     printf("\nConnection request\n");
@@ -572,7 +576,7 @@ for (count = 0; count < connection_count; count++)
         {
         int n;
         alarm(timeout);
-        if (fgets(buffer+offset, sizeof(buffer)-offset, in) == NULL)
+        if (fgets(CS buffer+offset, sizeof(buffer)-offset, in) == NULL)
           {
           printf("%sxpected EOF read from client\n",
             (strncmp(ss, "*eof", 4) == 0)? "E" : "Une");
@@ -580,14 +584,14 @@ for (count = 0; count < connection_count; count++)
           goto END_OFF;
           }
         alarm(0);
-        n = (int)strlen(buffer);
+        n = (int)strlen(CS buffer);
         while (n > 0 && isspace(buffer[n-1])) n--;
         buffer[n] = 0;
         printf("%s\n", buffer);
-        if (!data || strcmp(buffer, ".") == 0) break;
+        if (!data || strcmp(CS buffer, ".") == 0) break;
         }
 
-      if (strncmp(ss, buffer, (int)strlen(ss)) != 0)
+      if (strncmp(ss, CS buffer, (int)strlen(ss)) != 0)
         {
         printf("Comparison failed - bailing out\n");
         printf("Expected: %s\n", ss);
index 5694e911f662ca2d6ada0463ebcd519f058814bf..64dfc0b120ade59132fceace717ea40a6ffe1e34 100644 (file)
@@ -81,8 +81,6 @@ expanding: ${if eq {$address_data}{userz}{*}{:}}
 127.0.0.1 in hosts_verify_avoid_tls? no (end of list)
   SMTP>> STARTTLS
   SMTP<< 220 TLS go ahead
-127.0.0.1 in hosts_require_ocsp? no (option unset)
-127.0.0.1 in hosts_request_ocsp? yes (matched "*")
  in tls_verify_hosts? no (option unset)
  in tls_try_verify_hosts? no (option unset)
   SMTP>> EHLO myhost.test.ex
index c131da929ac497f655279acda21d923eb4711d36..87903f4ea711d439a94a9a28c39a4cc0298cabd1 100644 (file)
@@ -23,4 +23,4 @@ Connecting to ip6:ip6:ip6:ip6:ip6:ip6:ip6:ip6 port 1225 ... connected
 ??? 221
 <<< 221 myhost.test.ex closing connection
 End of script
-Connecting to ip6:ip6:ip6:ip6:ip6:ip6:ip6:ip6 port 1225 ... failed: Connection refused
+Connecting to ip6:ip6:ip6:ip6:ip6:ip6:ip6:ip6 port 1225 ... connect failed: Connection refused
index e2c79135d705ce87ae30ac07e456a5572c8f777a..f930d30a5a4528e69476a881de28715285a1f7e6 100644 (file)
@@ -1,18 +1,18 @@
 +++++++++++++++++++++++++++
-  T:127.0.0.1:127.0.0.1:1224:10HmaX-0005vi-00 -45 12865 SMTP error from remote mail server after MAIL FROM:<CALLER@the.local.host.name>: host 127.0.0.1 [127.0.0.1]: 450 Temporary error
+  T:127.0.0.1:127.0.0.1:1224:10HmaX-0005vi-00 -45 12865 H=127.0.0.1 [127.0.0.1]: SMTP error from remote mail server after MAIL FROM:<CALLER@the.local.host.name>: 450 Temporary error
 first failed = time last try = time2 next try = time2 + 7200
-  T:::1:::1:1224:10HmaX-0005vi-00 -45 12865 SMTP error from remote mail server after MAIL FROM:<CALLER@the.local.host.name>: host ::1 [::1]: 450 Temporary error
+  T:::1:::1:1224:10HmaX-0005vi-00 -45 12865 H=::1 [::1]: SMTP error from remote mail server after MAIL FROM:<CALLER@the.local.host.name>: 450 Temporary error
 first failed = time last try = time2 next try = time2 + 7200
-Transport: 127.0.0.1 [127.0.0.1]:1111 10HmaX-0005vi-00 error -45: SMTP error from remote mail server after MAIL FROM:<CALLER@the.local.host.name>: host 127.0.0.1 [127.0.0.1]: 450 Temporary error
+Transport: 127.0.0.1 [127.0.0.1]:1111 10HmaX-0005vi-00 error -45: H=127.0.0.1 [127.0.0.1]: SMTP error from remote mail server after MAIL FROM:<CALLER@the.local.host.name>: 450 Temporary error
   first failed: 07-Mar-2000 12:21:52
   last tried:   07-Mar-2000 12:21:52
   next try at:  07-Mar-2000 12:21:52
-Transport: ::1 [::1]:1111 10HmaX-0005vi-00 error -45: SMTP error from remote mail server after MAIL FROM:<CALLER@the.local.host.name>: host ::1 [::1]: 450 Temporary error
+Transport:  [:1:::1:1224:10HmaX-0005vi-00]:1224 10HmaX-0005vi-00 error -45: H=::1 [::1]: SMTP error from remote mail server after MAIL FROM:<CALLER@the.local.host.name>: 450 Temporary error
   first failed: 07-Mar-2000 12:21:52
   last tried:   07-Mar-2000 12:21:52
   next try at:  07-Mar-2000 12:21:52
 exinext exit code = 0
-Transport: ::1 [::1]:1111 10HmaX-0005vi-00 error -45: SMTP error from remote mail server after MAIL FROM:<CALLER@the.local.host.name>: host ::1 [::1]: 450 Temporary error
+Transport:  [:1:::1:1224:10HmaX-0005vi-00] error -45: H=::1 [::1]: SMTP error from remote mail server after MAIL FROM:<CALLER@the.local.host.name>: 450 Temporary error
   first failed: 07-Mar-2000 12:21:52
   last tried:   07-Mar-2000 12:21:52
   next try at:  07-Mar-2000 12:21:52