UK-1.1 Sendmail Configuration Package. Part 1 of 3
sources-request at genrad.UUCP
sources-request at genrad.UUCP
Wed May 15 06:25:18 AEST 1985
I've had a number of requests for this, since I announced it in net.mail
So, I'm sending it in 3 shar archives to mod.sources. One warning:
Some of the shell scripts I use are BSD specific. (E.g. I use "cat -n"
and "fmt" in places.) I assumed that most people who have sendmail
are running 4.xBSD.
Jim Crammond
jim at hwcs.uucp
uck!hwcs!jim
jim at cs.hw.ac.uk (soon)
# This is a shell archive.
# Remove everything above and including the cut line.
# Then run the rest of the file through sh.
-----cut here-----cut here-----cut here-----cut here-----
#!/bin/sh
# shar: Shell Archiver
# Run the following text with /bin/sh to create:
# README
# MAKE
# Mailers.a
# Rules.a
# Support
# This archive created: Mon May 13 18:37:37 1985
echo shar: extracting README '(6249 characters)'
cat << \SHAR_EOF > README
Scenario
--------
This configuration file is designed to handle three basic scenarios:
1. A single-host site
2. A multi-host site with one central host, and a number of satellites
3. A multi-host site which is fully distributed, i.e. no central host
As an example, consider a site called "ucs", whose domain name is "ucs.ac.uk".
In case 1, the host name is the same as the site name - "ucs".
In case 2, the central host is called "ucs", and its domain name is
"ucs.ac.uk". Satellite hosts will be subdomains of "ucs" so,
for example, a satellite host whose hostname is "vax1" will
have domain name "vax1.ucs.ac.uk"
Mail sent to user at ucs would always be sent to the central machine
(where it may be aliased to be delivered at a satellite).
In case 3, All hosts are like satellites in that they are all subdomains
of "ucs" (there is no host called "ucs").
Mail to user at ucs will be either aliased to a specific host or
delivered locally. (The same alias file can be distributed
to all machines.)
From the outside, all hosts will appear as one host - "ucs".
Mailers
-------
The following mailers are supported:
local the standard unix local mailer
ether mail over the ethernet
luucp local uucp mail (uses domain addressing)
uucp external uucp mail
janet janet mail, using hhcp
bitnet bitnet mail, using rscs
Addresses
---------
This configuration file accepts addresses in any of the standard forms:
RFC822 style: @domain1, at domain2:user at domain3
Percent style: user%domain3%domain2 at domain1
UUCP style: domain1!domain2!domain3!user
(If you define the Janet mailer then JNT style with big-endian domain name
ordering is also understood).
Mixed addresses are handled by using the precedence order '@' > '%' > '!'
e.g. domc!user%domb at doma => user%domc%domb at doma <=> doma!domb!domc!user
Configuration Overview
----------------------
These address forms are converted in ruleset 3 to one internal form - which
is Percent style. The rulesets 5 and 6 are then called which expands
incomplete domain names and aliases into full domain names.
The routing rule, ruleset 9, called from ruleset 0, converts this domain form
to an <address>host.network triple from which the appropriate mailer is
selected in ruleset 0.
Meanwhile the mailer specific rulesets convert the header addresses returned
by ruleset 3 into the appropriate form for the mailer.
Files
-----
The configuration file is generated from a set of m4 files:
Site independent:
base.m4 Defines special macros, options and headers etc.
version.m4 Gives the version number and history
rules.m4 Defines the standard rulesets
rules1.m4 Defines rulesets to do address conversions
<mailer>m.m4 Mailer specifications - one for each of the above
mailers
Site dependent:
<site>.dom Defines the domain tables for the site
Host dependent:
<host>.mc This defines some macros and reads everything else in.
<host>.chn This specifies all the routing information for
non-local mail
Installation
------------
1. Decide what your host, site and domain names are for this host.
2. Then run "MAKE".
This creates a directory containing all the rules and mailer m4 files
required for this configuration and creates the <host>.mc file.
MAKE will first ask for your host, site and domain names. If the host
and site names are the same then MAKE assumes that this is either a
single host site (case 1) or the central machine of multi-host site
(case 2); if they are different then MAKE asks if there is a central
host for this site (case 2); if there isn't it assumes this a distributed
multi-host site (case 3).
MAKE will then prompt for the mailers to include in the configuration,
and then it creates all the files.
3. "cd" to directory dom.
Here you must setup the domain tables from which the <site>.dom file
is generated.
There is only one of these per site, so if you have already done this
on another host, just copy the tables to this host.
More details are found in the README contained in the "dom" directory.
4. "cd" to directory chn
Here you must setup the channel tables which give all the routing
information from which the <host>.chn file is generated.
More details are found in the README contained in the "chn" directory.
5. "cd" to the <host> directory.
Run "make" to produce the <host>.cf file.
This can be tested by using "sendmail -bt -C<host>.cf" - if you haven't
used this before then see the sendmail documentation for details.
Also check that the mailer specification files have the correct
pathnames and options to the mailers, particularly the local mailer!
6. As superuser, run "make install" to install this. If you have a
sendmail daemon running (typically: /usr/lib/sendmail -bd -q1h),
then kill it and start a new one.
Running shared configuration files
----------------------------------
In the case where (satellite) hosts have the same routing information
and mailers to mail to other hosts, they can use the same configuration
file. To to this, run "MAKE" for one host, then edit the "DOMAIN"
definition in the resulting ".mc" file replacing the hostname with "$w".
e.g.
define(`DOMAIN',`$w.usc.ac.uk')
Run make and copy the resulting configuration file to all appropriate hosts.
Support programs
----------------
The Support directory contains programs that interface with sendmail.
More details are found in the README in the "Support" directory.
Aliases
-------
A type 3 site can use a common aliases file on all hosts containing
a list of users and the host addresses to which they wish their mail
to be delivered to, e.g.
jim: jim at vax1
fred: fred at vax2
Addresses of the form "user", "user at host" and "user at site" are all subject
to possible aliasing. In the "usc" example, "jim at vax2" will be sent to vax2.
If the aliases file on vax2 contains the above entries then the mail will
be delivered on vax1 (or aliased again).
Aliasing can be overridden by prepending a '~' to the user, so "~jim at vax2"
will be delivered on vax2.
--------
Mail bugs and comments to: jim at hwcs.uucp (hwcs!jim)
soon to be: jim at cs.hw.ac.uk
-Jim Crammond 22.4.85
SHAR_EOF
if test 6249 -ne "`wc -c README`"
then
echo shar: error transmitting README '(should have been 6249 characters)'
fi
echo shar: extracting MAKE '(3263 characters)'
cat << \SHAR_EOF > MAKE
#!/bin/sh
echo 'Sendmail initial configuration program UK-1.1
'
ether=
uucp=
janet=
bitnet=
#
# site dependant information information about names and mailers
#
host=`(hostname) 2> /dev/null || (uuname -l) 2> /dev/null`
site=$host
echo -n "Enter name of host ($host): "
read reply
if [ "$reply" != "" ]
then
host=$reply
fi
echo -n "Enter name of site ($site): "
read reply
if [ "$reply" != "" ]
then
site=$reply
fi
if [ $site = $host ]
then
echo -n "Complete host domain name: $host."
read domain
domain=$host.$domain
else
echo -n "Complete host domain name: $host.$site."
read domain
domain=$site.$domain
echo -n "Is there a host \"$site\" in domain \"$domain\"? (y|n) "
read reply
if [ "$reply" != 'y' ]
then
multihost=true
else
domain=$host.$domain
fi
fi
echo -n "
Site name = $site, Host name = $host, Domain name = $domain
confirm? (y|n) "
read reply
if [ "$reply" != 'y' ]
then
echo 'Start again'
exit 1
fi
echo "
A list of available mailer configurations will follow
type 'y' at the prompt to include the specified mailer.
"
echo -n "ethernet? "
read reply
if [ "$reply" = 'y' ]; then ether=etherm.m4; fi
echo -n "uucp? "
read reply
if [ "$reply" = 'y' ]
then
uucp="luucpm.m4 uucpm.m4";
uucpname=`uuname -l`
echo -n "Enter uucp name ($uucpname): "
read reply
if [ -n "$reply" ]
then
uucpname=$reply
fi
fi
echo -n "janet? "
read reply
if [ "$reply" = 'y' ]; then janet=hhcpm.m4; fi
echo -n "bitnet? "
read reply
if [ "$reply" = 'y' ]; then bitnet=bitnetm.m4; fi
#
# now start creating the files
#
echo -n "
Making directory $host... "
if mkdir $host
then
cd $host
else
echo mkdir failed, aborted
exit 1
fi
echo -n '
creating rules... '
ar x ../Rules.a
echo -n '
creating mailers... '
ar x ../Mailers.a localm.m4 $ether $uucp $janet $bitnet
echo -n '
creating Makefile... '
cat >Makefile <<EOF
#######################################################################
#
# Makefile for Sendmail configuration files
#
# @(#)Makefile UK-1.1 sendmail configuartion 22/4/85
#
#######################################################################
HOST=$host
SITE=$site
RULES=base.m4 rules.m4 rules1.m4 version.m4
MAILERS=localm.m4 $ether $uucp $janet $bitnet
EOF
cat >>Makefile <<'EOF'
.SUFFIXES: .mc .cf
.mc.cf:
m4 $*.mc > $*.cf
$(HOST).cf: $(RULES) $(MAILERS) $(SITE).dom $(HOST).chn
$(SITE).dom: ../dom/$(SITE).dom
cp ../dom/$(SITE).dom $(SITE).dom
$(HOST).chn: ../chn/$(HOST).chn
cp ../chn/$(HOST).chn $(HOST).chn
install: $(HOST).cf
sed -e '/^#/d' -e '/^$$/d' $(HOST).cf > /usr/lib/sendmail.cf
-if [ -f /usr/lib/sendmail.fc ]; then /usr/lib/sendmail -bz; fi
EOF
echo -n "
creating $host.mc... "
cat >$host.mc <<EOF
define(\`HOST',\`$host')
define(\`SITE',\`$site')
define(\`DOMAIN',\`$domain')
EOF
if [ -n "$multihost" ]
then
echo "define(\`MULTIHOST')" >> $host.mc
fi
if [ -n "$ether" ]
then
echo "define(\`ETHER')" >> $host.mc
fi
if [ -n "$uucp" ]
then
echo "define(\`UUCPNAME',\`$uucpname')" >> $host.mc
fi
if [ -n "$janet" ]
then
echo "define(\`JANET')" >> $host.mc
fi
if [ -n "$bitnet" ]
then
echo "define(\`BITNET')" >> $host.mc
fi
echo 'include(base.m4)' >> $host.mc
echo "
Initial configuration complete.
You now have to make the $site.dom and $host.chn files.
"
exit
SHAR_EOF
if test 3263 -ne "`wc -c MAKE`"
then
echo shar: error transmitting MAKE '(should have been 3263 characters)'
fi
echo shar: extracting Mailers.a '(5816 characters)'
cat << \SHAR_EOF > Mailers.a
!<arch>
bitnetm.m4 483046164 217 10 100644 1384 `
###############################################################################
###############################################################################
#####
##### Bitnet Mailer specification
#####
##### @(#)bitnetm.m4 UK-1.1 sendmail configuration 22/4/85
#####
###############################################################################
###############################################################################
Mbitnet, P=/usr/bin/vmcopy, F=SnsFDMR, S=22, R=22,
A=vmcopy $u@$h class=M fname=MAILER ftype=MAIL width=80 device=PUNCH
S22
#
# Bitnet can only cope with user at host.bitnet i.e. no subdomains
# therefore strip off any that exist
#
R$+@$=A.$j $@$1@$j strip off any local hostname
R$+@$+ $@$1@$2 return user at domain
R$+ $@$1@$j add local domain name
##################################################################
#####
##### Arpa Mail Via Batched Simple Mail Transfer Protocol
#####
##################################################################
Mbarpa, P=/usr/lib/rscs/bsmtp, F=SnsFDMRX, S=22, R=22,
A=bsmtp%mail $j $g $u $h
##################################################################
#####
##### Uucp Mail Via Batched Simple Mail Transfer Protocol
#####
##################################################################
Mbuucp, P=/usr/lib/rscs/bsmtp, F=SnsFDMRuhX, S=22, R=22, M=100000,
A=bsmtp%mail $j $g $u $h
etherm.m4 483046164 217 10 100644 557 `
###############################################################################
###############################################################################
#####
##### Ethernet Mailer specification
#####
##### @(#)etherm.m4 UK-1.1 sendmail configuration 22/4/85
#####
###############################################################################
###############################################################################
Mether, P=[IPC], F=nsmFDMRuXC, S=17, R=15, A=IPC $h
S17
R$+@$+ $@$1@$2 address ok
R$+ $@$1@$w add local hostname
hhcpm.m4 483046164 217 10 100644 703 `
###############################################################################
###############################################################################
#####
##### Janet Mailer specification
#####
##### @(#)hhcpm.m4 UK-1.1 sendmail configuration 22/4/85
#####
###############################################################################
###############################################################################
Mhhcp, P=/usr/lib/x25/hhsend, F=nsmFDMxVh, S=21, R=21, M=100000,
A=hhsend $h $u
S21
ifdef(`MULTIHOST',
`R$+@$=A.$j $1@$j strip local hostname')
R$+@$+ $@$>14$1@$2 RFC822 -> NRS style
R$+ $:$1@$j user -> user at mydomain
R$+@$+ $@$>14$1@$2 RFC822 -> NRS style
localm.m4 483046164 217 10 100644 1155 `
###############################################################################
###############################################################################
#####
##### Local and Program Mailer specification
#####
##### @(#)localm.m4 UK-1.1 sendmail configuration 22/4/85
#####
###############################################################################
###############################################################################
Mlocal, P=/bin/mail, F=rnlsmFDMR, S=16, R=16, A=mail -d $u
Mbinmail, P=/bin/mail, F=rnlsmFDMR, S=16, R=16, A=mail -d $u
Mprog, P=/bin/sh, F=nlsFDMR, S=16, R=16, A=sh -c $u
#
# The important thing here is to keep a valid reply path!
# Apparent uucp addresses are converted back to old style so that
# ucb-mail can cope with replies. Otherwise the domain is just stripped.
#
S16
R@ MAILER-DAEMON errors to mailer-daemon
R~$+ $1 remove '~' in To: line
R$+@$+ $:$>7$1@$2 strip domain addresses
# we assume an address is a uucp address if it contains more than two
# hostnames (as opposed to domain names). This is not always right..
R$+%$-%$-@$+ $@$>13$1%$2%$3@$4 convert to uucp address
luucpm.m4 483046164 217 10 100644 588 `
###############################################################################
###############################################################################
#####
##### Local UUCP Mailer specification
#####
##### @(#)luucpm.m4 UK-1.1 sendmail configuration 22/4/85
#####
###############################################################################
###############################################################################
Mluucp, P=/usr/bin/uux, F=smFDMRuh, S=18, R=18, M=100000,
A=uux - $h!rmail ($u)
S18
R$+@$+ $@$1@$2 address ok
R$+ $@$1@$w add local hostname
uucpm.m4 483046164 217 10 100644 1057 `
###############################################################################
###############################################################################
#####
##### UUCP Mailer specification
#####
##### @(#)uucpm.m4 UK-1.1 sendmail configuration 22/4/85
#####
###############################################################################
###############################################################################
Muucp, P=/usr/bin/uux, F=sFDMRuh, S=19, R=20, M=100000,
A=uux - -r -gA $h!rmail ($u)
#
# Addresses are converted back to uucp style.
# We need to do this to generate a valid Unix From line.
# However this invalidates the From: line in the header, which should be
# in 822 format - strictly speaking. Sendmail won't let you do this!
#
S19
R$+@$+ $:$>13$1@$2 convert to uucp style
ifdef(`MULTIHOST',
`R$=A.$j!$+ $2 strip local hostnames')
R$+!$+ $@$1!$2 address ok
R$+ $@$j!$1 add local domain name
#
# To: line is handled normally
#
S20
R$+@$+ $@$1@$2 address ok
R$+ $@$1@$j add local domain name
SHAR_EOF
if test 5816 -ne "`wc -c Mailers.a`"
then
echo shar: error transmitting Mailers.a '(should have been 5816 characters)'
fi
echo shar: extracting Rules.a '(11204 characters)'
cat << \SHAR_EOF > Rules.a
!<arch>
base.m4 483183564 217 10 100644 2953 `
##################################################################
##################################################################
#####
##### SENDMAIL CONFIGURATION FILE UK-1.1
#####
##### Copyright Jim Crammond, Heriot-Watt University. Apr. 1985.
#####
##### This configuration file maybe be freely distributed,
##### provided no profit is gained by doing so.
#####
##################################################################
##################################################################
##################################################################
`###' HOST configuration file
##################################################################
# domain name
Dj`'DOMAIN
# uucp hostname
ifdef(`UUCPNAME',DU`'UUCPNAME)
############################################################
#
# General configuration information
#
############################################################
include(version.m4)
##########################
### Special macros ###
##########################
# my name
DnMAILER-DAEMON
# UNIX header format
DlFrom $g $d remote from $U
# delimiter (operator) characters (note '~' has been added)
Do.:%@!^=/[]~
# format of a total name
Dq$?x$x $.<$g>
# SMTP login message
ifdef(`MULTIHOST',
`De$w.$j Sendmail $v/$V ready at $b',`De$j Sendmail $v/$V ready at $b')
###################
### Options ###
###################
# location of alias file
OA/usr/lib/aliases
# default delivery mode (deliver in background)
Odbackground
# (don't) connect to "expensive" mailers
#Oc
# temporary file mode
OF0644
# default GID
Og1
# location of help file
OH/usr/lib/sendmail.hf
# log level
OL9
# default messages to old style
Oo
# queue directory
OQ/usr/spool/mqueue
# read timeout -- violates protocols
Or2h
# status file
OS/usr/lib/sendmail.st
# queue up everything before starting transmission
# Os
# default timeout interval
OT3d
# time zone names (V6 only)
# OtGMT,BST
# default UID
Ou1
# wizard's password
OWz3GvK.dPUxieQ
###############################
### Message precedences ###
###############################
Pfirst-class=0
Pspecial-delivery=100
Pjunk=-100
#########################
### Trusted users ###
#########################
Troot
Tdaemon
Tuucp
Tjim
#############################
### Format of headers ###
#############################
H?F?From: $q
H?D?Date: $a
H?F?Resent-From: $q
H?D?Resent-Date: $a
HSubject:
ifdef(`MULTIHOST',
`H?R?Received: $?sfrom $s by $w.$j; $b$.',`H?R?Received: $?sfrom $s by $j; $b$.')
H?V?Via: $?s$s; $b$.
##########################
### The Rulesets ###
##########################
include(rules.m4)
include(rules1.m4)
include(SITE.dom)
include(HOST.chn)
#########################
### The Mailers ###
#########################
include(localm.m4)
ifdef(`ETHER',`include(etherm.m4)')
ifdef(`UUCPNAME',`include(luucpm.m4)')
ifdef(`UUCPNAME',`include(uucpm.m4)')
ifdef(`JANET',`include(hhcpm.m4)')
ifdef(`BITNET',`include(bitnetm.m4)')
rules.m4 484580248 217 10 100644 3178 `
###############################################################################
###############################################################################
#####
##### @(#)rules.m4 UK-1.1 sendmail configuration 22/4/85
#####
##### The rulesets
#####
###############################################################################
###############################################################################
###############################################
# Ruleset 0 -- Select mailer to be used #
###############################################
S0
# local domain - redo with local part of address
R$+@$j $>3$1
ifdef(`MULTIHOST',`R$+@$w.$j $>3$1')
# local mail
R$- $#local$:$1 local mail - maybe aliased
R~$- $#binmail$:$1 local mail - no aliasing
#
# convert domain address into "<address>host.network" triple
#
R$+@$+.$=T $:$>9$1@$2.$3 routing and address conversion
# select mailer
ifdef(`ETHER',`
R<$+>$-.ether $#ether$@$2$:$1 local ethernet mail
')
ifdef(`UUCPNAME',`
R<~$+>$+.luucp <\\~$1>$2.luucp band-aid for uuxqt
R<~$+>$+.uucp <\\~$1>$2.uucp band-aid for uuxqt
R<$+>$-.luucp $#luucp$@$2$:$1 local uucp mail
R<$+>$-.uucp $#uucp$@$2$:$1 external uucp mail
')
ifdef(`JANET',`
R<$+>$+.janet $#hhcp$@$2$:$1 janet mail
')
ifdef(`BITNET',`
R<$+>$-.bitnet $#bitnet$@$2$:$1 bitnet mail
R<$+>$+.barpa $#barpa$@$2$:$1 arpa mail via bitnet
R<$+>$+.buucp $#buucp$@$2$:$1 uucp mail via bitnet
')
# anything else with an '@' in is an error
R$+@$+ $#error$:Domain Unknown
# anything else - e.g. filenames, pipes etc goes to local mailer
R$+ $#local$:$1 local
###############################################
# Ruleset 1 -- Sender Field Pre-rewriting #
###############################################
S1
##################################################
# Ruleset 2 -- Recipient Field Pre-rewriting #
##################################################
S2
##########################################
# Ruleset 3 -- Name Canonicalisation #
##########################################
S3
# handle special cases
R$- $@$1 return "user"
R~$- $@~$1 return "~ user"
R<> $@@ turn null into magic token
# basic textual canonicalisation
R$*<$*>$* $2 basic RFC 822 parsing
R$+ at $+ $1@$2 " at " -> "@" for RFC 822
R$+%$+ $1@$2 convert '%'s to '@'s
R$+@$+@$+ $1%$2@$3 then reduce to only one '@'
# Address conversions. See rules1.m4 for the gory details
R@$+:$+ $:$>10@$1:$2 RFC822 to Percent form
R$+!$+ $:$>12$1!$2 uucp to Percent form
ifdef(`JANET',`
R$+@$+.$+ $:$>8$1@$2.$3 NRS ordering to 822 ordering
')
`#' Domain name expansion. See SITE`'.dom for the details
R$+@$+ $:$>5$1@$2 do domain name aliases
R$+@$+ $:$>6$1@$2 expand incomplete domain names
###############################################
# Ruleset 4 -- Final Output Post-rewriting #
###############################################
# header rewriting is done in the per-mailer rulesets.
S4
R@ $@ handle <> error addr
R$+@$+ $@$1@$2 already ok
# this ensures that $u has at least one '@' in (if percent style)
R$+%$+ $1@$2 convert '%'s to '@'s
R$+@$+@$+ $1%$2@$3 then reduce to only one '@'
rules1.m4 484852372 217 10 100644 3357 `
###############################################################################
###############################################################################
#####
##### @(#)rules1.m4 UK-1.1 sendmail configuration 22/4/85
#####
##### The rulesets
#####
###############################################################################
###############################################################################
#########################################################
# Ruleset 10 -- RFC source routing -> Percent style #
#########################################################
#
# convert a routed address in RFC822 form to Percent form
# e.g. @ucl-cs.arpa, at kcl-cs.uucp:jim at hwcs.uucp ->
# jim%hwcs.uucp%kcl-cs.uucp at ucl-cs.arpa
#
S10
R$+,$+ $1:$2 @a, at b, at c:u%d -> @a:@b:@c:u%d
R$*@$* $1%$2 @a:@b:@c:u at d -> %a:%b:%c:u%d
R%$+:$+ $:$2@$1 %a:%b:%c:u%d -> %b:%c:u%d at a
R%$+:$+@$+ $2@$1@$3 %b:%c:u%d at a -> u%d at c@b at a
R$+@$+@$+ $1%$2@$3 u%d at c@b at a -> u%d%c%b at a
###############################################################
# Ruleset 11 -- Percent style source routing -> RFC style #
###############################################################
#
# convert a routed address in the Percent form to RFC822 form
# e.g. jim%hwcs.uucp%kcl-cs.uucp at ucl-cs.arpa ->
# <@ucl-cs.arpa, at kcl-cs.uucp:jim at hwcs.uucp>
#
S11
R$+@$+ $1%$2 u%d%c%b at a -> u%d%c%b%a
R$+%$+%$+ $:@$3:$1@$2 u%d%c%b%a -> @c%b%a:u at d
R$+%$+:$+ @$2:$1:$3 @c%b%a:u%d -> @a:@b:@c:u at d
R$+:$+:$+ $1,$2:$3 @a:@b:@c:u at d -> @a, at b, at c:u at d
R@$+ $@<@$1> @a, at b, at c:u at d -> <@a, at b, at c:u at d>
################################################################
# Ruleset 12 -- uucp style source routing -> Percent style #
################################################################
#
# convert an address in uucp form to Percent form
# e.g. kcl-cs.uucp!hwcs.uucp!jim -> jim%hwcs.uucp at kcl-cs.uucp
#
# also converts mixed addresses, giving '@' and '%' priority over '!'
# e.g. hwcs!jim%kcl-cs.uucp at ucl-cs.arpa -> jim%hwcs%kcl-cs.uucp at ucl-cs.arpa
#
S12
# handle mixed addresses (with '!'s, '@'s and maybe '%'s in)
R$+!$+%$+ $1!$2@$3 c!d!u%b at a -> c!d!u at b@a
R$+!$+@$+ $2@$1@$3 c!d!u at b@a -> u at d@c at b@a
# handle pure uucp addresses
R$+!$+ $:$2@$1 a!b!c!d!u -> b!c!d!u at a
R$+!$+@$+ $2@$1@$3 b!c!d!u at a -> u at d@c at b@a
R$+@$+@$+ $1%$2@$3 u at d@c at b@a -> u%d%c%b at a
################################################################
# Ruleset 13 -- Percent style to uucp style source routing #
################################################################
#
# convert a Percent style address to uucp (domain1!domain2!user) form
# e.g. jim%hwcs.uucp at kcl-cs.uucp -> kcl-cs.uucp!hwcs.uucp!jim
#
S13
R$+%$+ $1@$2 u%d%c%b at a -> u at d@c at b@a
R$+@$+ $:$2!$1 u at d@c at b@a -> d at c@b at a!u
R$+@$+!$+ $2!$1!$3 d at c@b at a!u -> a!b!c!d!u
ifdef(`JANET',`
######################################################
# Ruleset 14 -- NRS <-> RFC822 domain conversion #
######################################################
#
# swap the order of the sub-domains around.
# e.g. steve at uk.ac.ucl-cs.44d => steve at 44d.ucl-cs.ac.uk
#
# this assumes that no colons will appear in the rhs of the domain address
#
S14
R$*@$+.$+ $1@$2:$3 u at a.b.c.d -> u at a:b:c:d
R$*@$-:$+ $:$1@$3.$2 u at a:b:c:d -> u at b:c:d.a
R$*@$-:$+.$+ $1@$3.$2.$4 u at b:c:d.a -> u at d.c.b.a
')
version.m4 484578324 217 10 100644 1466 `
#
# @(#)version.m4 UK-1.1 sendmail configuration 22/4/85
#
DVUK-1.1
#
# UK-1.1 22/4/85 jim
# COMMENTS:
# Changed janet rules in ruleset 3 to cope properly with domain expansion.
# Changed output of ruleset 9 (channel ruleset) so that ruleset 0
# can parse multiple-token hostnames. Support files for janet added.
# Renamed janet mailer to "hhcp". Added 'n' mailer flag to prog mailer.
# Added ruleset 8 to detect and convert NRS style domains to 822 style.
#
# UK-1.0 26/3/85 jim
# COMMENTS:
# Some rearranging. Removed ruleset 8 (path optimisation) as it
# optimised munged addresses away completely!
# Ruleset 4 ensures an '@' in Percent style address.
# Uucp ruleset rewritten to get as close to the uucp transmission
# standard as sendmail allows.
#
# HW-5.1 1/3/85 jim
# COMMENTS:
# Fixed bug with mailing to filenames. Other cleanup for
# distribution version.
#
# HW-5.0 26/2/85 jim
# COMMENTS:
# major restructuring: rewrote ruleset 3 which now converts
# all addresses to one style. Added bitnet mailer and ether mailer
# Rewrote all the mailer specs. Various other cleanups.
#
#
# HW-4.3 10/1/85 jim
# COMMENTS:
# Cope with rfc822 style routing and renumber some rulesets
#
# HW-4.2 4/1/85 jim
# COMMENTS:
# Put in janet mailer definitions and rules
#
# HW-4.1 17/12/84 jim
# COMMENTS:
# Some modifications and cleanup for distribution
#
# HW-4.0 5/12/84 jim
# COMMENTS:
# This is a complete rewrite based on some ideas borrowed from
# mmdf.
#
SHAR_EOF
if test 11204 -ne "`wc -c Rules.a`"
then
echo shar: error transmitting Rules.a '(should have been 11204 characters)'
fi
echo shar: creating directory Support
mkdir Support
chdir Support
echo shar: extracting rmail.c '(3690 characters)'
cat << \SHAR_EOF > rmail.c
#ifndef lint
static char sccsid[] = "@(#)rmail.c 4.4 (Berkeley) 8/11/83";
#endif
/*
** RMAIL -- UUCP mail server.
**
** This program reads the >From ... remote from ... lines that
** UUCP is so fond of and turns them into something reasonable.
** It calls sendmail giving it a -f option built from these
** lines.
**
** Modified to set the sender's hostname (deduced from first
** "remote from host" line) and convert the final "user" part
** from an address with '@' and '%' (which mmdf is so fond of)
** in to a 'pure' uucp address. -Jim Crammond, (hwcs!jim) 29/11/84
*/
# include <stdio.h>
# include <sysexits.h>
typedef char bool;
#define TRUE 1
#define FALSE 0
extern FILE *popen();
extern char *index();
extern char *rindex();
char *conv_at();
bool Debug;
# define MAILER "/usr/lib/sendmail"
main(argc, argv)
char **argv;
{
FILE *out; /* output to sendmail */
char lbuf[512]; /* one line of the message */
char from[512]; /* accumulated path of sender */
char ufrom[64]; /* user on remote system */
char sys[64]; /* a system in path */
char sysname[64]; /* system received from */
char cmd[2000];
register char *cp;
register char *uf; /* ptr into ufrom */
int firstline = 1;
int i;
# ifdef DEBUG
if (argc > 1 && strcmp(argv[1], "-T") == 0)
{
Debug = TRUE;
argc--;
argv++;
}
# endif DEBUG
if (argc < 2)
{
fprintf(stderr, "Usage: rmail user ...\n");
exit(EX_USAGE);
}
(void) strcpy(from, "");
(void) strcpy(sysname, "");
(void) strcpy(ufrom, "/dev/null");
while (fgets(lbuf, sizeof lbuf, stdin) != NULL)
{
if (strncmp(lbuf, "From ", 5) != 0 && strncmp(lbuf, ">From ", 6) != 0)
break;
(void) sscanf(lbuf, "%*s %s", ufrom);
cp = lbuf;
uf = ufrom;
while ((cp = index(cp, 'r')) != NULL)
{
#ifdef DEBUG
if (Debug)
printf("cp='%s'\n", cp);
#endif
if (sscanf(cp, "remote from %s", sys) == 1)
{ (void) strcat(from, sys);
(void) strcat(from, "!");
if (firstline)
(void) strcpy(sysname, sys);
break;
}
cp++;
}
#ifdef DEBUG
if (Debug)
printf("ufrom='%s', sys='%s', from now '%s'\n", uf, sys, from);
#endif
firstline = 0;
}
(void) strcat(from, conv_at(uf));
(void) sprintf(cmd, "%s -em -f%s", MAILER, from);
if (*sysname != '\0')
{ (void) strcat(cmd, " -oMs");
(void) strcat(cmd, sysname);
}
while (*++argv != NULL)
{
(void) strcat(cmd, " '");
if (**argv == '(')
(void) strncat(cmd, *argv + 1, strlen(*argv) - 2);
else
(void) strcat(cmd, *argv);
(void) strcat(cmd, "'");
}
#ifdef DEBUG
if (Debug)
printf("cmd='%s'\n", cmd);
#endif
out = popen(cmd, "w");
fputs(lbuf, out);
while (fgets(lbuf, sizeof lbuf, stdin))
fputs(lbuf, out);
i = pclose(out);
if ((i & 0377) != 0)
{
fprintf(stderr, "pclose: status 0%o\n", i);
exit(EX_OSERR);
}
exit((i >> 8) & 0377);
}
/*
** CONV_AT -- converts an address with 'at' symbols in to uucp style
**
** This converts addresses such as a%b%c at d to d!c!b!a style
** so that when the path deduced from the "remote from" lines is
** prepended, the address might still be valid.
** If a domain contains ".uucp" or ".UUCP" this gets stripped.
** e.g. c!user%b.uucp at a.uucp -> a!b!c!user
** user%d.dec%c.arpa%b.uucp at a.uucp -> a!b!c.arpa!d.dec!user
*/
char *
conv_at(addr)
char *addr;
{
char buf[512];
char *bp = buf;
char *p;
#ifdef DEBUG
if (Debug)
printf("conv_at(%s) ", addr);
#endif
while ((p = rindex(addr,'@')) != NULL || (p = rindex(addr,'%')) != NULL)
{
*p++ = '\0';
while (*p)
{
if (strcmp(p, ".uucp") == 0 || strcmp(p, ".UUCP") == 0)
break;
*bp++ = *p++;
}
*bp++ = '!';
}
strcpy(bp, addr);
#ifdef DEBUG
if (Debug)
printf("returns %s\n", buf);
#endif
return(buf);
}
SHAR_EOF
if test 3690 -ne "`wc -c rmail.c`"
then
echo shar: error transmitting rmail.c '(should have been 3690 characters)'
fi
echo shar: extracting damail.c '(3233 characters)'
cat << \SHAR_EOF > damail.c
/*
* rscs to sendmail mail interface
* invoked by the rscs master control daemon when a file with filetype MAIL
* is received over BITNET.
*
* The syntax is
* damail <mailfile> <fromsys> <fromuser> <tosys> <touser>
*
*
* Bill Nesheim
* Cornell U Dept of Computer Science
* August, 1983
*
* Rewritten by Jim Crammond
* Weizmann Institute
* Feb 1985
*/
#include <stdio.h>
#include <sys/file.h>
#include <sys/wait.h>
#include <sysexits.h>
#include "../common/rscs.h"
#include "../common/daemon.h"
#define MAILLOG "/usr/lib/rscs/maillog"
main(ac,av)
int ac;
char **av;
{
FILE *mail, *outfile, *log;
char line[BUFSIZ], From[BUFSIZ], To[BUFSIZ];
char sender[20];
char *actime, *err;
long tm, time();
int loc, smpid, ppe[2];
union wait status;
if(ac < 2) {
logerror("DAMAIL: No Mail File??");
return(TRUE);
}
if((log = fopen(MAILLOG, "a")) == (FILE *)NULL) {
logerror("Can't open mail log file!");
return(FALSE);
}
if((mail = fopen(av[1],"r")) == (FILE *)NULL) {
sprintf(line,"MTU: Can't open %s", av[1]);
logerror(line);
return(FALSE);
}
/* apparent source */
sprintf(From,"%s@%s.BITNET", av[3], av[2]);
/* apparent destination */
sprintf(To,"%s@%s.BITNET", av[5], av[4]);
/* sender flag to sendmail */
convlower(av[2]);
sprintf(sender,"-oMs%s.bitnet", av[2]);
/* try to find real destination and source */
while (fgets(line, BUFSIZ, mail) != NULL)
{
if (strncmp(line, "From:", 3) == 0) {
register char *p, *e;
char *index();
char *addr;
p = line + 5;
while (*p == ' ')
p++;
addr = p;
if ( (p=index(addr, '<')) && (e=index(p, '>')) )
{ /*
* address of the form: comment <address>
*/
addr = ++p;
*e = '\0';
}
else if ( (e=index(addr, '(')) )
{ /*
* address of the form: address (comment)
*/
while (*--e == ' ')
;
*++e = '\0';
}
else if ( (e=index(addr, '\n')) )
*++e = '\0';
strcpy(From, addr);
break;
}
}
rewind(mail);
tm = time(0L);
actime = (char *)ctime(&tm);
actime[19] = '\000';
/* open pipe to sendmail */
pipe(ppe);
if((smpid=vfork()) == 0) {
close(0);
dup(ppe[0], 0);
execl("/usr/lib/sendmail", "sendmail",
sender, "-odi", "-oem", "-f", From, To, 0);
logerror("MTU: exec failed");
perror("reason");
_exit(1);
}
if((outfile = fdopen(ppe[1], "w")) == (FILE *)NULL) {
logerror("MTU: pipe fdopen failure!");
return(FALSE);
}
loc = 1;
while (fgets(line, BUFSIZ, mail) != NULL) {
if (loc == 1) {
loc++;
if(strncmp(line, ":READ", 5) == 0)
continue;
}
fputs(line, outfile);
}
fclose(outfile);
fclose(mail);
wait(&status);
switch(status.w_retcode) {
case EX_OK:
err="sent";
break;
case EX_NOUSER:
err="no such user";
break;
case EX_NOHOST:
err="host unknown";
break;
case EX_UNAVAILABLE:
err="service unavailable";
break;
default:
err="other";
}
fprintf(log,"%s Received mail from %s %s (tag %s %s) \n",
actime, av[2], av[3], av[4], av[5]);
fprintf(log,"\t%s (%d) %s (%d) from %s to %s\n",
status.w_retcode ? "NOT SENT" : "Sent" , smpid, err, status.w_retcode, From, To);
fclose(log);
unlink(av[1]);
return(status.w_retcode);
}
SHAR_EOF
if test 3233 -ne "`wc -c damail.c`"
then
echo shar: error transmitting damail.c '(should have been 3233 characters)'
fi
echo shar: extracting Makefile '(673 characters)'
cat << \SHAR_EOF > Makefile
#
# Makefile for assorted programs related to Sendmail.
#
# @(#)Makefile UK-1.1 sendmail configuartion 22/4/85
#
CFLAGS=-O
#CFLAGS=-O -Dvoid=int # some pdp11's need this
X25FLAGS=-I/usr/src/local/x25/usr/src/
uucp: rmail
cp rmail /bin/rmail
bitnet: damail
cp rmail /usr/lib/rscs/damail
rmail: rmail.c
cc $(CFLAGS) -o rmail
damail: damail.c
cc $(CFLAGS) -o damail
janet: mailer hhsend
cp mailer /usr/lib/x25
chown root /usr/lib/x25/mailer
chmod 755 /usr/lib/x25/mailer
cp hhsend /usr/lib/x25
chown root /usr/lib/x25/hhsend
chmod 4755 /usr/lib/x25/hhsend
mailer: mailer.c
cc $(CFLAGS) mailer.c -lx25
hhsend: hhsend.c
cc $(CFLAGS) $(X25FLAGS) hhsend.c
SHAR_EOF
if test 673 -ne "`wc -c Makefile`"
then
echo shar: error transmitting Makefile '(should have been 673 characters)'
fi
echo shar: extracting README '(1249 characters)'
cat << \SHAR_EOF > README
This directory contains some sendmail interface programs.
Interfaces
----------
rmail.c:
This is a rewrite of the standard uucp -> sendmail interface program
which just a better job of deducing the From path from the
uucp from line(s), and also sets sendmail's $s macro.
This replaces /bin/rmail supplied with BSD4.2.
damail.c:
This is a rewrite of the bitnet -> sendmail interface program
supplied with the Cornell version of the RSCS emulation package.
This reads the from person from the From: line and sets
sendmail's $s macro.
This replaces /usr/lib/rscs/damail supplied with the RSCS software.
mailer.c:
This is a janet -> sendmail interface program. This reads a
message in JNT mail format and converts it into a form suitable
for calling sendmail. This also sets sendmail's $s macro.
This replaces /usr/lib/x25/mailer supplied with the York X25 software.
hhsend.c:
This is a sendmail -> janet interface program. This reads a
message processed by sendmail and converts it into JNT mail format,
then calls mhhcp to send it.
This effectively replaces the /usr/lib/x25/hhmail supplied with the
York X25 software; the standard mail user interfaces together with
sendmail perform the other functions provided by hhmail.
SHAR_EOF
if test 1249 -ne "`wc -c README`"
then
echo shar: error transmitting README '(should have been 1249 characters)'
fi
echo shar: extracting hhsend.c '(2613 characters)'
cat << \SHAR_EOF > hhsend.c
/*
* hhsend - Sendmail -> JNT mailer interface.
*
* This program takes a hostname and a list of users to send to as
* arguments and a mail message as standard input and creates a file
* containing a Janet header followed by the mail message, then
* calls mhhcp to send it over the network.
*
* Written by Jim Crammond. jim at hwcs 4/85
*/
#include <stdio.h>
#include <signal.h>
#include <sysexits.h>
#include <sys/wait.h>
#include "local.h"
#define MAILMODE (0660) /* mode of created spool file */
#ifdef DEBUG
#undef SPOOLD
#define SPOOLD "."
#endif DEBUG
FILE *mailf = NULL;
char sfile[ sizeof(SPOOLD) + 14 ];
int delete();
char *index();
main(argc, argv)
int argc;
char *argv[];
{
char *myname;
char *host;
char **users;
int nusers;
myname = argv[0];
if (argc < 3)
{ fprintf("usage: %s host users...\n", myname);
exit(EX_USAGE);
}
host = argv[1];
users = &argv[2];
nusers = argc - 2;
/* catch signals */
signal(SIGHUP, delete);
signal(SIGINT, delete);
signal(SIGQUIT, delete);
signal(SIGTERM, delete);
/* send the mail */
sendmail(host, users, nusers);
/* NOTREACHED */
}
/*
* sendmail - creates a mail file for mhhcp and exec mhhcp.
*/
sendmail(host, users, nusers)
char *host;
char *users[];
int nusers;
{
register char *auser, *p;
char line[BUFSIZ];
union wait status;
/* create spool file */
sprintf(sfile, "%s/M%06d", SPOOLD, getpid() );
mailf = fopen(sfile, "w");
if (mailf == NULL)
{ fprintf(stderr, "cannot create mail spool file %s\n", sfile);
exit(EX_CANTCREAT);
}
chmod(sfile, MAILMODE);
/* write out JNT-header */
while (nusers > 1)
{ auser = users[ --nusers ];
/* convert any '@'s in user part to '%'s */
while ((p = index(auser, '@')) != NULL)
*p = '%';
fprintf(mailf, "%s@%s,\n", auser, host);
}
auser = users[0];
/* convert any '@'s in user part to '%'s */
while ((p = index(auser, '@')) != NULL)
*p = '%';
fprintf(mailf, "%s@%s\n\n", auser, host);
/* write out header + message from stdin (supplied by sendmail) */
while (fgets(line, sizeof(line), stdin) != NULL)
fputs(line, mailf);
fclose(mailf);
#ifdef DEBUG
fprintf(stderr,"spool file is %s\n", sfile);
exit(0);
#endif
switch (fork())
{ case -1:
exit(EX_TEMPFAIL);
case 0:
execl(MHHCPPATH, MHHCP, sfile, host, 0);
exit(EX_UNAVAILABLE);
default:
wait(&status);
if (status.w_retcode == 1)
exit(EX_OK);
else
exit(EX_NOHOST);
}
}
/*
* delete - delete mail file and exit. Called on any interrupt.
*/
delete()
{
if (mailf != NULL)
{ fclose(mailf);
unlink(sfile);
}
exit(EX_TEMPFAIL);
}
SHAR_EOF
if test 2613 -ne "`wc -c hhsend.c`"
then
echo shar: error transmitting hhsend.c '(should have been 2613 characters)'
fi
echo shar: extracting mailer.c '(2736 characters)'
cat << \SHAR_EOF > mailer.c
/*
* mailer - JNT -> Sendmail interface.
*
* This program takes a mail file in JNT format and converts the
* Janet header into an argument and then calls sendmail giving the
* message part of the mail file as standard input.
*
* Written by Jim Crammond. jim at hwcs 4/85
*/
#include <stdio.h>
#include <time.h>
#include <pwd.h>
#include <tdir.h>
#include <sysexits.h>
#include "local.h"
struct tdirent *gettdnam(), *td;
#define CMDSIZ 5000 /* command line size */
#define SENDMAIL "/usr/lib/sendmail" /* sendmail rah rah */
#define DEADLETTER "/tmp/dead.letter" /* somewhere for trashed mail */
char cmd[CMDSIZ];
char line[BUFSIZ];
char *file, *via;
FILE *fopen(), *popen();
FILE *fp, *outp, *logfd, *dlp;
long iop, time();
char *ctime();
char *rindex();
int LOGGING;
main(argc, argv)
int argc;
char *argv[];
{
register char *usersp, *c, *n;
char *f;
int ret;
#ifndef DEBUG
chdir(SPOOLD); /* somewhere to dump core */
#endif
if ((logfd = fopen(MAIL_LOG, "a")) == NULL)
LOGGING = 0;
else
LOGGING = 1;
chmod(MAIL_LOG, 0666);
time(&iop);
LOG("\n\nMail server started %s", ctime(&iop));
file = argv[1];
via = argv[2];
if ((fp = fopen(file, "r")) == NULL)
{ LOG("could not open file\n");
done();
}
/*
* find out where this came from
*/
for (f = via; *f; f++)
if (*f == '/')
{ *f = '\0';
break;
}
if ((td = gettdnam(via, 0)) != 0)
via = td->td_name;
/*
* initialise command sendmail command line
*/
sprintf(cmd, "%s -oMs%s", SENDMAIL, via);
usersp = cmd;
while (*usersp != '\0')
usersp++;
/*
* get list of addresses to send to in JNT-header form and
* convert to a list of command line arguments.
*/
while (fgets(line, BUFSIZ, fp) != NULL)
{ c = line;
while (*c == ' ' || *c == '\t')
c++;
if (*c == '\n')
break;
*usersp++ = ' ';
while (*c != '\0' && *c != '\n')
{ if (*c == ',')
{ *usersp++ = ' ';
c++;
}
else
*usersp++ = *c++;
}
}
*usersp = '\0';
/* call sendmail */
#ifdef DEBUG
fprintf(stderr, "call: %s\n", cmd);
done();
#endif DEBUG
LOG("%s\n", cmd);
outp = popen(cmd, "w");
while (fgets(line, sizeof(line), fp) != NULL)
fputs(line, outp);
ret = pclose(outp);
if (ret & 0377)
{ /* sendmail failed - drop letter into "dead.letter" */
LOG("%s failed, returning status %d\n", cmd, ret);
if ((dlp = fopen(DEADLETTER, "a")) != NULL)
{ fprintf(dlp, "%s failed, message body follows:\n", cmd);
while (fgets(line, sizeof(line), fp) != NULL)
fputs(line, dlp);
}
exit(EX_OSERR);
}
LOG("exit status %d\n", ret >> 8);
done();
}
/* VARARGS1 */
LOG(fmt, args)
char *fmt;
{
if (LOGGING)
{ fprintf(logfd, fmt, args);
fflush(logfd);
}
return;
}
done()
{
unlink(file);
exit(EX_OK);
}
SHAR_EOF
if test 2736 -ne "`wc -c mailer.c`"
then
echo shar: error transmitting mailer.c '(should have been 2736 characters)'
fi
echo shar: done with directory Support
chdir ..
# End of shell archive
exit 0
More information about the Mod.sources
mailing list