Subject: misc/26682: Patch to rulesets for two features for networks with internal-only domain names that connect to the outside world for email
To: None <gnats-bugs@gnats.netbsd.org>
From: None <danielfdickinson@yahoo.ca>
List: netbsd-bugs
Date: 08/16/2004 02:58:30
>Number:         26682
>Category:       misc
>Synopsis:       Add two handy features for internal-only-domain networks
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    misc-bug-people
>State:          open
>Class:          change-request
>Submitter-Id:   net
>Arrival-Date:   Mon Aug 16 07:23:00 UTC 2004
>Closed-Date:
>Last-Modified:
>Originator:     Daniel F. Dickinson
>Release:        NetBSD 1.6.2
>Organization:
none
	
>Environment:
	
	
System: NetBSD hardknottpass.estiria.net 1.6.2 NetBSD 1.6.2 (GENERIC) #0: Tue Feb 10 21:53:10 UTC 2004 autobuild@tgm.netbsd.org:/autobuild/netbsd-1-6-PATCH002/i386/OBJ/autobuild/netbsd-1-6-PATCH002/src/sys/arch/i386/compile/GENERIC i386
Architecture: i386
Machine: i386
>Description:
	
	This patch adds two FEATUREs to sendmail.  
	FEATURE(`mailhub_is_local') forwards local email to MAILHUB even if MAILHUB is local (in class w).
	FEATURE(`masquerade_remote_only') masquerades (and/or generictables) mail that is going outside the local network (Cw) but not mail to a local host (Cw).  
>How-To-Repeat:
	
	Not really a bug, so ignore how to repeat.
>Fix:
	
	To apply the patch:
		patch < patchfile (below)

Only in /usr/share/sendmail/feature: mailhub_is_local.m4
Only in /usr/share/sendmail/feature: masquerade_remote_only.m4
diff -duHr /home/braelon/usr/share/sendmail/m4/proto.m4 /usr/share/sendmail/m4/proto.m4
--- /home/braelon/usr/share/sendmail/m4/proto.m4	Tue Feb 10 16:41:54 2004
+++ /usr/share/sendmail/m4/proto.m4	Mon Aug 16 01:53:47 2004
@@ -13,6 +13,7 @@
 #
 divert(0)
 
+VERSIONID(`proto.m4 Aug 15 2004 danielfdickinson@yahoo.ca local_mailhub')
 VERSIONID(`Id: proto.m4,v 8.446.2.5.2.44 2001/07/31 22:25:49 gshapiro Exp')
 
 MAILER(local)dnl
@@ -1119,7 +1120,12 @@
 R< local : $* > $*		$>CanonLocal < $1 > $2
 R< $- : $+ @ $+ > $*<$*>$*	$# $1 $@ $3 $: $2<@$3>	use literal user
 R< $- : $+ > $*			$# $1 $@ $2 $: $3	try qualified mailer
+ifdef(`_MAILHUB_IS_LOCAL_', `dnl
+R< $=w > $+ < @ $+ >		$: localhub < $1 > $2 < @ $3 >
 R< $=w > $*			$@ $2			delete local host
+Rlocalhub < $+ > $+ < @ $+ >	$: < $1 > $2 < @ $3 >',
+`dnl
+R< $=w > $*			$@ $2			delete local host')
 R< [ IPv6 : $+ ] > $*		$#_RELAY_ $@ $(dequote $1 $) $: $2	use unqualified mailer
 R< $+ > $*			$#_RELAY_ $@ $1 $: $2	use unqualified mailer
 
@@ -1154,12 +1160,37 @@
 R< $+ > $* <@ $* > $*		$#_LOCAL_ $@ $2@$3 $: $1
 R< $+ > $* 			$#_LOCAL_ $@ $2    $: $1
 
+ifdef(`_MASQUERADE_REMOTE_ONLY_', `dnl
+###################################################################
+###  Ruleset 83 -- hostname for local, blank for remote         ###
+###################################################################
+
+SToIsLocal=83
+R$*				$: < $1 >
+R< $+ *LOCAL* > 		$: < $1 >
+R< $=w >			$: local to
+R< $+ >				$: remote to
+
 ###################################################################
 ###  Ruleset 93 -- convert header names to masqueraded form	###
 ###################################################################
 
 SMasqHdr=93
+# skip masquerading of local-local traffic but masquerade (and generics)
+# local-remote
+R$+				$: $1 @ $>83 $&h	Mark local address
+R$+ @ remote to			$: $>84 $1		Remote=Masquerade
+R$+ @ local to  		$: $1			Unmark local
 
+SOriginalMasqHdr=84
+',
+`dnl
+###################################################################
+###  Ruleset 93 -- convert header names to masqueraded form	###
+###################################################################
+
+SMasqHdr=93
+')
 ifdef(`_GENERICS_TABLE_', `dnl
 # handle generics database
 ifdef(`_GENERICS_ENTIRE_DOMAIN_',
>Release-Note:
>Audit-Trail:
>Unformatted: