[comp.sources.unix] v16i081: Mail delivery program, Part01/03

rsalz@uunet.uu.net (Rich Salz) (11/16/88)

Submitted-by: Chip Salzenberg <chip@ateng.uu.net>
Posting-number: Volume 16, Issue 81
Archive-name: deliver/part01

A long time ago, I wanted to set up a mail alias that could pipe mail
through a process.  Well, one thing led to another, and the result is
this program:  deliver.

Deliver does mail delivery.  It is, however, unique in that its
configuration files are shell scripts.  Thus a user is not limited to simply
piping his mail; he can do anything that he can express in a shell script.
One beta tester, for example, bounces daytime mail to his work machine
and night/weekend mail to his home machine.

This program has been tested under Xenix System V and 4.3 BSD.  It should
work under System V with minimal work.
--
Chip Salzenberg                   <chip@ateng.uu.net> or <uunet!ateng!chip>
A T Engineering                      stuck in a closet with Vanna White

#! /bin/sh
# This is a shell archive.  Remove anything before this line, then unpack
# it by saving it into a file and typing "sh file".  To overwrite existing
# files, type "sh file -c".  You can also feed this as standard input via
# unshar, or by typing "sh <file", e.g..  If this archive is complete, you
# will see the following message at the end:
#		"End of shell archive."
# Contents:  README deliver.8 Makefile config.h context.h deliver.h
#   dest.h patchlevel.h misc.h
PATH=/bin:/usr/bin:/usr/ucb ; export PATH
if test -f 'README' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'README'\"
else
echo shar: Extracting \"'README'\" \(2335 characters\)
sed "s/^X//" >'README' <<'END_OF_FILE'
X$Header: README,v 1.5 88/09/14 20:09:37 network Exp $
X
X
X                             WHAT IS DELIVER?
X
X
XDeliver is a program which delivers electronic mail once it has arrived
Xat a given machine.
X
X
X
X                              WHO CAN USE IT?
X
X
XDeliver is intended for use in three environments:
X
X
X    1.  Any Xenix system.
X
X        Deliver was invented to be a direct replacement for the Xenix
X        program /usr/lib/mail/mail.local.  In fact, on ateng, mail.local is
X	just another link to /usr/bin/deliver.
X
X
X    2.  Any Unix system with smail 2.x.
X
X        You can use deliver for local mail by changing the local mailer
X        definition in config.h:
X	    #define LMAIL(frm)      "/usr/bin/deliver -r '%s'",frm
X
X
X    3.  Any Unix system with either sendmail or smail 3.x.
X
X	Any user can let deliver handle all his mail by putting the
X	following line in his .forward file:
X	    "|/usr/bin/deliver username"
X	Be sure to specify the correct username, or someone else will
X	get your mail!
X
X
X
X                                PORTABILITY
X
X
XDeliver has been compiled and tested under SCO Xenix System V/286 and 4.3
XBSD.  The configuration provides for System V, but I have not been able to
Xtest it. (Patches for all environments are welcome; see below.)
X
X
X
X			   WARNINGS: BE CAREFUL!
X
X
X    1.  Deliver is intended to be run setuid root; otherwise it would not
X        be possible to execute a user delivery file in the context of its
X        owner.  Any setuid root program is a potential security hole!  Be
X        careful of the modes on the deliver binary and the directory where
X        it lives.
X
X    2.  Deliver's flexibility makes it easy to lose lots of mail through
X	carelessness in configuration.  Delivery files should be written
X	with extreme care.
X
X
X
X                          COMPILING AND INSTALLING
X
X
XEdit the Makefile and config.h to taste.  Type "make".  To install, type
X"make install".  See the Makefile for further hints.
X
X
X
X			    HELP SAVE THE WORLD!
X
X
XIf you run into a bug, you are probably not alone.  Save your fellow human
Xbeings from toil and trouble!  Send mail to <bugs-deliver@ateng.uucp>.  Bug
Xreports accepted; patches greatly appreciated.  I will coordinate patches.
X
XThank you, and good night.
X
X	Chip Salzenberg
X	A T Engineering
X
X	<chip@ateng.uucp> or
X	<chip@ateng.uu.net> or
X	<uunet!ateng!chip>
END_OF_FILE
if test 2335 -ne `wc -c <'README'`; then
    echo shar: \"'README'\" unpacked with wrong size!
fi
# end of 'README'
fi
if test -f 'deliver.8' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'deliver.8'\"
else
echo shar: Extracting \"'deliver.8'\" \(8688 characters\)
sed "s/^X//" >'deliver.8' <<'END_OF_FILE'
X.\" $Header: deliver.8,v 1.3 88/09/14 19:41:44 network Exp $
X.\"
X.\" Man page for deliver.
X.\"
X.\" $Log:	deliver.8,v $
X.\" Revision 1.3  88/09/14  19:41:44  network
X.\" Portability to System V and BSD.
X.\" General fixup.
X.\" 
X.\" Revision 1.2  88/08/25  14:58:31  network
X.\" Document -u and -s.  Also general cleanup.
X.\" Change default system delivery file.
X.\" 
X.\" Revision 1.1  88/06/06  09:33:50  chip
X.\" Initial revision
X.\" 
X.\"
X.TH DELIVER 8
X.SH NAME
Xdeliver \- deliver local mail
X.SH SYNOPSIS
X.B deliver
X[ options ] address ...
X.SH DESCRIPTION
XThe
X.I deliver
Xprogram collects a mail message from the standard input and delivers it.
XIt is intended to take over the delivery of all local mail, a job which
Xis usually handled by
X.I /bin/mail
X(that's
X.I /usr/lib/mail/mail.local
Xon Xenix systems).
X.PP
XA mail system which uses
X.I deliver
Xbecomes very flexible in its handling of local mail delivery.  All files
Xused to control
X.I deliver
Xare shell scripts.  Thus anything you can express in a shell script can
Xbe used to control mail delivery.
X.PP
X.I deliver
Xwas designed for use in two environments.  If your Unix system uses
X.I smail(8)
Xto handle incoming mail, then you can change the LMAIL macro to call
X.I deliver.
XOr, if you have a Xenix system,
X.I deliver
Xcan be used as a direct replacement for
X.IR /usr/lib/mail/mail.local.
X(If you are using
X.I smail
Xunder Xenix, either of these approaches will work.)
X.I deliver
Xcan also be used with
X.I sendmail
Xor
X.I smail
Xversion 3, through the use of
X.I .forward
Xfiles.
X.PP
XBy default,
X.I deliver
Xdeposits mail in the system mailbox for the named user(s).  However,
X.I deliver
Xis useful specifically because of its ability to vary its behavior
Xdepending on the recipient(s) and content of mail messages.
X.PP
XWhen
X.I deliver
Xstarts execution, it interprets its arguments in one of three ways.  If the
X.B \-b
X(mailbox) option was specified, then all arguments are interpreted as
Xmailbox pathnames.  Otherwise, if a system delivery file exists,
X.I deliver
Xexecutes it with all of deliver's arguments, interpreting the output as
Xdescribed below; this procedure gives the postmaster control over delivery
Xto non-existent user names.  If
X.I deliver
Xcannot find a system delivery file, it interprets all its arguments as
Xuser names.
X.PP
XAfter executing the system delivery file (if any),
X.I deliver
Xlooks in its list of destinations for valid user names without explicitly
Xnamed mailboxes.  If any of those users have user delivery files in their
Xhome directories,
X.I deliver
Xexecutes each delivery file with the name of the user for its only argument.
X.bp
X.SH OPTIONS
X.TP
X.B \-b
XInterpret all arguments as mailboxes instead of addresses.
X.TP
X.B \-A
XPrint the resolved addresses; don't deliver to any mailboxes.  Note that
X.I deliver
Xstill collects a message from the standard input, since delivery files may
Xdo different things depending on message content.  For simple testing,
Xredirect standard input from /dev/null.
X.TP
X.B \-d
XBe verbose; don't deliver to any mailboxes or catch any signals.
X.TP
X.B \-v
XBe verbose, but still deliver.
X.TP
X.B \-t
XDo not remove temporary files before exiting.
X.TP
X.BI \-r " sender"
XPut
X.I sender
Xon the generated From_ line.  Default is to use the address on the From_
Xline in the input, or else the name corresponding to the real uid, or else
X"unknown".
X.TP
X.BI \-h " hostname"
XSet the host name.  The default is configuration dependent.
X.TP
X.BI \-s " system delivery file"
XSpecify an alternate system delivery file.  The default is
X.I /usr/local/lib/deliver.sys.
XFor security reasons, this option disables setuid privileges.
X.TP
X.BI \-u " user delivery file"
XSpecify an alternate user delivery file.  The default is
X.I .deliver
X(in each user's home directory).
XFor security reasons, this option disables setuid privileges.
X.PP
XAll command line options are put into environment variables, which
X.I deliver
Xexamines on startup; thus all flags are propagated when
X.I deliver
Xis invoked recursively.
X.bp
X.SH DELIVERY FILES
XDelivery files are shell scripts.  They are executed by
X.I deliver
Xto control delivery to users.  Note that delivery files do
X.I not
Xcontrol delivery to explicitly named mailboxes.
X.PP
XOn each system the postmaster may create a
X.I system delivery file
Xto controls delivery of all messages.
XThe system delivery file, if it exists, is executed
Xwith the name(s) specified on the
X.I deliver
Xcommand line as its arguments.
X.PP
XIn addition, each user may create a
X.I user delivery file
Xin his home directory.  User delivery files are always executed with exactly
Xone argument: the name of the user in whose home directory the file is
Xfound.
X.PP
XWhen
X.I deliver
Xexecutes a delivery file, it sets several environment variables, listed
Xbelow.
XNote that these environment variables are both set and used by
X.I deliver;
Xtherefore, all command line options automatically propagate when
X.I deliver
Xis run recursively (within a delivery file).  Recursive execution of
X.I deliver
Xis quite useful, especially with the
X.B \-b
X(mailbox) flag.
X.TP
X.B DELFLAGS
XThe command line flags, if any, specified on the
X.I deliver
Xcommand line.
X.TP
X.B SYSDELFILE
XThe system delivery filename.
X.TP
X.B USERDELFILE
XThe user delivery filename.
X.TP
X.B HOSTNAME
XThe local host name, either the actual hostname or a name specified with the
X.B \-h
Xoption to
X.I deliver.
X.TP
X.B SENDER
XThe sender, if any, specified with the
X.B \-r
Xoption to
X.I deliver.
X.TP
X.B HEADER
XThe name of the temporary file containing the message header.
X.TP
X.B BODY
XThe name of the temporary file containing the message body.
X.PP
X.I deliver
Xmonitors the standard output of delivery files for lines of two forms:
Xeither "user" or "user:mailbox".  Those users whose names appear in the
Xoutput of a delivery file will receive the message.  If a mailbox name
Xappears after the user name, then that mailbox receives the message.  If a
Xmailbox name is not specified, the user's default mailbox is used. (The
Xdefault mailbox for a user is configuration-dependent.) If a mailbox is not
Xan absolute pathname, it is interpreted relative to the home directory of
Xthe named user.
X.PP
X.B NOTE 1:
XWhen
X.I deliver
Xexecutes a delivery file, it expects that delivery file to explicitly name
Xall users (and, optionally, mailboxes) which should receive the message.
XIf a delivery file does not name any users in its output, then the message
Xwill not be delivered to anyone whose mail delivery is controlled by that
Xdelivery file.
X.PP
XTherefore, a user delivery file which contains only "exit" will keep the
Xgiven user from receiving any mail.  A system delivery file which contains
Xonly "exit" will cause
X.B all
Xmail to disappear.  So be careful!
X.PP
X.B NOTE 2:
XIf
X.I deliver
Xis setuid root -- which it should be for normal operation -- then the system
Xdelivery file is executed as root.  Be
X.I very careful
Xabout its permissions and its contents!  If you are not careful, it can
Xeasily become a security hole.
X.PP
X.B NOTE 3:
XAll user delivery files are executed in the context of the user in whose
Xhome directory they reside.  A user's "context" includes the uid, gid, and
Xhome directory as specified in /etc/passwd.
X.PP
X.B NOTE 4:
XFor security reasons, if a user's home directory is writable to the world,
X.I deliver
Xwill ignore any deliver file that might be found there.
X.PP
X.B NOTE 5:
XFor security reasons,
X.I deliver
Xrejects lines of the form "user:mailbox" when generated by a user delivery
Xfile unless they are output by the given user's delivery file.  In other
Xwords, no user can request writing a mailbox as another user.
X.SH LOCKING
XSeveral preprocessor labels may be defined during compilation to control
Xthe method(s) used by
X.I deliver
Xto lock mailboxes.  These labels are:
X.RS
X.PP
X.B ML_DOTLOCK
XLock on exclusive creation of the mailbox name with ".lock"
Xappended.  (Version 7 and early BSD mailers use this method.)
X.PP
X.B ML_DOTMLK
XLock on exclusive creation of
X.I /tmp/basename.mlk,
Xwhere
X.I basename
Xis the last component of the mailbox pathname.  (Xenix mailers use this
Xmethod.)
X.PP
X.B ML_LOCKF
XExclusively lock mailbox with lockf().
X.PP
X.B ML_FCNTL
XExclusively lock mailbox with fcntl().
X.PP
X.B ML_LOCKING
XExclusively lock mailbox with locking().
X.PP
X.RE
XOne or both of ML_DOTLOCK and ML_DOTMLK may be specified.  At most one of
XML_LOCKF, ML_FCNTL or ML_LOCKING may be specified.
X.SH FILES
X/usr/local/lib/deliver.sys      system delivery file
X.br
X~user/.deliver                  user delivery file(s)
X.br
X/etc/systemid                   system name (Xenix only)
X.SH SUPPORT
XEnhancements, enhancement requests, trouble reports, etc.,
Xshould be sent to
X.sp
X.ce
Xbugs-deliver@ateng.UUCP.
X.sp
X.SH "SEE ALSO"
X.IR uux (1),
X.IR smail (8),
X.IR mail (1)
END_OF_FILE
if test 8688 -ne `wc -c <'deliver.8'`; then
    echo shar: \"'deliver.8'\" unpacked with wrong size!
fi
# end of 'deliver.8'
fi
if test -f 'Makefile' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'Makefile'\"
else
echo shar: Extracting \"'Makefile'\" \(2960 characters\)
sed "s/^X//" >'Makefile' <<'END_OF_FILE'
X# $Header: Makefile,v 1.7 88/09/14 19:59:53 network Exp $
X#
X# Makefile for deliver
X#
X#  +----------------+
X#  | Things to make |
X#  +----------------+
X#
X#       deliver         Compile and link the deliver program.
X#       install         Install deliver.  (You must be root to do this.)
X#       lint            Run lint on all sources, creating lint.out.
X#       shar            Create distribution sharchives.
X#       clean           Clean up.
X#       clobber         Remove everything that can be regenerated.
X#
X#  +---------------+
X#  | Configuration |
X#  +---------------+
X#
X# SHELL
X#       I don't have to tell you...
X#
X# COPY
X#       Your local copy program.  SCO Xenix users may want to change this
X#       to "copy -m" which preserves file modification time.
X#
X# SHAR
X#       Your local sharchive generator.
X#
X# CFLAGS
X#       Compile-time flags to cc.
X#       For BSD systems, include "-DBSD".
X#       For USG (System III and System V) systems, include "-DUSG".
X#
X# LDFLAGS
X#       Link-time flags to cc.  The -i flag creates pure (sharable) code.
X#
X# LIBS
X#       Depending on your environment, you may or may not need to link
X#       with "-lx".  SCO Xenix System V needs it; Altos Xenix doesn't.
X#
X# BIN
X#       Target directory for installation; /usr/bin is recommended.
X#       You may use /usr/local/bin (or whatever), but you must be sure
X#       that the directory you choose is in your PATH during mail
X#       transmission and delivery.
X#
X# DELSHAR
X#       Basename of sharchives created by "make shar".
X#
X
XSHELL = /bin/sh
XCOPY =  cp
XSHAR =  shar
XCFLAGS = -O
XLDFLAGS = -i
XLIBS = -lx
XBIN =   /usr/bin
XDELSHAR =  deliver.sh
X
X#
X# The files that make up the deliver distribution.
X#
X
XDOCS =  README deliver.8
XMF   =  Makefile
X
XHDRS =  config.h context.h deliver.h dest.h patchlevel.h misc.h
X
XSRC1 =  context.c copymsg.c debug.c dest.c dfile.c lock.c
XSRC2 =  main.c mbox.c procs.c subs.c sysdep.c uucp.c
XSRCS =  $(SRC1) $(SRC2)
X
XOBJS =  context.o copymsg.o debug.o dest.o dfile.o lock.o \
X	main.o mbox.o procs.o subs.o sysdep.o uucp.o
X
Xall: deliver
Xdeliver: $(OBJS)
X	$(CC) $(LDFLAGS) -o $@ $(OBJS) $(LIBS)
X$(OBJS): $(HDRS)
X
Xclean::
X	rm -f $(OBJS)
X
X#
X# This is a klugy way to determine if you are root or not.
X# I'm open to suggestions!  (Remember that 'su' counts.)
X#
X
Xinstall: deliver
X	@if [ ! -w /etc ]; \
X	then \
X		echo ""; \
X		echo "Sorry!  You must be root to install deliver."; \
X		exit 1; \
X	fi
X	$(COPY) deliver $(BIN)/deliver
X	chgrp root $(BIN)/deliver
X	chown root $(BIN)/deliver
X	chmod 4711 $(BIN)/deliver
X
Xclobber::
X	rm -f deliver
X
X#
X# Look for fuzz.
X#
X
Xlint: lint.out
Xlint.out: $(HDRS) $(SRCS)
X	lint $(SRCS) -lc $(LIBS) >lint.out
X
Xclean::
X	rm -f lint.out
X
X#
X# Make distribution sharchives.
X#
X
Xshar:   $(DELSHAR).01 $(DELSHAR).02 $(DELSHAR).03
X$(DELSHAR).01: $(DOCS) $(MF) $(HDRS)
X	$(SHAR) >$@ $(DOCS) $(MF) $(HDRS)
X$(DELSHAR).02: $(SRC1)
X	$(SHAR) >$@ $(SRC1)
X$(DELSHAR).03: $(SRC2)
X	$(SHAR) >$@ $(SRC2)
X
Xclobber::
X	rm -f $(DELSHAR).??
END_OF_FILE
if test 2960 -ne `wc -c <'Makefile'`; then
    echo shar: \"'Makefile'\" unpacked with wrong size!
fi
# end of 'Makefile'
fi
if test -f 'config.h' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'config.h'\"
else
echo shar: Extracting \"'config.h'\" \(4412 characters\)
sed "s/^X//" >'config.h' <<'END_OF_FILE'
X/* $Header: config.h,v 1.3 88/09/14 19:41:35 network Exp $
X *
X * Deliver configuration.
X *
X * $Log:	config.h,v $
X * Revision 1.3  88/09/14  19:41:35  network
X * Portability to System V and BSD.
X * General fixup.
X * 
X * Revision 1.2  88/08/25  15:21:15  network
X * Change default system delivery file to "/usr/local/lib/deliver.sys".
X * Add ENV_SYSDEL and ENV_USERDEL for system and user delivery filenames.
X * 
X * Revision 1.1  88/06/06  09:37:27  chip
X * Initial revision
X * 
X */
X
X/*----------------------------------------------------------------------
X * Various kinds of mailbox locking.
X * You may define one or both of ML_DOTLOCK and ML_DOTMLK.
X * You may define no more than one of ML_FCNTL, ML_LOCKF and ML_LOCKING.
X *
X * File creation locking:
X *     ML_DOTLOCK   create <mailbox>.lock       (most systems except BSD4.3)
X *     ML_DOTMLK    create /tmp/<basename>.mlk  (Xenix)
X *
X * Kernel record locking:
X *     ML_FCNTL     lock with fcntl(F_SETLKW)   (SVID systems only)
X *     ML_LOCKF     lock with lockf(F_LOCK)     (SVID systems only)
X *     ML_LOCKING   lock with locking(LK_LOCK)  (Xenix systems only)
X */
X
X#ifdef M_XENIX
X#define ML_DOTMLK
X#define ML_LOCKING
X#else
X#define ML_DOTLOCK
X#endif
X
X/*----------------------------------------------------------------------
X * Maximum filename length.
X * Note that this is for _filenames_, not _pathnames_.
X * For AT&T file systems, the usual value is 14.
X * For Berzerkley file systems, use something big like 255.
X */
X
X#ifdef BSD
X#define MAX_NAMESIZE    255
X#else
X#define MAX_NAMESIZE    14
X#endif
X
X/*----------------------------------------------------------------------
X * How to get the host name.
X *
X * HOSTFILE             file containing name    (Xenix)
X * UNAME                uname()                 (System V)
X * GETHOSTNAME          gethostname()           (BSD)
X */
X
X#ifdef M_XENIX
X#define HOSTFILE   "/etc/systemid"
X#else
X#ifdef USG
X#define UNAME
X#else
X#ifdef BSD
X#define GETHOSTNAME
X#endif
X#endif
X#endif
X
X/*----------------------------------------------------------------------
X * Are vprintf() and friends available?
X * Is putenv() available?
X */
X
X#ifndef BSD
X#define HAS_VPRINTF
X#define HAS_PUTENV
X#endif
X
X/*----------------------------------------------------------------------
X * Name of shell used to execute delivery files.
X */
X
X#define SHELL   "/bin/sh"
X
X/*----------------------------------------------------------------------
X * Standard mailbox location.
X *
X * Define either MAILBOX_NAME or MAILBOX_DIR.
X * If MAILBOX_NAME is defined, then the default mailbox is a file with
X * that name in the user's home directory.
X * If MAILBOX_DIR is defined, then the default mailbox is a file in that
X * directory with the same name as the user.
X *
X * Define MAILBOX_GROUP if all mailboxes must be owned by a specific group.
X * (System V requires this feature.)  If MAILBOX_GROUP is not defined,
X * mailboxes will have their groups set to the recipients' default group.
X *
X * Define MAILBOX_MODE to the file access modes for new mailboxes.
X * (System V requires group write permissions, i.e. 0020.)
X */
X
X#ifdef USG
X/* #define MAILBOX_NAME   "mbox" */
X#define MAILBOX_DIR     "/usr/mail"
X#define MAILBOX_MODE    0660
X#define MAILBOX_GROUP   "mail"
X#else
X/* #define MAILBOX_NAME   "mbox" */
X#define MAILBOX_DIR     "/usr/spool/mail"
X#define MAILBOX_MODE    0600
X#endif
X
X/*----------------------------------------------------------------------
X * Names of delivery files.
X *
X * SYS_DELIVER          system-wide delivery file
X * USER_DELIVER         user delivery file (in user's home directory)
X */
X
X#define SYS_DELIVER     "/usr/local/lib/deliver.sys"
X#define USER_DELIVER    ".deliver"
X
X/*----------------------------------------------------------------------
X * Environment variables passed to child processes.
X * Variables marked with [#] are created only if they are specified
X * as command line options.
X */
X
X#define ENV_DFLAGS      "DELFLAGS"      /* Flags: [-[Avdt]]             */
X#define ENV_SYSDEL      "SYSDELFILE"    /* System delivery file [#]     */
X#define ENV_USERDEL     "USERDELFILE"   /* User delivery file [#]       */
X
X#define ENV_HOSTNAME    "HOSTNAME"      /* Name of this host            */
X#define ENV_SENDER      "SENDER"        /* Message sender [#]           */
X#define ENV_HEADER      "HEADER"        /* Message header file          */
X#define ENV_BODY        "BODY"          /* Message body file            */
END_OF_FILE
if test 4412 -ne `wc -c <'config.h'`; then
    echo shar: \"'config.h'\" unpacked with wrong size!
fi
# end of 'config.h'
fi
if test -f 'context.h' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'context.h'\"
else
echo shar: Extracting \"'context.h'\" \(423 characters\)
sed "s/^X//" >'context.h' <<'END_OF_FILE'
X/* $Header: context.h,v 1.1 88/06/06 09:37:40 chip Exp $
X *
X * User context, as found in /etc/passwd.
X *
X * $Log:	context.h,v $
X * Revision 1.1  88/06/06  09:37:40  chip
X * Initial revision
X * 
X */
X
X/*----------------------------------------------------------------------
X * The context structure.
X */
X
X#define CONTEXT struct context
XCONTEXT {
X	CONTEXT *next;
X	int     uid;
X	int     gid;
X	char    *name;
X	char    *home;
X};
END_OF_FILE
if test 423 -ne `wc -c <'context.h'`; then
    echo shar: \"'context.h'\" unpacked with wrong size!
fi
# end of 'context.h'
fi
if test -f 'deliver.h' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'deliver.h'\"
else
echo shar: Extracting \"'deliver.h'\" \(2690 characters\)
sed "s/^X//" >'deliver.h' <<'END_OF_FILE'
X/* $Header: deliver.h,v 1.3 88/09/14 19:41:50 network Exp $
X *
X * General pull-it-together include file.
X *
X * $Log:	deliver.h,v $
X * Revision 1.3  88/09/14  19:41:50  network
X * Portability to System V and BSD.
X * General fixup.
X * 
X * Revision 1.2  88/08/30  16:13:03  network
X * Add copystr().
X * 
X * Revision 1.1  88/06/06  09:36:49  chip
X * Initial revision
X * 
X */
X
X#include <stdio.h>
X#include <fcntl.h>
X#include <ctype.h>
X
X#include "config.h"
X#include "misc.h"
X#include "context.h"
X#include "dest.h"
X
X/*----------------------------------------------------------------------
X * Global data
X */
X
Xextern  int     verbose;        /* Print debugging messages?            */
Xextern  int     dryrun;         /* Are we making a dry run?             */
Xextern  int     printaddrs;     /* Address resolution only?             */
Xextern  int     leavetemps;     /* Leave temp files for later perusal   */
Xextern  int     boxdelivery;    /* Args are mailboxes, not addresses    */
Xextern  char    *sender;        /* Who is sending this message?         */
X
Xextern  char    *progname;      /* Name this program was invoked under  */
Xextern  char    *hostname;      /* Name of this host                    */
X
Xextern  char    *sys_deliver;   /* Systemwide delivery file             */
Xextern  char    *user_deliver;  /* User delivery file                   */
Xextern  char    *shell;         /* Shell used to run delivery files     */
X
Xextern  int     eff_uid;        /* Returned by geteuid()                */
Xextern  int     eff_gid;        /* Returned by getegid()                */
Xextern  int     real_uid;       /* Returned by getuid()                 */
Xextern  int     real_gid;       /* Returned by getgid()                 */
X
Xextern  CONTEXT *eff_ct;        /* Context of effective uid             */
Xextern  CONTEXT *real_ct;       /* Context of real uid                  */
X
X/* Temp file indices: */
X#define T_HEADER 0      /* Temp file for message header         */
X#define T_BODY   1      /* Temp file for message body           */
X#define T_MAX    2      /* Number of temp files                 */
X
Xextern  char    *ttype[T_MAX];  /* Temp file types (for messages)       */
Xextern  char    *tfile[T_MAX];  /* Temp file names                      */
Xextern  int     tfd[T_MAX];     /* Temp file fd's                       */
X
X/*----------------------------------------------------------------------
X * Global functions
X */
X
Xchar    *basename();
Xchar    *gethost();
Xchar    *copystr();
Xchar    *zalloc();
Xchar    *srealloc();
X
XCONTEXT *name_context();
XCONTEXT *uid_context();
X
XFILE    *ct_popenv();
Xint     ct_pclose();
X
XDEST    *dest();
XDEST    *first_dest();
XDEST    *next_dest();
END_OF_FILE
if test 2690 -ne `wc -c <'deliver.h'`; then
    echo shar: \"'deliver.h'\" unpacked with wrong size!
fi
# end of 'deliver.h'
fi
if test -f 'dest.h' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'dest.h'\"
else
echo shar: Extracting \"'dest.h'\" \(1636 characters\)
sed "s/^X//" >'dest.h' <<'END_OF_FILE'
X/* $Header: dest.h,v 1.1 88/06/06 09:37:48 chip Exp $
X *
X * Description of a mail destination and its state.
X *
X * $Log:	dest.h,v $
X * Revision 1.1  88/06/06  09:37:48  chip
X * Initial revision
X * 
X */
X
X/*----------------------------------------------------------------------
X * Destination class.
X */
X
Xtypedef enum {
X	CL_USER,                /* User name, no mailbox                */
X	CL_MBOX,                /* User name, with mailbox name         */
X	CL_UUCP                 /* UUCP address (bang path)             */
X} DCLASS;
X
X/*----------------------------------------------------------------------
X * Destination state.
X */
X
Xtypedef enum {
X	ST_WORKING,             /* the "normal" state                   */
X	ST_HOLD,                /* on hold during expansion             */
X	ST_DONE,                /* all processing complete              */
X	ST_ERROR                /* "something is horribly wrong"        */
X} DSTATE;
X
X/*----------------------------------------------------------------------
X * Structure describing a mail destination.
X */
X
X#define DEST    struct dest
XDEST {
X	DEST    *next;          /* next destination in the chain        */
X	DEST    *prev;          /* previous destination in the chain    */
X	DCLASS  class;          /* destination class                    */
X	DSTATE  state;          /* destination state                    */
X	int     dfdone;         /* boolean -- delivery file was run     */
X	char    *name;          /* context for delivery                 */
X	char    *mailbox;       /* mailbox name or NULL for default     */
X	char    *error;         /* error message (if state is ERROR)    */
X};
X
END_OF_FILE
if test 1636 -ne `wc -c <'dest.h'`; then
    echo shar: \"'dest.h'\" unpacked with wrong size!
fi
# end of 'dest.h'
fi
if test -f 'patchlevel.h' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'patchlevel.h'\"
else
echo shar: Extracting \"'patchlevel.h'\" \(21 characters\)
sed "s/^X//" >'patchlevel.h' <<'END_OF_FILE'
X#define PATCHLEVEL 0
END_OF_FILE
if test 21 -ne `wc -c <'patchlevel.h'`; then
    echo shar: \"'patchlevel.h'\" unpacked with wrong size!
fi
# end of 'patchlevel.h'
fi
if test -f 'misc.h' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'misc.h'\"
else
echo shar: Extracting \"'misc.h'\" \(1423 characters\)
sed "s/^X//" >'misc.h' <<'END_OF_FILE'
X/* $Header: misc.h,v 1.2 88/09/14 19:42:20 network Exp $
X *
X * Miscellaneous definitions.
X *
X * $Log:	misc.h,v $
X * Revision 1.2  88/09/14  19:42:20  network
X * Portability to System V and BSD.
X * General fixup.
X * 
X * Revision 1.1  88/06/06  09:37:58  chip
X * Initial revision
X * 
X */
X
X/*
X * Non-portable include files
X */
X
X#ifdef BSD
X#include <strings.h>
X#else
X#include <string.h>
X#include <memory.h>
X#endif
X
X/*
X * Constants
X */
X
X#ifdef NULL
X#undef NULL
X#endif
X#define NULL    0               /* The One True NULL */
X
X#define FALSE   0
X#define TRUE    1
X
X/*
X * Macros.
X */
X
X/* Length parameter for fgets() on given buffer. */
X
X#define GETSIZE(buf)    (int) (sizeof(buf) - 1)
X
X/*
X * Public data
X */
X
Xextern  char    **environ;
X
X/*
X * Library functions
X */
X
Xextern  char    *ctime();
Xextern  char    *getenv();
Xextern  char    *malloc();
Xextern  char    *realloc();
Xextern  char    *mktemp();
Xextern  int     putenv();
Xextern  long    lseek();
Xextern  long    time();
Xextern  void    free();
X
X/*
X * Library differences
X */
X
X#ifdef BSD
X
Xextern  int     setlinebuf();
X
X#define strchr          index
X#define strrchr         rindex
X#define memcpy(d,s,n)   bcopy(s,d,n)
X#define Zero(d,n)       bzero(d,n)
X#define Linebuf(f)      setlinebuf(f)
X
X#else   /* not BSD */
X
Xextern  int     setvbuf();
X
X#define Zero(d,n)       memset(d,0,(int)(n))
X#define Linebuf(f)      setvbuf(f, _IOLBF, (char *)NULL, BUFSIZ)
X
X#endif  /* not BSD */
END_OF_FILE
if test 1423 -ne `wc -c <'misc.h'`; then
    echo shar: \"'misc.h'\" unpacked with wrong size!
fi
# end of 'misc.h'
fi
echo shar: End of shell archive.
exit 0

-- 
Please send comp.sources.unix-related mail to rsalz@uunet.uu.net.