Proxy Protocol - Server support
[exim.git] / src / src / receive.c
index 372747360df308259b51d2401b2376cc6ce79016..9205436d335283f2447e861aae0d4afb5aca4efa 100644 (file)
@@ -1277,9 +1277,10 @@ else if (rc != OK)
 #ifdef EXPERIMENTAL_DCC
   dcc_ok = 0;
 #endif
-  if (smtp_handle_acl_fail(ACL_WHERE_MIME, rc, user_msg, log_msg) != 0)
+  if (smtp_input && smtp_handle_acl_fail(ACL_WHERE_MIME, rc, user_msg, log_msg) != 0) {
     *smtp_yield_ptr = FALSE;    /* No more messsages after dropped connection */
-  *smtp_reply_ptr = US"";       /* Indicate reply already sent */
+    *smtp_reply_ptr = US"";     /* Indicate reply already sent */
+  }
   message_id[0] = 0;            /* Indicate no message accepted */
   return FALSE;                 /* Cause skip to end of receive function */
   }
@@ -1453,7 +1454,7 @@ BOOL resents_exist = FALSE;
 uschar *resent_prefix = US"";
 uschar *blackholed_by = NULL;
 uschar *blackhole_log_msg = US"";
-int  cutthrough_done = 0;
+enum {NOT_TRIED, TMP_REJ, PERM_REJ, ACCEPTED} cutthrough_done;
 
 flock_t lock_data;
 error_block *bad_addresses = NULL;
@@ -3250,6 +3251,7 @@ else
           }
         }
       }
+#endif /* DISABLE_DKIM */
 
 #ifdef WITH_CONTENT_SCAN
     if (recipients_count > 0 &&
@@ -3310,7 +3312,7 @@ else
          }
        if (log_msg)       log_write(0, LOG_MAIN, "PRDR %s %s", addr, log_msg);
        else if (user_msg) log_write(0, LOG_MAIN, "PRDR %s %s", addr, user_msg);
-       else               log_write(0, LOG_MAIN, CS msg);
+       else               log_write(0, LOG_MAIN, "%s", CS msg);
 
        if (rc != OK) { receive_remove_recipient(addr); c--; }
         }
@@ -3426,8 +3428,6 @@ else
       }
     }
 
-#endif /* DISABLE_DKIM */
-
   /* The applicable ACLs have been run */
 
   if (deliver_freeze) frozen_by = US"ACL";     /* for later logging */
@@ -3755,6 +3755,13 @@ if (sender_host_authenticated != NULL)
 if (prdr_requested)
   s = string_append(s, &size, &sptr, 1, US" PRDR");
 #endif
+#ifdef EXPERIMENTAL_PROXY
+if (proxy_session &&
+    (log_extra_selector & LX_proxy) != 0)
+  {
+  s = string_append(s, &size, &sptr, 2, US" PRX=", proxy_host);
+  }
+#endif
 
 sprintf(CS big_buffer, "%d", msg_size);
 s = string_append(s, &size, &sptr, 2, US" S=", big_buffer);
@@ -3949,7 +3956,7 @@ for this message. */
 
    XXX We do not handle queue-only, freezing, or blackholes.
 */
-cutthrough_done = 0;
+cutthrough_done = NOT_TRIED;
 if(cutthrough_fd >= 0)
   {
   uschar * msg= cutthrough_finaldot(); /* Ask the target system to accept the messsage */
@@ -3957,17 +3964,17 @@ if(cutthrough_fd >= 0)
   switch(msg[0])
     {
     case '2':  /* Accept. Do the same to the source; dump any spoolfiles.   */
-      cutthrough_done = 3;
+      cutthrough_done = ACCEPTED;
       break;                                   /* message_id needed for SMTP accept below */
 
     default:   /* Unknown response, or error.  Treat as temp-reject.         */
     case '4':  /* Temp-reject. Keep spoolfiles and accept. */
-      cutthrough_done = 1;                     /* Avoid the usual immediate delivery attempt */
+      cutthrough_done = TMP_REJ;               /* Avoid the usual immediate delivery attempt */
       break;                                   /* message_id needed for SMTP accept below */
 
     case '5':  /* Perm-reject.  Do the same to the source.  Dump any spoolfiles */
       smtp_reply= msg;         /* Pass on the exact error */
-      cutthrough_done = 2;
+      cutthrough_done = PERM_REJ;
       break;
     }
   }
@@ -4081,8 +4088,8 @@ if (smtp_input)
 
     switch (cutthrough_done)
       {
-      case 3: log_write(0, LOG_MAIN, "Completed");     /* Delivery was done */
-      case 2: {                                                /* Delete spool files */
+      case ACCEPTED: log_write(0, LOG_MAIN, "Completed");/* Delivery was done */
+      case PERM_REJ: {                                 /* Delete spool files */
              sprintf(CS spool_name, "%s/input/%s/%s-D", spool_directory,
                message_subdir, message_id);
              Uunlink(spool_name);
@@ -4093,7 +4100,7 @@ if (smtp_input)
                message_subdir, message_id);
              Uunlink(spool_name);
              }
-      case 1: message_id[0] = 0;                       /* Prevent a delivery from starting */
+      case TMP_REJ: message_id[0] = 0;   /* Prevent a delivery from starting */
       default:break;
       }
     cutthrough_delivery = FALSE;