Newsgroups: comp.mail.sendmail
Subject:    Re: TCPWRAPPER 8.8.8 && ANTI-SPAM
Author:     Wietse Venema <wietse@(nospam)wzv.win.tue.nl>
Date:       15 Nov 1997 14:28:46 -0500

"Randall C. Grimshaw" <rgrimsha@syr.edu> writes:

>I am exploring TCP-WRAPPER as part of our anti-spam measures

>The KNOWN / UNKNOWN keywords work via inetd... but with TCPWRAPPER
>compiled in 8.8.8, all hosts appear as known. I know this is working
>otherwise because the exec program attached to the sendmail line in
>hosts.allow is executed properly.

This week I found out that sendmail calls my wrapper incorrectly,
causing hosts to always match the KNOWN pattern. A workaround is
below. Similar code will appear in the next sendmail release.

        Wietse

--- workaround, file conf.c ---

	char *host;
	...
	if (hostname[0] == '[' && hostname[strlen(hostname) - 1] == ']')
		host = STRING_UNKNOWN;
	else
		host = hostname;
	if (!hosts_ctl("sendmail", host, anynet_ntoa(sap), STRING_UNKNOWN))
	{
	...

The following patch was generated by John E. Gotts <jgotts@linuxsavvy.com>:

--- sendmail-8.8.8/src/conf.c.orig	Sat Nov 22 22:52:50 1997
+++ sendmail-8.8.8/src/conf.c	Sat Nov 22 22:54:29 1997
@@ -4106,6 +4106,8 @@
 	char *hostname;
 	ENVELOPE *e;
 {
+	char *host;
+
 	if (tTd(48, 3))
 		printf("validate_connection(%s, %s)\n",
 			hostname, anynet_ntoa(sap));
@@ -4118,7 +4120,11 @@
 	}
 
 #if TCPWRAPPERS
-	if (!hosts_ctl("sendmail", hostname, anynet_ntoa(sap), STRING_UNKNOWN))
+	if (hostname[0] == '[' && hostname[strlen(hostname) - 1] == ']')
+		host = STRING_UNKNOWN;
+	else
+		host = hostname;
+	if (!hosts_ctl("sendmail", host, anynet_ntoa(sap), STRING_UNKNOWN))
 	{
 		if (tTd(48, 4))
 			printf("  ... validate_connection: BAD (tcpwrappers)\n");
