[comp.mail.sendmail] RFC-compliant UUCP mail

Makey@Logicon.COM (Jeff Makey) (07/26/90)

I have decided to toe the line and make mail I send via UUCP conform
to RFC 796 ("UUCP Mail Interchange Format Standard").  I have looked
closely at the sendmail 5.61 sources and I have determined that there
is no way to set up my .cf file to output a pure !-path in the From_
line in conjunction with an RFC 822 compliant From: line.  Am I
correct?  Does 5.64 provide a workaround?  Will the IDA enhancements
do the trick?

If I am not clear, I want to output

    From host.domain!user  Wed Jul 25 16:39:22 1990 remote from mysite
    From: user@host.domain

instead of

    From host.domain!user  Wed Jul 25 16:39:22 1990 remote from mysite
    From: mysite!host.domain!user

or

    From user@host.domain  Wed Jul 25 16:39:22 1990 remote from mysite
    From: user@host.domain

Thanks.

                           :: Jeff Makey

Department of Tautological Pleonasms and Superfluous Redundancies Department
    Disclaimer: All opinions are strictly those of the author.
    Internet: Makey@Logicon.COM    UUCP: {nosc,ucsd}!logicon.com!Makey

moore@cs.utk.edu (Keith Moore) (07/26/90)

In article <730@logicon.com>, Makey@Logicon.COM (Jeff Makey) writes:
> I have decided to toe the line and make mail I send via UUCP conform
> to RFC 796 ("UUCP Mail Interchange Format Standard").  I have looked
> closely at the sendmail 5.61 sources and I have determined that there
> is no way to set up my .cf file to output a pure !-path in the From_
> line in conjunction with an RFC 822 compliant From: line.  Am I
> correct?  Does 5.64 provide a workaround?  Will the IDA enhancements
> do the trick?
> 
> If I am not clear, I want to output
> 
>     From host.domain!user  Wed Jul 25 16:39:22 1990 remote from mysite
>     From: user@host.domain
> 
> instead of
> 
>     From host.domain!user  Wed Jul 25 16:39:22 1990 remote from mysite
>     From: mysite!host.domain!user
> 
> or
> 
>     From user@host.domain  Wed Jul 25 16:39:22 1990 remote from mysite
>     From: user@host.domain
> 
> Thanks.
> 

You are correct.  For UUCP mail, the envelope addresses should be pure
bang paths and the (optional) message headers should be RFC822
compliant (ideally with real domain names) if they appear at all.

Here's how to do this with sendmail.  This isn't to be taken verbatim,
just as a guideline:

* The easy way to do this is to get IDA sendmail, which lets you have
seperate rewrite rules for envelope addresses and headers addresses.
Vanilla sendmail (including 5.64) treats these the same.

* If you can't or don't want to use IDA sendmail, you can effect this
change with a shell script.  Change the "uucp" mailer description so
that, instead of running uux, you run this shell script.  Have your
sendmail rewrite rules generate domains instead of bang paths.  The
shell script uses sed (or maybe expr) to rewrite each of the addresses
(including both sender and recipient) from domains to bang paths.
Also, pass the sender's address to the shell script, which prepends
the From line (instead of sendmail).  Finally, pass the rewritten
recipient list (via the command line) and the message with the From
line prepended (via standard input) to uux.

Sure this is ugly, but it's not terribly difficult to set up, and it's
easy to test your shell script independently of sendmail.

Keith Moore			Internet: moore@cs.utk.edu
University of Tenn. CS Dept.	BITNET: moore@utkvx
107 Ayres Hall, UT Campus	UT Decnet: utkcs::moore
Knoxville Tennessee 37996-1301	Telephone: +1 615 974 0822

karl_kleinpaste@cis.ohio-state.edu (07/26/90)

moore@cs.utk.edu (Keith Moore) writes:
   * If you can't or don't want to use IDA sendmail, you can effect this
   change with a shell script.  [contorted pain follows.]

I already wrote to Jeff separately about this, but you're working much
too hard at this.

Use smail 2.5 as a UUCP backend to sendmail.  Generate u@h.d in .cf,
hand it to smail.  Smail will turn the From_'s u@h.d around to h.d!u.

--karl

rickert@CS.NIU.EDU (Neil Rickert) (07/26/90)

   In article: 730@logicon.com, Jeff Makey  <Makey@Logicon.COM>
writes:
>
>If I am not clear, I want to output
>
>    From host.domain!user  Wed Jul 25 16:39:22 1990 remote from mysite
>    From: user@host.domain
>
>instead of
>
>    From host.domain!user  Wed Jul 25 16:39:22 1990 remote from mysite
>    From: mysite!host.domain!user
>
>or
>
>    From user@host.domain  Wed Jul 25 16:39:22 1990 remote from mysite
>    From: user@host.domain

 If you use sendmail 5.64+/IDA-1.3.4 you have two choices.

 If you use the UUCP-A mailer, you will get:

    From host.domain!user  Wed Jul 25 16:39:22 1990
    From: user@host.domain

 If you use the UUCP mailer you will get:

    From host.domain!user  Wed Jul 25 16:39:22 1990 remote from mysite
    From: host.domain!user

 The choice of mailer is specified in the DBM lookup MAILERTABLE.  There
may be some variations from these formats depending on whether 'host.domain'
is the same host as 'mysite' and on what you have in UUCPXTABLE for
'host.domain'.  The variations only affect the UUCP mailer.

 The 'remote from mysite' is omitted from the output with the UUCP-A
mailer, because otherwise the receiving 'rmail' will translate the
address into 'mysite!host.domain!user' with presumably redundant routing.

 The versions of sendmail/IDA and the IDA config package are available from
uxc.cso.uiuc.edu via anonymous ftp, with name
	/pub/sendmail.5.64+IDA-1.3.4.tar.Z

 My thanks to Paul Pomes (paul@uxc.cso.uiuc.edu) for helping me test my
major rewrite of the config package, and for making it accessible via ftp.

 There have been some changes in the package over the last two weeks
specifically related to UUCP mail formats, so anyone who picked it up
earlier will need to get the latest version.  The changes included a
code change (in parseaddr.c if I remember) needed to fully benefit.

  ---- Further comments on the IDA sendmail, and RFC1123 ----

In article <ENAG.90Jul25163050@slembe.ifi.uio.no>, 
	enag@ifi.uio.no (Erik Naggum)
 (in response to my earlier comments) writes:

>Instead of complaining, and showing us all kinds of broken systems,
>why don't you try to make things according to standard?  That means,

 That is what I have been trying to do.  That is why I put a lot of
effort into what was almost a complete rewrite of the IDA sendmail config
package.  It now probably comes closer to adhering to standards than
most systems.

 However, it interprets 'a!b%c' as 'a -> c -> b'.  This is probably not
in disagreement with reasonable interpretations of RFC1123, since it can
be claimed that 'a!b%c' is a purely UUCP address, not an Internet address,
so RFC1123 does not apply.

 It currently interprets 'a!b%c@d' as 'd -> a -> c -> b'.  According
to some interpretations this is contrary to RFC1123.  Never mind.  If you
prefer the interpretation 'd -> c -> a -> b' you need only remove the
comment from one rewrite rule in ruleset #9.  Unless the domain 'd'
of the '@d' portion is your own, it usually will not matter which
interpretation you use, for although the address is fully parsed, including
the 'local part', it is parsed in a way which allows complete restoral to
the original format in the final ruleset #4.

>for instance, that you sit down and try to grok the intentions behind
>the specs, instead of comparing the standard to your broken system
>which just happens to work because others follow the robustness
>principle:
>
>	"Be liberal in what you accept, and
>	 conservative in what you send."
>
 Where is the conservatism in interpretations of RFC1123 which wish to
output mail using the '%-hack' in a way which is inconsistent with the
interpretation of the majority of those existing mailers which use both
'!' and '%' ?  Better to make the RFC822 source routes, with all their
ugliness, work.  Better to demand that all routes have exclusively '!' and
'@' or exclusively '%' and '@'.  There is too long a history of usage of
'%' where 'a!b%c' means 'a -> c -> b' for their to be any reasonable hope
of reliably reversing this interpretation.

=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=
  Neil W. Rickert, Computer Sci Dept, Northern Illinois U., DeKalb IL 60115
  InterNet, unix: rickert@cs.niu.edu              Bitnet, VM: T90NWR1@NIUCS
=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=

mark@DRD.Com (Mark Lawrence) (07/27/90)

karl_kleinpaste@cis.ohio-state.edu wrote:
} Use smail 2.5 as a UUCP backend to sendmail.  Generate u@h.d in .cf,
} hand it to smail.  Smail will turn the From_'s u@h.d around to h.d!u.

This is an opportunity to ask a (related but tangental) question about 
something that's been bugging me.

We're an MX served uucp-only site.  I note that when mail originated from
here arrives at some recipient, transported via the good graces of our 
local friendly neighborhood internet gateway, the headers look like:

From drd!DRD.Com!user  (is this the From_ referred to above?)
From: user@DRD.Com

Who's responsible for this?  Did my sendmail re-write it (how do I tell)?  
Is it likely my internet gateway did it?  I get a lot of mail bounced back
to me especially from vm sites (griping that the From_ header doesn't
have an FQDN in it).  

We and our internet gateway are running Sun's with 4.0.3 and the stock
sendmail sun supplies.  I think my gateway is running a fairly stock
sendmail.mx provided with SunOS.

If I'm restarting the war between the bang re-writers and the absolute
domainists (which I followed *mostly*), my apologies.  I just want my mail 
to get through.

karl_kleinpaste@cis.ohio-state.edu (07/27/90)

mark@DRD.Com writes:
   We're an MX served uucp-only site.  I note that when mail originated from
   here arrives at some recipient, transported via the good graces of our 
   local friendly neighborhood internet gateway, the headers look like:

   From drd!DRD.Com!user  (is this the From_ referred to above?)
   From: user@DRD.Com

   Who's responsible for this?  Did my sendmail re-write it (how do I tell)?  
   Is it likely my internet gateway did it?  I get a lot of mail bounced back
   to me especially from vm sites (griping that the From_ header doesn't
   have an FQDN in it).  

You are probably responsible for half of it, and your gateway the
other half.  You can see how things look if you send some mail, su,
and then go look in the UUCP queue toward your MX host.  You will
probably find that the D.* file contains
	From DRD.Com!user <date> remote from drd
	From: user@DRD.Com
and rmail on the MX host will turn around the first line to
drd!DRD.Com!user.  That's almost certainly where it comes from.  This
is normal and correct.

As for bounced mail from some sites due to lack of FQDN is concerned,
that's the fault of your MX host.  As an SMTP-capable site, it is
their responsibility to send all addresses leaving their site via SMTP
in local-part@FQDN format.  This means that their [IPC] mailer (Mtcp
or Msmtp or whatever they're calling it) probably needs rules
something like this, as part of "S=xx,R=xx" in the mailer definition:

R$*@$*		$@$1@$2		already @ified, so leave alone
R$+		$@$1@$D		Add "@my-d" for sanity

This leaves things alone which are already in local-part@FQDN format,
and adds the MX host's FQDN to things not already in that format.

Small plug: If the MX host were Domain Absolutist, then a trio of
rules I've described before would have already taken care of this
problem.

--karl

rickert@CS.NIU.EDU (Neil Rickert) (07/27/90)

mark@DRD.Com writes:
>   We're an MX served uucp-only site.  I note that when mail originated from
>   here arrives at some recipient, transported via the good graces of our 
>   local friendly neighborhood internet gateway, the headers look like:
>
>   From drd!DRD.Com!user  (is this the From_ referred to above?)
>   From: user@DRD.Com
>

karl_kleinpaste@cis.ohio-state.edu replied with some good explanations, and
suggestions as to how the MX forwarder can be modified to add routing.

  If that is done, the mail will probably go out as

  From drd!DRD.Com!user@your.internet.gateway

 which is perfectly acceptable, but probably not what you wanted.

 If you are using a standard Sun sendmail.main.cf, try using the 'smartuucp'
 mailer to forward mail to the internet gateway.  Then experiment with changing:

  Msmartuucp, P=/usr/bin/uux, F=CmsDFMhuU, S=22, R=22, 

 to:

  Msmartuucp, P=/usr/bin/uux, F=CmsDFMhu, S=22, R=22, 

   In otherwords, try removing the 'U' from the end of the F= flags.  This
will remove the 'remote from drd' in the UUCP mail you send out with the
smartuucp mailer.  If the internet gateway machine can handle it, (it
probably can) your mail should then go out as

  From user@DRD.com

 which is probably what you wanted, and avoids all of the superfluous routing.

=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=
  Neil W. Rickert, Computer Sci Dept, Northern Illinois U., DeKalb IL 60115
  InterNet, unix: rickert@cs.niu.edu              Bitnet, VM: T90NWR1@NIUCS
=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=

rickert@CS.NIU.EDU (Neil Rickert) (07/30/90)

mark@DRD.Com wrote:
>   We're an MX served uucp-only site.  I note that when mail originated from
>   here arrives at some recipient, transported via the good graces of our 
>   local friendly neighborhood internet gateway, the headers look like:
>
>   From drd!DRD.Com!user  (is this the From_ referred to above?)
>   From: user@DRD.Com

 To this I replied:
>
> If you are using a standard Sun sendmail.main.cf, try using the 'smartuucp'
> mailer to forward mail to the internet gateway.  Then experiment with changing:
>  Msmartuucp, P=/usr/bin/uux, F=CmsDFMhuU, S=22, R=22, 
> to:
>  Msmartuucp, P=/usr/bin/uux, F=CmsDFMhu, S=22, R=22, 
>   In otherwords, try removing the 'U' from the end of the F= flags.
> your mail should then go out as
>  From user@DRD.com

 Unfortunately this may not work reliably.

 I suggested this because I had just implemented this scheme recently on
a UUCP node for which I provide Internet gateway services.  It worked well.
But I forgot about one piece of the puzzle which I happened to have put in
place some time ago.

 Here, specifically, is what is happening:

 If you use the 'smartuucp' mailer as originally defined, sendmail.cf formats
the addresses in domain format.  Thus the envelope address is formatted as
 'user@DRD.com'.  However, because of the 'U' mailer flag, code within the
sendmail binary converts this to:
From DRD.com!user  date and time remote from drd

 At the Internet gateway host (hereinafter known as i.g.h), the 'rmail'
converts the 'From_' line into drd!DRD.com!user, and invokes sendmail
as:
    /usr/lib/sendmail -f drd!DRD.com!user <recipient address>

 If, not, you remove the 'U' flag from the mailer, the address is formatted
as 
From user@DRD.com date and time.
Once again the receiving 'rmail' interprets this from line, and invokes
sendmail as:
    /usr/lib/sendmail -f user@DRD.com <recipient address>

 At first glance this looks to be exactly what is required.  Unfortunately,
however, most versions of 'sendmail' normally ignore the '-f' option on the
command line, unless invoked by a 'trusted user'.  This is to prevent the
forging of sender addresses.  There is one exception to this sendmail
restriction.  If the sender address contains a '!', sendmail accepts the '-f'
option, even if from a non-trusted user - UUCP mail would not work otherwise.

 The problem now, is that when the from line contains an '@' instead of a '!'
the address may go out as:  From drd@i.g.h  instead of From user@DRD.com.
It all depends on how the UUCP connection is made.
  If the UUCP connection is started by i.g.h from 'crontab' everything should
be fine, because 'uucp' is usually a Trusted user.  If the uucp connection
in initiated by 'drd', everything will be file PROVIDED that the login name
'drd' uses is a trusted user in 'sendmail.cf'.  But if the uucp connections
is initiated by, for instance, a user on i.g.h issuing the 'uucp' command,
this will not work.

  Any of the following should solve the problem:

	1.	Make sure that the outgoing UUCP mail says:
		From_DRD.com!user  date&time.
		The idea here is that there should be a bang in the
		address.  This could be managed by restoring the U flag
		and replacing uux by a shell script uux.sh which strips
		off the 'remote from drd' (with sed) and feeds its output
		to the real uux.


	2.	Create a new rewrite ruleset in sendmail.cf which converts
		all addresses to domain!user format.  Use this on the S= line
		of the mailer definition.  It probably need only consist of
		something simple like:
		R$+		$:$>22$1
		R$+		$@$>5$1

		The disadvantate is that the header line will also go out
		as:
		From: DRD.com!user
		This is probably not serious, for i.g.h will probably convert
		that into user@DRD.com.

	3.	Make sure that all UUCP calls are initiated from 'drd'
		and that the login name used is on the trusted user list
		at i.g.h.

	4.	Modify 'rmail' on i.g.h. This is the method I am currently
		using.  My 'rmail', which came with the sendmail/IDA package,
		is suid root, and sets its real uid to 0 before invoking
		sendmail.  This means that it is always trusted.

		I also set 'rmail' to be in group 'daemon' and executable only
		by 'user' or 'group'.  Uucp usually runs sgid daemon, so can
		execute rmail, but typical users cannot.  Of course a user
		who wants to forge mail can still do it by using '!' in the
		from address.

=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=
  Neil W. Rickert, Computer Sci Dept, Northern Illinois U., DeKalb IL 60115
  InterNet, unix: rickert@cs.niu.edu              Bitnet, VM: T90NWR1@NIUCS
=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=