$NetBSD$

--- sendmail/srvrsmtp.c.orig	2020-06-08 10:35:03.000000000 +0200
+++ sendmail/srvrsmtp.c	2021-03-18 16:31:49.667905040 +0100
@@ -47,8 +47,12 @@
 #if _FFR_DM_ONE
 static bool	NotFirstDelivery = false;
 #endif
 
+#if NAMED_BIND
+extern struct __res_state sm_res;
+#endif
+
 /* server features */
 #define SRV_NONE	0x0000	/* none... */
 #define SRV_OFFER_TLS	0x0001	/* offer STARTTLS */
 #define SRV_VRFY_CLT	0x0002	/* request a cert */
@@ -1407,8 +1411,9 @@
 					  anynet_ntoa(&RealHostAddr),
 					  (int) tp.tv_sec +
 						(tp.tv_usec >= 500000 ? 1 : 0)
 					 );
+				BLACKLIST_NOTIFY(BLACKLIST_AUTH_FAIL, fd, "pre-greeting traffic");
 			}
 		}
 	}
 
@@ -1679,9 +1684,14 @@
 
 			/* get an OK if we're done */
 			if (result == SASL_OK)
 			{
+				int fd;
+
   authenticated:
+				fd = sm_io_getinfo(InChannel, SM_IO_WHAT_FD, NULL);
+				BLACKLIST_NOTIFY(BLACKLIST_AUTH_OK, fd, "AUTH OK");
+
 				message("235 2.0.0 OK Authenticated");
 				authenticating = SASL_IS_AUTH;
 				macdefine(&BlankEnvelope.e_macro, A_TEMP,
 					macid("{auth_type}"), auth_type);
@@ -2097,8 +2107,13 @@
 			if (p != NULL)
 				auth_type = newstr(p);
 			if (result != SASL_OK && result != SASL_CONTINUE)
 			{
+				int fd;	
+
+				fd = sm_io_getinfo(InChannel, SM_IO_WHAT_FD, NULL);
+				BLACKLIST_NOTIFY(BLACKLIST_AUTH_FAIL, fd, "AUTH FAIL");
+
 				LOGAUTHFAIL;
 				break;
 			}
 
@@ -3662,9 +3677,13 @@
 		  case CMDERROR:	/* unknown command */
 #if MAXBADCOMMANDS > 0
 			if (++n_badcmds > MAXBADCOMMANDS)
 			{
+				int fd;
+
   stopattack:
+				fd = sm_io_getinfo(InChannel, SM_IO_WHAT_FD, NULL);
+				BLACKLIST_NOTIFY(BLACKLIST_ABUSIVE_BEHAVIOR, fd, "too many bad commands");
 				message("421 4.7.0 %s Too many bad commands; closing connection",
 					MyHostName);
 
 				/* arrange to ignore any current send list */
@@ -4135,10 +4154,10 @@
 	(void) sm_io_setinfo(e->e_xfp, SM_BF_TRUNCATE, NULL);
 	id = e->e_id;
 
 #if NAMED_BIND
-	_res.retry = TimeOuts.res_retry[RES_TO_FIRST];
-	_res.retrans = TimeOuts.res_retrans[RES_TO_FIRST];
+	sm_res.retry = TimeOuts.res_retry[RES_TO_FIRST];
+	sm_res.retrans = TimeOuts.res_retrans[RES_TO_FIRST];
 #endif
 
 #if _FFR_PROXY
 	if (SM_PROXY_REQ == e->e_sendmode)
