1Patch from John Marshall (slightly modified).
2Modified for 8.16.1 by Anne Bennett.
3
4--- a/sendmail/srvrsmtp.c	2020-09-28 17:51:12.497535563 -0400
5+++ b/sendmail/srvrsmtp.c	2020-09-28 18:21:30.482890337 -0400
6@@ -116,7 +116,7 @@
7 	do							\
8 	{							\
9 		RESET_AUTH_FAIL_LOG_USER;			\
10-		result = reset_saslconn(&conn, AuthRealm, remoteip, \
11+		result = reset_saslconn(&conn, hostname, remoteip, \
12 					localip, auth_id, &ext_ssf); \
13 		if (result != SASL_OK)				\
14 			sasl_ok = false;			\
15@@ -1018,8 +1018,6 @@
16 	e->e_features = features;
17 	hostname = macvalue('j', e);
18 #if SASL
19-	if (AuthRealm == NULL)
20-		AuthRealm = hostname;
21 	sasl_ok = bitset(SRV_OFFER_AUTH, features);
22 	n_mechs = 0;
23 	authenticating = SASL_NOT_AUTH;
24@@ -1028,8 +1026,8 @@
25 	if (sasl_ok)
26 	{
27 # if SASL >= 20000
28-		result = sasl_server_new("smtp", AuthRealm, NULL, NULL, NULL,
29-					 NULL, 0, &conn);
30+		result = sasl_server_new("smtp", hostname, AuthRealm, NULL,
31+					 NULL, NULL, 0, &conn);
32 # elif SASL > 10505
33 		/* use empty realm: only works in SASL > 1.5.5 */
34 		result = sasl_server_new("smtp", AuthRealm, "", NULL, 0, &conn);
35@@ -5559,7 +5557,7 @@
36
37 	sasl_dispose(conn);
38 # if SASL >= 20000
39-	result = sasl_server_new("smtp", hostname, NULL, NULL, NULL,
40+	result = sasl_server_new("smtp", hostname, AuthRealm, NULL, NULL,
41 				 NULL, 0, conn);
42 # elif SASL > 10505
43 	/* use empty realm: only works in SASL > 1.5.5 */
44