Debug: fix showing option name for list (vs. list content)
[exim.git] / src / src / transports / smtp.c
index 596a328c36bce6183ed464d6090f33bbff9ab984..0338d6301f2d75bc6188f7ef5b6026efa27c74f2 100644 (file)
@@ -533,7 +533,7 @@ switch(*errno_value)
 
   case ERRNO_SMTPFORMAT:       /* Handle malformed SMTP response */
     s = string_printing(buffer);
-    while (isspace(*s)) s++;
+    Uskip_whitespace(&s);
     *message = *s == 0
       ? string_sprintf("Malformed SMTP reply (an empty line) "
          "in response to %s%s", pl, smtp_command)
@@ -668,12 +668,15 @@ deferred_event_raise(address_item * addr, host_item * host, uschar * evstr)
 {
 uschar * action = addr->transport->event_action;
 const uschar * save_domain, * save_local;
+uschar * save_rn, * save_tn;
 
 if (!action)
   return;
 
 save_domain = deliver_domain;
 save_local = deliver_localpart;
+save_rn = router_name;
+save_tn = transport_name;
 
 /*XXX would ip & port already be set up? */
 deliver_host_address = string_copy(host->address);
@@ -697,7 +700,8 @@ deliver_localpart = addr->local_part;
 
 deliver_localpart = save_local;
 deliver_domain =    save_domain;
-router_name = transport_name = NULL;
+router_name = save_rn;
+router_name = save_tn;
 }
 #endif
 
@@ -815,8 +819,7 @@ uschar * match;
 if (regex_match(regex_LIMITS, sx->buffer, -1, &match))
   for (const uschar * s = sx->buffer + Ustrlen(match); *s; )
     {
-    while (isspace(*s)) s++;
-    if (*s == '\n') break;
+    if (Uskip_whitespace(&s) == '\n') break;
 
     if (strncmpic(s, US"MAILMAX=", 8) == 0)
       {
@@ -946,7 +949,8 @@ if (  sx->early_pipe_active
     if (!(er = dbfn_read_enforce_length(dbm_file, ehlo_resp_key, sizeof(dbdata_ehlo_resp))))
       debug_printf("no ehlo-resp record!\n");
     else
-      debug_printf("ehlo-resp record is %d seconds old\n", time(NULL) - er->time_stamp);
+      debug_printf("ehlo-resp record is %.0f seconds old\n",
+                   difftime(time(NULL), er->time_stamp));
     }
 
   dbfn_delete(dbm_file, ehlo_resp_key);
@@ -1088,6 +1092,7 @@ if (pending_BANNER)
   /*XXX EXPERIMENTAL_ESMTP_LIMITS ? */
 
 # ifndef DISABLE_TLS_RESUME
+  GET_OPTION("host_name_extract");
   s = ((smtp_transport_options_block *)sx->conn_args.ob)->host_name_extract;
   if (!s) s = HNE_DEFAULT;
   ehlo_response_lbserver(sx, s);
@@ -1306,7 +1311,7 @@ while (count-- > 0)
 
     if (testflag(addr, af_dr_retry_exists))
       {
-      uschar *altkey = string_sprintf("%s:<%s>", addr->address_retry_key,
+      uschar * altkey = string_sprintf("%s:<%s>", addr->address_retry_key,
         sender_address);
       retry_add_item(addr, altkey, rf_delete);
       retry_add_item(addr, addr->address_retry_key, rf_delete);
@@ -1322,7 +1327,7 @@ while (count-- > 0)
 
   else if (errno == ETIMEDOUT)
     {
-    uschar *message = string_sprintf("SMTP timeout after RCPT TO:<%s>",
+    uschar * message = string_sprintf("SMTP timeout after RCPT TO:<%s>",
                transport_rcpt_address(addr, sx->conn_args.tblock->rcpt_include_affixes));
     set_errno_nohost(sx->first_addr, ETIMEDOUT, message, DEFER, FALSE, &sx->delivery_start);
     retry_add_item(addr, addr->address_retry_key, 0);
@@ -1693,8 +1698,8 @@ if (  sx->esmtp
        {
        DEBUG(D_transport) debug_printf("skipping %s authenticator: %s\n",
          au->name,
-         (au->client)? "client_condition is false" :
-                       "not configured as a client");
+         au->client ? "client_condition is false"
+                   : "not configured as a client");
        continue;
        }
 
@@ -1702,15 +1707,14 @@ if (  sx->esmtp
 
       while (*p)
        {
-       int len = Ustrlen(au->public_name);
-       int rc;
+       int len = Ustrlen(au->public_name), rc;
 
-       while (isspace(*p)) p++;
+       Uskip_whitespace(&p);
 
        if (strncmpic(au->public_name, p, len) != 0 ||
-           (p[len] != 0 && !isspace(p[len])))
+           (p[len] && !isspace(p[len])))
          {
-         while (*p != 0 && !isspace(*p)) p++;
+         while (*p && !isspace(*p)) p++;
          continue;
          }
 
@@ -1769,6 +1773,7 @@ uschar * local_authenticated_sender = authenticated_sender;
     authenticated_sender, ob->authenticated_sender, f.smtp_authenticated?"Y":"N");
 #endif
 
+GET_OPTION("authenticated_sender");
 if (ob->authenticated_sender)
   {
   uschar * new = expand_string(ob->authenticated_sender);
@@ -2374,6 +2379,7 @@ PIPE_CONNECT_RETRY:
   For early-pipe, we are ok if binding to a local interface; otherwise (if
   $sending_ip_address is seen in helo_data) we disabled early-pipe above. */
 
+  GET_OPTION("helo_data");
   if (sx->helo_data)
     if (!(sx->helo_data = expand_string(sx->helo_data)))
       if (sx->verify)
@@ -2501,6 +2507,7 @@ goto SEND_QUIT;
     an LB.  Call this anyway, so that a dummy host_name_extract option value can
     force resumption attempts. */
 
+    GET_OPTION("host_name_extract");
     if (!(s = ob->host_name_extract)) s = US"never-LB";
     ehlo_response_lbserver(sx, s);
 # endif
@@ -2629,6 +2636,7 @@ goto SEND_QUIT;
        }
 #endif
 #ifndef DISABLE_TLS_RESUME
+      GET_OPTION("host_name_extract");
       if (!(s = ob->host_name_extract)) s = HNE_DEFAULT;
       ehlo_response_lbserver(sx, s);
 #endif
@@ -2837,13 +2845,17 @@ if (tls_out.active.sock >= 0)
   {
   uschar * greeting_cmd;
 
-  if (!sx->helo_data && !(sx->helo_data = expand_string(ob->helo_data)))
+  if (!sx->helo_data)
     {
-    uschar *message = string_sprintf("failed to expand helo_data: %s",
-      expand_string_message);
-    set_errno_nohost(sx->addrlist, ERRNO_EXPANDFAIL, message, DEFER, FALSE, &sx->delivery_start);
-    yield = DEFER;
-    goto SEND_QUIT;
+    GET_OPTION("helo_data");
+    if (!(sx->helo_data = expand_string(ob->helo_data)))
+      {
+      uschar *message = string_sprintf("failed to expand helo_data: %s",
+       expand_string_message);
+      set_errno_nohost(sx->addrlist, ERRNO_EXPANDFAIL, message, DEFER, FALSE, &sx->delivery_start);
+      yield = DEFER;
+      goto SEND_QUIT;
+      }
     }
 
 #ifndef DISABLE_PIPE_CONNECT
@@ -3094,6 +3106,7 @@ if (sx->addrlist->prop.utf8_msg)
   /* If the transport sets a downconversion mode it overrides any set by ACL
   for the message. */
 
+  GET_OPTION("utf8_downconvert");
   if ((s = ob->utf8_downconvert))
     {
     if (!(s = expand_string(s)))
@@ -5368,7 +5381,7 @@ retry_non_continued:
     BOOL host_is_expired = FALSE, message_defer = FALSE, some_deferred = FALSE;
     address_item * first_addr = NULL;
     uschar * interface = NULL;
-    uschar * retry_host_key = NULL, * retry_message_key = NULL;
+    const uschar * retry_host_key = NULL, * retry_message_key = NULL;
     uschar * serialize_key = NULL;
 
     /* Deal slightly better with a possible Linux kernel bug that results
@@ -5565,8 +5578,9 @@ retry_non_continued:
 
     host_af = Ustrchr(host->address, ':') ? AF_INET6 : AF_INET;
       {
-      uschar * s = ob->interface;
-      if (s && *s)
+      uschar * s;
+      GET_OPTION("interface");
+      if ((s = ob->interface) && *s)
        {
        if (!smtp_get_interface(s, host_af, addrlist, &interface, tid))
          return FALSE;
@@ -5864,9 +5878,7 @@ retry_non_continued:
                  ob->expand_retry_include_ip_address, &incl_ip) != OK)
          incl_ip = TRUE;       /* error; use most-specific retry record */
 
-        retry_host_key = incl_ip
-         ? string_sprintf("T:%S:%s%s", host->name, host->address, pistring)
-         : string_sprintf("T:%S%s", host->name, pistring);
+        retry_host_key = retry_host_key_build(host, incl_ip, pistring);
         }
 
       /* If a delivery of another message over an existing SMTP connection
@@ -5912,10 +5924,8 @@ retry_non_continued:
                  ob->expand_retry_include_ip_address, &incl_ip) != OK)
          incl_ip = TRUE;       /* error; use most-specific retry record */
 
-        retry_message_key = incl_ip
-         ? string_sprintf("T:%S:%s%s:%s", host->name, host->address, pistring,
-             message_id)
-         : string_sprintf("T:%S%s:%s", host->name, pistring, message_id);
+        retry_message_key = string_sprintf("%s:%s",
+         retry_host_key_build(host, incl_ip, pistring), message_id);
         }
       retry_add_item(addrlist, retry_message_key,
         rf_message | rf_host | delete_flag);