From wietse@wzv.win.tue.nl Tue Jul 9 19:20:04 1996 Received: by wzv.win.tue.nl (8.7.4/1.45) id TAA03288; Tue, 9 Jul 1996 19:20:04 +0200 (MET DST) From: wietse@wzv.win.tue.nl (Wietse Venema) Message-Id: <199607091720.TAA03288@wzv.win.tue.nl> Subject: tcpd support built into sendmail To: BKnowles@aol.net Date: Tue, 9 Jul 96 19:20:04 MET DST Cc: wietse (Wietse Venema) Organization: Eindhoven University of Technology, P.O. Box 513, 5600 MB Eindhoven, The Netherlands X-Phone: +31 40 2472989 X-Fax: +31 40 2465995 X-Private: +31 40 2433327 X-Mailer: ELM [version 2.3 PL11] Status: O I've put the message below on anonymous FTP as sendmail-tcpd.patch. Wietse -----BEGIN PGP SIGNED MESSAGE----- This is a minimal patch to sendmail 8.7.5 that adds built-in tcp wrapper support. This should give the same functionality as running sendmail under control of the tcp wrapper, except that you do not incur the cost of starting sendmail from scratch for each connection. Installation instructions: - Cd into the sendmail.whatever/src directory - Unshar this file - Apply the patch (patch wrapper.diff <<'END_OF_wrapper.diff' X*** ./Makefiles/Makefile.FreeBSD- Wed Sep 13 17:29:01 1995 X--- ./Makefiles/Makefile.FreeBSD Tue Jul 9 15:30:35 1996 X*************** X*** 14,29 **** X # really gnarly systems, you can set this to null; it will crawl like a high X # spiral snail, but it will work. X DBMDEF= -DNEWDB X X! CFLAGS+=-I${.CURDIR} ${DBMDEF} X X SRCS= alias.c arpadate.c clock.c collect.c conf.c convtime.c daemon.c \ X deliver.c domain.c envelope.c err.c headers.c macro.c main.c map.c \ X mci.c mime.c parseaddr.c queue.c readcf.c recipient.c savemail.c \ X srvrsmtp.c stab.c stats.c sysexits.c trace.c udb.c usersmtp.c \ X! util.c version.c X DPADD= X! LDADD= $(LIBUTIL) X # X # FreeBSD 1.0 RELEASE has GNU man and doesn't need preformatted man pages anymore X # (assuming you consider a slower "man" command a feature) X--- 14,32 ---- X # really gnarly systems, you can set this to null; it will crawl like a high X # spiral snail, but it will work. X DBMDEF= -DNEWDB X+ WRAPDIR= /home/wietse/tcp_wrappers_7.4 X+ WRAPDEF= -I$(WRAPDIR) -DHOSTS_ACCESS X+ WRAPLIB= -L$(WRAPDIR) -lwrap X X! CFLAGS+=-I${.CURDIR} ${DBMDEF} ${WRAPDEF} X X SRCS= alias.c arpadate.c clock.c collect.c conf.c convtime.c daemon.c \ X deliver.c domain.c envelope.c err.c headers.c macro.c main.c map.c \ X mci.c mime.c parseaddr.c queue.c readcf.c recipient.c savemail.c \ X srvrsmtp.c stab.c stats.c sysexits.c trace.c udb.c usersmtp.c \ X! util.c version.c wantconn.c X DPADD= X! LDADD= $(LIBUTIL) $(WRAPLIB) X # X # FreeBSD 1.0 RELEASE has GNU man and doesn't need preformatted man pages anymore X # (assuming you consider a slower "man" command a feature) X*** ./daemon.c- Wed Nov 29 18:24:45 1995 X--- ./daemon.c Tue Jul 9 19:07:33 1996 X*************** X*** 313,318 **** X--- 313,331 ---- X OutChannel = outchannel; X DisConnected = FALSE; X X+ #ifdef HOSTS_ACCESS X+ if (wantconn(t, "sendmail") == 0) { X+ #ifdef LOG X+ syslog(LOG_WARNING, "refusing connection from %s/%s", X+ RealHostName, anynet_ntoa(&RealHostAddr)); X+ #endif X+ message("421 %s Sendmail will not talk to %s.", X+ MyHostName, RealHostName); X+ sleep(1); X+ exit(0); X+ } X+ #endif X+ X /* should we check for illegal connection here? XXX */ X #ifdef XLA X if (!xla_host_ok(RealHostName)) END_OF_wrapper.diff if test 2249 -ne `wc -c wantconn.c <<'END_OF_wantconn.c' X /* X * NAME X * X * wantconn - build tcpd access control into any TCP or UDP application X * X * SYNOPSIS X * X * extern int wantconn(int sock, char *progname) X * X * extern int allow_severity; X * X * extern int deny_severity; X * X * DESCRIPTION X * X * wantconn() returns a non-zero value when the client in sock is allowed to X * talk to the daemon in progname. As a side effect of calling wantconn(), X * the syslog severity levels in the global variables allow_severity and X * deny_severity may be updated. X * X * wantconn() is not "paranoid", i.e. it does not autmoatically refuse clients X * whose host name is inconsistent with their address. X * X * AUTHOR X * X * Wietse Venema, Eindhoven University of Technology, The Netherlands X */ X X#include X X#ifdef __hpux X#define request_info tcpd_request_info X#endif X X#ifndef ALLOW_SEVERITY X#define ALLOW_SEVERITY LOG_INFO X#define DENY_SEVERITY LOG_WARNING X#endif X X#include "tcpd.h" X Xint allow_severity; /* run-time adjustable */ Xint deny_severity; /* ditto */ X Xint wantconn(sock, progname) Xint sock; Xchar *progname; X{ X struct request_info request; X X /* X * Reset the logging level in case we are called from a program that X * responds to multiple clients. X */ X allow_severity = ALLOW_SEVERITY; X deny_severity = DENY_SEVERITY; X X /* X * The user will expect that this will work as if sendmail is run under X * control of the tcpd program. For perfect emulation we must be prepared X * to do our own username lookup and whatever else tcpd may want to do in X * the future. The cost is a small hit in performance. X */ X request_init(&request, RQ_FILE, sock, RQ_DAEMON, progname, 0); X fromhost(&request); X return (hosts_access(&request)); X} END_OF_wantconn.c if test 1785 -ne `wc -c