Xref: utzoo comp.mail.uucp:845 comp.unix.questions:4747
Path: utzoo!mnetor!uunet!husc6!bbn!rochester!PT.CS.CMU.EDU!sei!sei.cmu.edu!pdb
From: pdb@sei.cmu.edu (Patrick Barron)
Newsgroups: comp.mail.uucp,comp.unix.questions
Subject: Re: 'Cannot mail directly to files' from sendmail
Message-ID: <3526@aw.sei.cmu.edu>
Date: 11 Dec 87 05:39:42 GMT
References: <538@acornrc.UUCP>
Sender: netnews@sei.cmu.edu
Reply-To: pdb@sei.cmu.edu (Pat Barron)
Organization: Carnegie-Mellon University, SEI, Pgh, Pa
Lines: 32
Keywords: sendmail, 4.2bsd, help?

In article <538@acornrc.UUCP> bob@acornrc.UUCP (Bob Weissman) writes:
>I know I can do this with /usr/ucb/mail .  Fine.  I want to do
>it (in a script) with /usr/lib/sendmail , but sendmail gives the
>error message 'Cannot mail directly to files'.  The script is running as
>UUCP, driven by a "|script" entry in the aliases file.
>
>Looking at the code in recipient.c, it appears that sendmail is rather
>arbitrarily deciding it doesn't want to do what I want.  (I am not
>claiming here that I understand all this code!)
>
>Any ideas (1) why sendmail is refusing me and (2) how to get around this?

Sendmail will only mail to files if the filename appears in an alias
expansion, or in someone's ".forward" file; this is for security reasons.
Suppose your sendmail runs setuid to root, and someone trys to mail
something to any arbitrary file, oh, say, "/etc/init" for instance.  I
think you can see that it would be a disaster.  Mail to pipes (through
the "prog" mailer is similarly restricted.

To get mail to a file, you need an entry in /usr/lib/aliases for that
file.  For example, if you wanted to mail stuff to /usr/foo/bar, you'd
need an alias entry like:

  foo:    /usr/foo/bar

and you'd mail it to "foo" instead.

Individual users can cause their mail to be appended to a file (or sent
through a filter) by putting an appropriate entry in their ".forward"
file, so they wouldn't need to mess around with the aliases file.

--Pat.