SPDX: Mass-update to GPL-2.0-or-later
[exim.git] / src / src / smtp_in.c
index 4a5c44714fcac9735389b004485ab96269cf6060..9b60702c15accc42b9068d3f0a9039799f11369c 100644 (file)
@@ -5,6 +5,7 @@
 /* Copyright (c) The Exim Maintainers 2020 - 2022 */
 /* Copyright (c) University of Cambridge 1995 - 2018 */
 /* See the file NOTICE for conditions of use and distribution. */
+/* SPDX-License-Identifier: GPL-2.0-or-later */
 
 /* Functions for handling an incoming SMTP call. */
 
@@ -2157,8 +2158,12 @@ prdr_requested = FALSE;
 #ifdef SUPPORT_I18N
 message_smtputf8 = FALSE;
 #endif
+#ifdef WITH_CONTENT_SCAN
+regex_vars_clear();
+#endif
 body_linecount = body_zerocount = 0;
 
+lookup_value = NULL;                           /* Can be set by ACL */
 sender_rate = sender_rate_limit = sender_rate_period = NULL;
 ratelimiters_mail = NULL;           /* Updated by ratelimit ACL condition */
                    /* Note that ratelimiters_conn persists across resets. */
@@ -4099,11 +4104,16 @@ while (done <= 0)
            { DEBUG(D_auth) debug_printf("tls auth succeeded\n"); }
          else
            {
-           uschar * save_name = sender_host_authenticated;
            DEBUG(D_auth) debug_printf("tls auth not succeeded\n");
-           sender_host_authenticated = au->name;
-           (void) event_raise(event_action, US"auth:fail", s, NULL);
-           sender_host_authenticated = save_name;
+#ifndef DISABLE_EVENT
+            {
+             uschar * save_name = sender_host_authenticated, * logmsg;
+             sender_host_authenticated = au->name;
+             if ((logmsg = event_raise(event_action, US"auth:fail", s, NULL)))
+               log_write(0, LOG_MAIN, "%s", logmsg);
+             sender_host_authenticated = save_name;
+            }
+#endif
            }
          }
        break;
@@ -4208,13 +4218,19 @@ while (done <= 0)
          smtp_printf("%s\r\n", FALSE, smtp_resp);
          if (rc != OK)
            {
-           uschar * save_name = sender_host_authenticated;
-
-           log_write(0, LOG_MAIN|LOG_REJECT, "%s authenticator failed for %s: %s",
-             au->name, host_and_ident(FALSE), errmsg);
-           sender_host_authenticated = au->name;
-           (void) event_raise(event_action, US"auth:fail", smtp_resp, NULL);
-           sender_host_authenticated = save_name;
+           uschar * logmsg = NULL;
+#ifndef DISABLE_EVENT
+            {uschar * save_name = sender_host_authenticated;
+             sender_host_authenticated = au->name;
+             logmsg = event_raise(event_action, US"auth:fail", smtp_resp, NULL);
+             sender_host_authenticated = save_name;
+            }
+#endif
+           if (logmsg)
+             log_write(0, LOG_MAIN|LOG_REJECT, "%s", logmsg);
+           else
+             log_write(0, LOG_MAIN|LOG_REJECT, "%s authenticator failed for %s: %s",
+               au->name, host_and_ident(FALSE), errmsg);
            }
          }
        else