[net.mail] uucp!user%localnet, etc, with a Free Surprise Present!

gnu@sun.uucp (John Gilmore) (10/17/84)

sdcsvax!brian suggests:

> 	when I send mail from one of our campus machines ('wizard', for
> 	example), the address will appear as follows:
> 		sdcsvax!brian%wizard
> 	since 'sdcsvax' is our portal to the world.

A better choice is to output your local addresses as
		sdcsvax!wizard!brian
since there is a firmly defined parsing order for that, while there
is no firmly defined precedence between ! and %.

> UCSD is our local domain.  (We have a ucsd net registered with the NIC).
> 
> When we get full sub-subdomains installed (there are about 50 machines
> on campus that can send/receive mail), split along administrative or
> departmental lines, each sub-subdomain(ssd) will have a name, and a mail
> server that can route mail within that ssd.  So, for example, the
> machines in the computer center will generate addresses of the sort
> 	brian%sdcc9.cc.ucsd
> as a return address.  Mail entering our portal at sdcsvax can be
> addressed using this address, eg
> 	sdcsvax!brian%sdcc9.cc.ucsd

I would think that for internal use you'd have
	brian@sdcc9.cc.ucsd   .
When accepting mail from outside to get to such a place, it looks like
the uucp mail project has settled on this syntax:
	sdcsvax!sdcc9.cc.ucsd!brian
because we know of no Unix mailers that will munge an address like
this unless the dotted "hostname" is the first hostname in the list.
Also note that this is the same convention used for "brian@wizard" above.

> If/when we get on the Internet, the above composite address
> (user%machine  or user%ssd) will simply be the mailbox part of a
> standard RFC822 address, such as brian%wizard.cglab@UCSD, or more
> simply, brian%cglab@UCSD.

The standard Internet address should have the subdomains and hosts
on the RIGHT side of the @ -- that's what it's there for, to separate the
username from the host&domain.  Thus you'd be:
				    brian@wizard.cglab.ucsd
   or     brian@cglab.ucsd

There's an outstanding question in my mind whether "ucsd" should be
a top level domain (Sun has a network registered at the NIC too, but
that doesn't make us one of a few dozen names that every site in the
world should know how to route to).  There should be no problem tucking
it under the uucp, csnet, or arpa domains though.  Or whatever strange
world domain naming scheme the ISI folks have dreamed up this season.

------------------ The Free Surprise!

What follows below is excerpts from our local sendmail.cf file which
implement rewriting of local addresses into uucp-like addresses as
described above.  As an added feature, the stuff at the bottom
(rule 8) hacks mail relayed from our Arpanet relay (ucbvax) to make
the relay transparent (i.e. to make the return address "foo@bar.arpa"
rather than "ucbvax!foo@bar.arpa").

You'll have to merge these into your sendmail.cf file.  The best way
I've found is to print both on fanfold paper and spread them out on 
a table.  Diffs don't usually work very well because of the cryptic
and very context-sensitive nature of the file.

One more thing.  I've used rewriting rule numbers greater than 30 for
convenience (mine, not yours).  The standard sendmail only allows 30
rules.  You'll have to either recompile your sendmail with this silly
limit raised, or change rules 30, 38, etc. to have smaller (otherwise
unused) numbers.  Search for all the "30"s in the file and fix them
all, don't just change the number in the "S" line and expect it to
work.  If you don't do either, your sendmail will point out the
rewriting rule numbers it can't deal with, when you first test the
merged config file.

I'll answer questions, but remember -- NO WARRANTEES!


############################################################
###	local info
############################################################

# my official hostname
# You have two choices here.  If you want the gateway machine to identify
# itself as the DOMAIN, use this line:
Dj$D.$U
# If you want the gateway machine to appear to be INSIDE the domain, use:
#Dj$w.$D.$U

# major relay mailer
DMuucp

# major relay host
DR ucbvax
CR ucbvax

# local domain names
DDsun
CDsun

# domain-spec for local domain within universe (eg, what domains are above?)
DUuucp

# known SMTP/ethernet hosts (this domain only)
FS/etc/hosts.equiv
FS/usr/lib/mailhosts

# my name
DnMAILER-DAEMON

#################################
#  Final Output Post-rewriting  #
#################################

S4
R$+<@$+.uucp>		$2!$1				u@h.uucp => h!u
R$+			$: $>9 $1			Clean up addr
R$*<$+>$*		$1$2$3				defocus


################################################
#  Clean up an address for passing to a mailer #
#  (but leave it focused)		       #
################################################

S9
# externalize internal forms which don't meet external specs
R@			$@$n				handle <> error addr
R$*<$*LOCAL>$*		$1<$2$D.$U>$3			change local info
R<@$+>$*:$+:$+		<@$1>$2,$3:$4			<route-addr> canonical


###########################
#  Name Canonicalization  #
###########################

# Internal format of addresses within the rewriting rules is:
# 	anything<@host.domain.domain...>anything
# We try to get every kind of address into this format, except for local
# addresses, which have no host part.  The reason for the "<>" stuff is
# that the relevant host name could be on the front of the address (for
# source routing), or on the back (normal form).  We enclose the one that
# we want to route on in the <>'s to make it easy to find.
# 

S3

# handle "from:<>" special case
R<>			$@@				turn into magic token

# basic textual canonicalization
R$*<$+>$*		$2				basic RFC821/822 parsing
R$+ at $+		$1@$2				"at" -> "@" for RFC 822

# make sure <@a,@b,@c:user@d> syntax is easy to parse -- undone later
R@$+,$+:$+		@$1:$2:$3			change all "," to ":"
R@$+:$+			$@$>6<@$1>:$2			src route is canonical

# more miscellaneous cleanup
R$+			$:$>8$1				host dependent cleanup
R$+:$*;@$+		$@$1:$2;@$3			list syntax
R$+@$+			$:$1<@$2>			focus on domain
R$+<$+@$+>		$1$2<@$3>			move gaze right
R$+<@$+>		$@$>6$1<@$2>			already canonical

# convert old-style addresses to domain-based addresses
# All old-style addresses parse from left to right, without precedence.
# Note that the left side of '%' is a username; it is matched with $+ so
# that complex names like "john.gilmore%l5" will be caught and translated.
# The rest can only have an atom as the host name (left of the symbol).
R$-:$+			$@$>3$2@$1			host:user
R$-^$+			$1!$2				convert ^ to !
R$-!$+			$@$>6$2<@$1.uucp>		uucphost!user
R$-=$+			$@$>6$2<@$1.bitnet>		bitnethost=user
R$-.$+!$+		$@$>6$3<@$1.$2>			host.domain!user
R$+%$+			$@$>3$1@$2			user%host


#######################
#   Rewriting rules   #
#######################

##### special local conversions
S6
R$*<@$*$=D>$*		$1<@$2LOCAL>$4			convert local domain
R$*<@$*$=D.$U>$*	$1<@$2LOCAL>$4			or full domain name


############################################################
############################################################
#####
#####		UUCP Mailer specification
#####
#####		@(#)uucpm.m4 1.3 84/03/23 SMI; from UCB	3.6	3/26/83
#####
############################################################
############################################################

############################################################
############################################################
#####
#####		Provide Backward Compatibility
#####
#####		@(#)compat.m4 1.3 84/03/23 SMI; from UCB	3.3	2/24/83
#####
############################################################
############################################################



##########################################################
#  General code to convert back to old style UUCP names  #
##########################################################

S5
R$+<@LOCAL>		$@ $D!$1			name@LOCAL => sun!name
R$+<@$-.LOCAL>		$@ $2!$1			u@h.LOCAL => h!u
R$+<@$+.uucp>		$@ $2!$1			u@h.uucp => h!u
R$+<@$=S>		$@ $2!$1			u@etherh => etherh!u
R$+<@$+>		$@ $1%$2			u@any => u%any
# Route-addrs do not work here.  Punt til uucp-mail comes up with something.
R<@$+>$*		$@ @$1$2			just defocus and punt
R$*<$*>$*		$@ $1$2$3			Defocus strange stuff

Muucp,	P=/usr/bin/uux, F=sDFMhuU, S=13, R=23,
	A=uux - -r $h!rmail ($u)

# Convert uucp sender (From) field
S13
R$+			$:$>5$1				convert to old style
R$=w!$+			$2				strip local name
R$+			$:$w!$1				stick on real host name

# Convert uucp recipient (To, Cc) fields
S23
R$+			$:$>5$1				convert to old style



############################################################
############################################################
#####
#####		RULESET ZERO
#####
#####	domain.cf has a totally custom Ruleset Zero.
#####
############################################################
############################################################

# Ruleset 30 just calls rulesets 3 then 0.
S30
R$*			$: $>3 $1			First canonicalize
R$*			$@ $>0 $1			Then rerun ruleset 0

S0
# On entry, the address has been canonicalized and focused by ruleset 3.
# Handle special cases.....
R@			$#local $:$n			handle <> form
# For numeric spec, you can't pass spec on to receiver, since rcvr's
# are not smart enough to know that [x.y.z.a] is their own name.
R<@[$+]>:$*		$:$>9 <@[$1]>:$2		Clean it up, then...
R<@[$+]>:$*		$#ether $@[$1] $:$2		numeric internet spec
R<@[$+]>,$*		$#ether $@[$1] $:$2		numeric internet spec
R$*<@[$+]>		$#ether $@[$2] $:$1		numeric internet spec

# resolve the local hostname to "LOCAL".
R$*<$*$=w.LOCAL>$*	$1<$2LOCAL>$4			thishost.LOCAL
R$*<$*$=w.uucp>$*	$1<$2LOCAL>$4			thishost.uucp
R$*<$*$=w>$*		$1<$2LOCAL>$4			thishost

# Mail addressed explicitly to the domain gateway (us)
R$*<@LOCAL>		$@$>30$1			strip our name, retry
R<@LOCAL>:$+		$@$>30$1			retry after route strip

# deliver to known ethernet hosts explicitly specified in our domain
R$*<@$*$=S.LOCAL>$*	$#ether $@$3 $:$1@$2$3.$D.$U$4	user@etherhost.sun.uucp

# etherhost.uucp is treated as etherhost.$D.$U for now.
# This allows them to be addressed from uucpnet as foo!sun!etherhost!user.
R$*<@$*$=S.uucp>$*	$#ether $@$3 $:$1@$2$3.$D.$U$4	user@etherhost.uucp

# Explicitly specified names in our domain -- that we've never heard of
R$*<@$*.LOCAL>$*	$#error $:Never heard of host $2 in domain $D.$U

# Clean up addresses for external use -- kills LOCAL, route-addr ,=>: and etc.
R$*			$:$>9 $1			Then continue...

# resolve UUCP domain
R<@$-.uucp>:$+		$#uucp  $@$1 $:$2		@host.uucp:...
R$+<@$-.uucp>		$#uucp  $@$2 $:$1		user@host.uucp

# Pass Arpanet and Bitnet names up the ladder to our forwarder
R$*<@$*$-.arpa>$*	$#$M    $@$R $:$1@$2$3.arpa$4	user@anything.arpa
R$*<@$*$-.bitnet>$*	$#$M    $@$R $:$1@$2$3.bitnet$4	user@anything.bitnet

# All addresses in the rules ABOVE are absolute (fully qualified domains).
# (Note that all patterns end in a word, not a multi-matcher).
# Addresses BELOW can be partially qualified.

# deliver to known ethernet hosts
R$*<@$*$=S>$*		$#ether $@$3 $:$1@$2$3$4	user@etherhost

# other non-local names have nowhere to go; return them to sender.
R$*<@$+.$->$*		$#error $:Unknown domain $3
R$*<@$+>$*		$#error $:Never heard of $2; maybe you mean $2.arpa ?
R$*@$*			$#error $:I don't understand $1@$2

# Local names with % are really not local!
R$+%$+			$@$>30$1@$2			turn % => @, retry

# everything else is a local name
R$+			$#local $:$1			local names


#
# Host-dependent address cleanup:  strip Berkeley! relay off Arpanet mail
#
S8
#
# Handle from addresses that arrive over uucp from our Arpanet relay
# site.  They are passed to us in the -f argument from rmail, when uucp
# hands us the message.  Since many Arpa hosts are not qualifying their
# domains yet, we have to tack on ".arpa" if no domain is specified.
#
# If there's no atsign in the name, just let it on thru -- it's being
# relayed from a uucp site.
#
# THIS IS A KLUDGE OF THE EMERGENCY BROADCAST SYSTEM.  THIS IS ONLY A KLUDGE.
# It will have to stay around until our relay site passes us real
# domain-based addresses, at which point all we have to do is strip off
# the uucp garbage on the front.
#
R$=R!$*			$@ $>38 $2		Run thru 38 if came from relay!
# Otherwise, the address is OK as it stands.

# This address is from our Arpa relay site.  Fix it for slow Arpanauts.
S38
R$*			$: $>3 $1		Canonicalize, focus rest of it
R$*<@$-.uucp>		$@ $2!$1@$R.uucp	If uucp addr, leave relay on.
R$*<@$*LOCAL>$*		$@ @$R.uucp:$1@$2$D.$U$3	If LOCAL, deloc&relay
R$*<@$+.$*>$*		$@ $1@$2.$3$4		If domain known, defocus&return
R$*<@$+>$*		$@ $1@$2.arpa$3		If not, "arpa", defocus&return
R$*<$*>$*		$@ $R!$1$2$3		Restore unknown strangenesses
R$*			$@ $R!$1		Restore unknown strangenesses

# Kludge to deal with non-UGLYUUCP mail from our relay site.
# Adds host "somewhere" to the class containing our relay site.  It will
# be translated to the real name, or removed, by the S8 code.
CRsomewhere