home *** CD-ROM | disk | FTP | other *** search
Text File | 1991-11-03 | 54.6 KB | 1,650 lines |
- Newsgroups: comp.sources.misc
- From: berg@messua.informatik.rwth-aachen.de (Stephen R. van den Berg)
- Subject: v25i003: procmail - mail processing program v2.31, Part03/04
- Message-ID: <1991Nov3.230023.9890@sparky.imd.sterling.com>
- X-Md4-Signature: 0e1f79a0c8af6cc7145a5c81f5998295
- Date: Sun, 3 Nov 1991 23:00:23 GMT
- Approved: kent@sparky.imd.sterling.com
-
- Submitted-by: berg@messua.informatik.rwth-aachen.de (Stephen R. van den Berg)
- Posting-number: Volume 25, Issue 3
- Archive-name: procmail/part03
- Environment: UNIX, sendmail, smail, MMDF
- Supersedes: procmail2.10: Volume 20, Issue 89-91
-
- #! /bin/sh
- # This is a shell archive. Remove anything before this line, then feed it
- # into a shell via "sh file" or similar. To overwrite existing files,
- # type "sh file -c".
- # The tool that generated this appeared in the comp.sources.unix newsgroup;
- # send mail to comp-sources-unix@uunet.uu.net if you want that tool.
- # Contents: procmail/FAQ procmail/HISTORY procmail/INSTALL
- # procmail/Makefile procmail/autoconf procmail/config.h
- # procmail/examples/1rmail procmail/examples/advanced
- # procmail/lockfile.c procmail/man/formail.man procmail/nonint.c
- # Wrapped by kent@sparky on Sun Nov 3 16:50:06 1991
- PATH=/bin:/usr/bin:/usr/ucb ; export PATH
- echo If this archive is complete, you will see the following message:
- echo ' "shar: End of archive 3 (of 4)."'
- if test -f 'procmail/FAQ' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'procmail/FAQ'\"
- else
- echo shar: Extracting \"'procmail/FAQ'\" \(3979 characters\)
- sed "s/^X//" >'procmail/FAQ' <<'END_OF_FILE'
- X------------------------------------------------------------------------------
- X---------------------- Frequently Asked Questions ----------------------------
- X------------------------------------------------------------------------------
- X
- X1. Why does the logfile have lines containing "file -i not found"?
- X
- X Your egrep doesn't understand the -i option (ignore case). Either
- X use a different grep (e.g. set GREP to /bin/grep), get a different
- X egrep (e.g. GNU-egrep), or be sure to specify the 'D' option on every
- X recipe. Or better yet: use the internal egrep.
- X
- X2. I installed procmail (i.e. typed 'make install'), but how am I supposed to
- X use it? When I type procmail on the command line it simply does nothing.
- X
- X You're not supposed to start procmail from the command line.
- X Be sure to have a .forward and a .procmailrc file in your home
- X directory (see the examples subdirectory or the man page).
- X
- X3. When I compile everything the compiler complains about invalid or illegal
- X pointer combinations, but it produces the executables anyway.
- X Should I be concerned?
- X
- X Ignore these warnings, they simply indicate that either your compiler
- X or your system include files are not ANSI/POSIX compliant.
- X The compiler will produce correct code regardless of these warnings.
- X
- X4. The compiler seems to issue warnings about "loop not entered at top",
- X is that a problem?
- X
- X No, no problem at all, it just means I wrote the code :-)
- X That's just about the only uncommon coding technique I use (don't
- X think I don't try to avoid those jumps in loops, it's just that
- X sometimes they are the best way to code it). Use gcc if you want
- X to avoid these warnings.
- X
- X5. The compiler complains about unmodifiable lvalues or assignments to const
- X variables. Now what?
- X
- X Well, if the compiler produces the executables anyway everything
- X probably is all right. If it doesn't, you might try inserting a
- X "#define const" in the autoconf.h file by hand. However in any case,
- X your compiler is broken; I would recommend submitting this as a
- X compiler bug to your vendor.
- X
- X6. The compiler produces some excessive warnings about enums, is that a reason
- X for concern?
- X
- X Your compiler is not ANSI compliant; so, in other words, ignore the
- X warnings.
- X
- X7. The compiler refuses to compile regexp.c, what is the problem?
- X
- X Try compiling that module with optimisation turned off.
- X
- X8. When I send myself a testmail, the mail bounces with the message: cannot
- X execute binary file. What am I doing wrong?
- X
- X It is very well possible that mail is processed on a different
- X machine from that where you usually read your mail. Therefore you
- X have to make sure that procmail has the right binary format to
- X execute on those machines on which mail could arrive. In order to
- X get this right you might need to do some .forward file tweaking,
- X look at the examples/advanced file for some suggestions.
- X
- X9. Where do I look for examples about:
- X Crossmounted mailboxes?
- X Procmail as an integrated local mail delivery agent?
- X Security consideratiions (when installing procmail suid root)
- X How to generate autoreplies?
- X Exorbitant rcfile formats?
- X The 'A' flag?
- X
- X Well, this probably is your lucky day :-), all these topics are covered
- X in the examples/advanced file.
- X
- X10. How do I go about setting up a mailinglist?
- X
- X Look in the examples/mailinglist file, it describes it in detail.
- X
- X11. Why do the example rcfiles set IFS in the first line?
- X
- X If procmail would be called with the -p option, and IFS would be preset
- X (this might not be under *your* control since anyone can call up
- X procmail to deliver to you, if it is suid root) to some insane values
- X (sane value of IFS='\n\t ') any Bourne-shell script (/bin/sh) started
- X from within procmail could start to behave very strange.
- X
- X12. None of the above topics cover my problem. Should I panic?
- X
- X Let me ask you a question :-), have you examined the CAVEATS, WARNINGS,
- X BUGS and NOTES sections of the manual pages *closely* ?
- X If you have, well, then panic.
- END_OF_FILE
- if test 3979 -ne `wc -c <'procmail/FAQ'`; then
- echo shar: \"'procmail/FAQ'\" unpacked with wrong size!
- fi
- # end of 'procmail/FAQ'
- fi
- if test -f 'procmail/HISTORY' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'procmail/HISTORY'\"
- else
- echo shar: Extracting \"'procmail/HISTORY'\" \(4360 characters\)
- sed "s/^X//" >'procmail/HISTORY' <<'END_OF_FILE'
- X1990/12/07: v1.00
- X1990/12/12: v1.01
- X1991/02/04: v1.02
- X1991/02/13: v1.10
- X1991/02/21: v1.20
- X1991/02/22: v1.21
- X1991/03/01: v1.30
- X1991/03/15: v1.35
- X Started using RCS to manage the source
- X1991/06/04: v1.99
- X1991/06/10: v2.00
- X1991/06/11: v2.01
- X1991/06/12: v2.02
- X1991/06/20: v2.03
- X1991/07/04: v2.10
- X Fixed bugs (regression bugs introduced in v1.99):
- X Misleading error message when a ':c' recipe was used on a
- X simple mailbox
- X Inability to change numeric variables from their defaults
- X Fixed slight descrepancy between /bin/sh parsing and procmail while
- X assigning something in backquotes
- X Added two more recognised headers to formail for splitting digests
- X Added MMDF mailbox format support to procmail and formail
- X Added MH mailbox format support to procmail
- X Extended the FAQ section in INSTALL
- X Improved the 'void' test in autoconf
- X Added three new features to procmail: 'A'-recipe option, "LOG"
- X keyword, "TIMEOUT" keyword
- X Changes to the man pages:
- X Made them more portable! (yes, I was surprised myself :-)
- X Documented the new features
- X Reformulated some things more clearly
- X Changes to the example files:
- X A better example for splitting up digests
- X Extended the 'advanced' examples by an elaborate ':A' option
- X example
- X1991/07/12: v2.11
- X Enhanced MMDF support
- X Ignoring SIGPIPE now, how could I ever have left it out?
- X This should take care of any, previously inexplicable,
- X mysterious failures of formail or procmail
- X Blanks are really ignored now on action lines
- X1991/10/02: v2.20 (never released)
- X Included an extensive guide on how to set up mailinglists
- X Split off the FAQ into a separate file and extended it
- X Replaced some 'forgotten' fork()s with sfork()
- X Changes to formail.c:
- X Added simple header-munging support to formail
- X Extended the number of recognised headers when searching for
- X the originating address by two
- X Made it concatenate continued header lines (in order to ensure
- X reliable header-munging)
- X Changes to procmail:
- X Added the DELIVERED keyword
- X Added some command line options, options are now not exclusive
- X anymore
- X Gave new meaning to the -d option, old meaning is transferred
- X to the LOGFILE assignment
- X It can now return EX_TEMPFAIL if needed
- X It can be used as a direct replacement for /bin/mail when
- X delivering mail
- X It can be run suid root (for enhanced functionality, this
- X is *not* intended to open up security holes, and as far as
- X I can see it doesn't)
- X Added a Usage message
- X Reorganised flags parsing, blanks can now be inserted anywhere
- X Added the 'i' flag
- X Dropped support for the 's' and 'I' flags
- X Enhanced the locallockfile determination code
- X Reordered some assignments in the signal-detect code, should
- X improve reliability
- X Dropped the SIGQUIT child-parent communication, has become
- X obsolete
- X Threw out sscanf, provided a strtol substitute
- X Made HARDLOCKS optional
- X Changes to exopen.c:
- X Yet improved the lockfile acquiring, more elegant and even more
- X fault tolerant than ever before :-)
- X lockfile and formail state their names on error messages now
- X Alphabetised the DIAGNOSTICS section of man/procmail.1
- X Added a 'deinstall' entry in Makefile
- X Improved Makefile installation feedback
- X Added a patchlevel.h file
- X1991/10/18: v2.30
- X Implemented a custom regular expression library (fully egrep
- X compatible), should eliminate the annoyances with incompatible
- X egreps
- X Changed the formatting (indenting) style in all the source files
- X (which blows up all diffs beyond proportion of course)
- X Accomplished the doubtfull milestone of having a source file
- X (regexp.c) which provokes a compiler error on an old compiler
- X (if using the optimiser)
- X Threw out the GREP environment variable
- X Ignoring leading spaces on condition lines now
- X Rewrote some parts to use the regexp lib, making the code smaller
- X1991/10/22: v2.31
- X Updated the example rcfiles
- X Added answers to FAQ list
- X Fixed portability problem with missing strpbrk and strchr
- X Cleaned up the lockfile creation when in explicit delivery mode
- END_OF_FILE
- if test 4360 -ne `wc -c <'procmail/HISTORY'`; then
- echo shar: \"'procmail/HISTORY'\" unpacked with wrong size!
- fi
- # end of 'procmail/HISTORY'
- fi
- if test -f 'procmail/INSTALL' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'procmail/INSTALL'\"
- else
- echo shar: Extracting \"'procmail/INSTALL'\" \(3165 characters\)
- sed "s/^X//" >'procmail/INSTALL' <<'END_OF_FILE'
- XDiscusses:
- X 1. Getting the lot to compile
- X 2. Setting up the environment
- X 3. Extra options if you are a system administrator
- X
- X ---
- X
- X1. Getting the lot to compile
- X --------------------------
- X
- XTo install procmail, lockfile and formail: edit Makefile & config.h accordingly
- Xand type 'make install'.
- XIntended configurable options in Makefile are: the install-destinations
- XIntended configurable options in config.h are: HARDLOCKS and MMDF support.
- X
- X'make install' will:
- X - execute autoconf (a shell script that repeatedly calls the C compiler
- X to determine if certain features/symbols are supported), which will
- X create a file named autoconf.h
- X - compile the *.c files, create the three stripped binaries:
- X procmail, lockfile and formail
- X - copy these binaries to $(BINDIR)
- X - copy the man pages to $(MANDIR)
- X
- X'make deinstall' will:
- X - remove the just installed files in $(BINDIR)
- X - remove the just installed files in $(MANDIR)
- X
- X
- XMinimal requirements:
- X
- Xprocmail must be installed.
- Xlockfile needs only to be installed if you plan to read several mailboxes
- X with one of the standard mailers that don't support lockfiles.
- Xformail needs only to be installed if mail sometimes arrives in nonstandard
- X mailbox format (or if you want to generate auto replies, split up
- X mailboxes/digests etc., see the man page of formail for more info).
- X
- X
- XIf things don't compile automagically, I suggest you take a look at:
- Xautoconf, autoconf.h, config.h, includes.h
- X
- XFor autoconf to work as intended, your compiler should either be fully ANSI
- Xcompliant, or you should NOT turn off all warnings; enabling all warnings
- Xshouldn't hurt. In most cases the default options in the Makefile will do.
- X
- XThe sources are supposed to be fully ANSI and K&R compliant.
- X
- XIf you run procmail by hand and pipe in some sample mail, then make
- Xsure that if you kill procmail, you use "kill pid" and NOT "kill -9 pid".
- XShould procmail seem to hang, check if the $LOCKFILE is still present.
- XIf you kill procmail with "kill pid" it will clean up the $LOCKFILE
- Xitself.
- X
- XSuggested command line for a test run: "procmail -d LOGFILE=:/dev/tty"
- X(now type in a mail message).
- X
- X ---
- X
- X2. Setting up the environment
- X --------------------------
- X
- XEvery user that wants to use procmail should have a .forward and a
- X.procmailrc file in his HOME directory. For starters, you can look
- Xat the supplied example files in "examples".
- X(BTW, be sure to make .forward *world* readable).
- X
- X ---
- X
- X3. Extra options if you are a system administrator
- X -----------------------------------------------
- X
- XIf you are a system administrator you can decide to install procmail
- Xglobally (i.e. as an equivalent substitute for /bin/mail), this has the
- Xadvantage that users do not need to have a .forward file anymore that
- Xcalls up procmail. Simply having a .procmailrc file in the $HOME directory
- Xwill suffice. Operation is transparant in this case (i.e. if no .procmailrc
- Xfile is present in the $HOME directory, mail will be delivered as usual).
- X
- XFor direct examples on how to do this, look at the examples/advanced file.
- X
- X ---
- X
- XFor more info about the program, see the man page or the FAQ list.
- END_OF_FILE
- if test 3165 -ne `wc -c <'procmail/INSTALL'`; then
- echo shar: \"'procmail/INSTALL'\" unpacked with wrong size!
- fi
- # end of 'procmail/INSTALL'
- fi
- if test -f 'procmail/Makefile' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'procmail/Makefile'\"
- else
- echo shar: Extracting \"'procmail/Makefile'\" \(3772 characters\)
- sed "s/^X//" >'procmail/Makefile' <<'END_OF_FILE'
- X#$Id: Makefile,v 2.7 1991/10/18 15:36:39 berg Rel $
- X
- X# change BASENAME to your home directory if need be
- XBASENAME = /usr/local
- X
- XBINDIR = $(BASENAME)/bin
- XMANSUFFIX= 1
- XMANDIR = $(BASENAME)/man/man$(MANSUFFIX)
- X
- X# Things that can be made are:
- X
- X# procmail formail lockfile These are the three programs contained
- X# in this package
- X
- X# all Makes all three binaries and the man pages
- X# install.man Installs the man pages to $(MANDIR)
- X# install Is a "make all" followed by copying all the binaries
- X# and man pages to $(BINDIR) and $(MANDIR) respectively
- X# clean Restores the package to pre-make state
- X# deinstall Removes the previously installed binaries and man
- X# pages by carefull surgery
- X
- X########################################################################
- X# Only edit below this line if you *think* you know what you are doing #
- X########################################################################
- X
- X# Directory for the standard include files
- XUSRINCLUDE = /usr/include
- X
- XOCFLAGS = -O
- XOLDFLAGS= -s
- X
- XCFLAGS = $(OCFLAGS) -I$(USRINCLUDE) -I./include
- XLDFLAGS = $(OLDFLAGS)
- X
- XCC = cc
- XMAKE = make
- XSHELL = /bin/sh
- XO = o
- XRM = rm -f
- X
- XBINS=procmail lockfile formail
- X
- XMANS=man/procmail.1 man/formail.1
- X
- XMANSO=procmail.$(MANSUFFIX) formail.$(MANSUFFIX) lockfile.$(MANSUFFIX)
- X
- XOBJ=nonint.$(O) goodies.$(O) regexp.$(O)
- X
- XDEP=shell.h procmail.h config.h
- X
- Xall: autoconf.h $(BINS) $(MANS)
- X
- Xprocmail: procmail.$(O) $(OBJ) exopen.$(O) common.$(O) retint.$(O)
- X $(CC) $(CFLAGS) -o procmail procmail.$(O) $(OBJ) exopen.$(O) \
- Xcommon.$(O) retint.$(O) $(LDFLAGS)
- X
- Xlockfile: lockfile.$(O) exopen.$(O)
- X $(CC) $(CFLAGS) -o lockfile lockfile.$(O) exopen.$(O) ${LDFLAGS}
- X
- Xformail: formail.$(O) common.$(O)
- X $(CC) $(CFLAGS) -o formail formail.$(O) common.$(O) ${LDFLAGS}
- X
- X_autotst: _autotst.$(O)
- X $(CC) $(CFLAGS) -o _autotst _autotst.$(O) $(LDFLAGS)
- X
- Xautoconf.h: autoconf Makefile
- X /bin/sh autoconf $(O) $(MAKE) autoconf.h
- X
- XMakefile:
- X
- X$(OBJ): $(DEP)
- X
- Xretint.$(O): $(DEP) exopen.h
- X
- Xprocmail.$(O): $(DEP) patchlevel.h
- X
- Xexopen.$(O): config.h includes.h exopen.h
- X
- Xformail.$(O): config.h includes.h shell.h
- X
- Xlockfile.$(O): config.h includes.h
- X
- Xcommon.$(O): includes.h shell.h
- X
- Xprocmail.h: includes.h
- X touch procmail.h
- X
- Xincludes.h: autoconf.h
- X touch includes.h
- X
- X.c.$(O):
- X $(CC) $(CFLAGS) -c $*.c
- X
- Xman/man.sed: man/manconf.c config.h procmail.h
- X $(CC) $(CFLAGS) -o man/manconf man/manconf.c ${LDFLAGS}
- X man/manconf >man/man.sed
- X rm -f man/manconf
- X chmod 755 man/mansed
- X
- Xman/procmail.1: man/man.sed man/procmail.man man/mansed
- X man/mansed man/procmail.man man/procmail.1
- X
- Xman/formail.1: man/man.sed man/formail.man man/mansed
- X man/mansed man/formail.man man/formail.1
- X
- Xinstall.man: $(MANS)
- X chmod 0644 man/*.1
- X cp man/procmail.1 $(MANDIR)/procmail.$(MANSUFFIX)
- X cp man/lockfile.1 $(MANDIR)/lockfile.$(MANSUFFIX)
- X cp man/formail.1 $(MANDIR)/formail.$(MANSUFFIX)
- X
- Xinstall: all install.man
- X @chmod 0755 $(BINS)
- X @cp $(BINS) $(BINDIR)
- X @echo
- X @cd $(BINDIR); echo Installed in $(BINDIR); ls -l $(BINS)
- X @cd $(MANDIR); echo Installed in $(MANDIR); ls -l $(MANSO)
- X @echo ----------------------------------------------------------------\
- X---------------
- X @echo If you are a system administrator, you should consider \
- Xinstalling procmail
- X @echo suid-root and/or integrating procmail into the mail-delivery \
- Xsystem -- for
- X @echo advanced functionality --. For more information about this \
- Xtopic you should
- X @echo look in the examples/advanced file.
- X @echo ----------------------------------------------------------------\
- X---------------
- X
- Xdeinstall:
- X cd $(BINDIR); $(RM) $(BINS); ls -l $(BINS)
- X cd $(MANDIR); $(RM) $(MANSO); ls -l $(MANSO)
- X
- Xclean:
- X $(RM) $(OBJ) common.$(O) lockfile.$(O) exopen.$(O) retint.$(O) \
- Xformail.$(O) procmail.$(O) $(BINS) autoconf.h _autotst* grepfor $(MANS) \
- Xman/man.sed
- END_OF_FILE
- if test 3772 -ne `wc -c <'procmail/Makefile'`; then
- echo shar: \"'procmail/Makefile'\" unpacked with wrong size!
- fi
- # end of 'procmail/Makefile'
- fi
- if test -f 'procmail/autoconf' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'procmail/autoconf'\"
- else
- echo shar: Extracting \"'procmail/autoconf'\" \(4506 characters\)
- sed "s/^X//" >'procmail/autoconf' <<'END_OF_FILE'
- X
- X#$Id: autoconf,v 2.9 1991/10/22 15:31:26 berg Rel $
- X
- XSHELL=/bin/sh || exec /bin/sh autoconf $* # we're in a csh, feed myself to sh
- X
- X# All possible entries in autoconf.h:
- X
- X# #define const
- X# #define volatile
- X# #define void char
- X# typedef int mode_t;
- X# typedef int pid_t;
- X# typedef int uid_t;
- X# typedef int gid_t;
- X# typedef unsigned size_t;
- X# typedef long time_t;
- X# #define NOmemmove
- X# #define NObcopy
- X# #define NOstrstr
- X# #define NOstrcspn
- X# #define NOstrpbrk
- X# #define strchr(s,c) index(s,c)
- X# #define setpwent()
- X# #define endpwent()
- X# #define strtol(str,ptr,base) ((long)atoi(str))
- X# #define SYSTEM_MAILBOX "/usr/spool/mail/$USER"
- X
- X# A conforming ANSI compiler and POSIX library should only produce three
- X# entries in autoconf.h: setpwent(), endpwent() and SYSTEM_MAILBOX
- X# Anything else indicates failure of your installation to comply with either
- X# the ANSI or POSIX standards (but procmail should be installable anyway).
- X
- XPATH=:$PATH
- Xexport SHELL
- XACONF=$3
- XMAKE=$2
- Xif test -f $ACONF
- Xthen
- X trap "exit 1" 1 2 3 15
- Xelse
- X trap "rm -f $ACONF; exit 1" 1 2 3 15
- Xfi
- X
- Xcat >grepfor <<HERE
- Xif fgrep "\$1" _autotst.rrr >/dev/null
- Xthen
- X echo "\$2" >>$ACONF
- X exit 0
- Xfi
- Xexit 1
- XHERE
- Xchmod 0755 grepfor
- X
- Xcat >$ACONF <<HERE
- X/* This file was automagically generated by autoconf */
- X
- XHERE
- X
- X# WARNING: in ./include/stdlib.h the const keyword is already used!
- X# hence the const test has to precede all others.
- X
- Xcat >_autotst.c <<HERE
- Xmain(){const char*p;const char*q;
- X p="t";q=p;return 0;}
- XHERE
- X
- Xecho 'Testing for const'
- Xif ${MAKE} _autotst.$1 >_autotst.rrr 2>&1
- Xthen
- X grepfor const '#define const'
- Xelse
- X echo '#define const' >>$ACONF
- Xfi
- Xrm -f _autotst.$1
- X
- Xcat >_autotst.c <<HERE
- Xmain(){volatile int i;return 0;}
- XHERE
- X
- Xecho 'Testing for volatile'
- Xif ${MAKE} _autotst.$1 >/dev/null 2>&1
- Xthen
- X:
- Xelse
- X echo '#define volatile' >>$ACONF
- Xfi
- Xrm -f _autotst.$1
- X
- Xcat >_autotst.c <<HERE
- Xmain(){int i;i= -1;return i=-i;}
- XHERE
- X
- Xecho 'Testing for compiler age'
- X${MAKE} _autotst >_autotst.rrr 2>&1
- X
- Xif _autotst
- Xthen
- X echo 'Aha, this one is genuine antique!'
- X echo '#define void char' >>$ACONF
- Xfi
- Xrm -f _autotst _autotst.$1
- X
- Xcat >_autotst.c <<HERE
- X#include "includes.h"
- Xmain(){int i;char*p="t";
- X void*vvoid;vvoid=p;
- X i=(size_t)1;
- X i+=(pid_t)1;
- X i+=(time_t)1;
- X i+=(mode_t)1;
- X i+=(uid_t)1;
- X i+=(gid_t)1;
- X return !vvoid;}
- XHERE
- X
- Xecho 'Testing for void*,size_t,pid_t,time_t,mode_t,uid_t,gid_t'
- X${MAKE} _autotst.$1 >_autotst.rrr 2>&1
- Xrm -f _autotst.$1
- X
- Xgrepfor void '#define void char'
- Xgrepfor size_t 'typedef unsigned size_t;'
- Xgrepfor pid_t 'typedef int pid_t;'
- Xgrepfor time_t 'typedef long time_t;'
- Xgrepfor mode_t 'typedef int mode_t;'
- Xgrepfor uid_t 'typedef int uid_t;'
- Xgrepfor gid_t 'typedef int gid_t;'
- X
- Xcat >_autotst.c <<HERE
- X#include "includes.h"
- Xmain(){char a[2];
- X setpwent();endpwent();memmove(a,"0",1);bcopy("0",a,1);strstr(a,"0");
- X strcspn(a,"0");strtol("0",(char**)0,10);strchr("0",'0');strpbrk(a,"0");
- X return 0;}
- XHERE
- X
- Xecho 'Testing for memmove, strstr, strchr, strcspn & strtol'
- X${MAKE} _autotst.$1 >/dev/null 2>&1
- X${MAKE} _autotst >_autotst.rrr 2>&1
- Xrm -f _autotst _autotst.$1 _autotst.c
- X
- Xgrepfor strstr '#define NOstrstr'
- Xgrepfor strcspn '#define NOstrcspn'
- Xgrepfor strpbrk '#define NOstrpbrk'
- Xgrepfor strchr '#define strchr(s,c) index(s,c)'
- Xgrepfor setpwent '#define setpwent()'
- Xgrepfor endpwent '#define endpwent()'
- Xgrepfor strtol '#define strtol(str,ptr,base) ((long)atoi(str))'
- Xgrepfor memmove '#define NOmemmove' &&
- Xif fgrep bcopy _autotst.rrr >/dev/null
- Xthen
- X echo '#define NObcopy' >>$ACONF
- Xelse
- X
- X cat >_autotst.c <<HERE
- X#include "includes.h"
- X#define M256 256
- X#define F33 33
- Xmain(){int j=0,i=M256-1;static char a[M256];
- X do a[i]=i;while(i--);
- X bcopy(a+F33,a,M256-F33);bcopy(a,a+F33,M256-F33);i=F33-1;
- X do j|=a[i]!=(char)(i+F33);while(i--);i=M256-1;
- X do j|=a[i]!=(char)i;while(--i!=F33-1);return!j;}
- XHERE
- X
- X echo 'Testing for bcopy handling overlaps'
- X ${MAKE} _autotst >/dev/null 2>&1
- X
- X if _autotst
- X then
- X echo 'Sorry, incompetent bcopy'
- X echo '#define NObcopy' >>$ACONF
- X fi
- X rm -f _autotst _autotst.c
- Xfi
- X
- Xif test -d /usr/spool/mail
- Xthen
- X echo '#define SYSTEM_MAILBOX "/usr/spool/mail/$USER"' >>$ACONF
- Xelif test -d /usr/mail
- Xthen
- X echo '#define SYSTEM_MAILBOX "/usr/mail/$USER"' >>$ACONF
- Xelse
- X echo '#define SYSTEM_MAILBOX "$HOME/.mbox"' >>$ACONF
- X echo Could not find the system-mailbox directory, supplied substitute
- Xfi
- X
- Xrm -f _autotst* grepfor
- X
- Xecho -----------------------------autoconf.h-----------------------------------
- Xcat $ACONF
- Xecho --------------------------------------------------------------------------
- END_OF_FILE
- if test 4506 -ne `wc -c <'procmail/autoconf'`; then
- echo shar: \"'procmail/autoconf'\" unpacked with wrong size!
- fi
- # end of 'procmail/autoconf'
- fi
- if test -f 'procmail/config.h' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'procmail/config.h'\"
- else
- echo shar: Extracting \"'procmail/config.h'\" \(4838 characters\)
- sed "s/^X//" >'procmail/config.h' <<'END_OF_FILE'
- X/*$Id: config.h,v 2.5 1991/10/18 15:33:23 berg Rel $*/
- X
- X/*#define KERNEL_LOCKS /* uncomment if you want to use kernel locks on file
- X descriptors (not recommended if your system uses a
- X buggy lockd across a net, or if your mailer uses tmp files in updating
- X mailboxes and moves them into place); only advisable if your mailreader
- X can't be convinced to use "dotfile"-locks */
- X
- X/*#define MAILBOX_SEPARATOR "\1\1\1\1\n" /* uncomment if your mail
- X system uses nonstandard
- X mail separators (non sendmail or smail compatible mailers like MMDF),
- X if yours is even different, uncomment and change the value of course */
- X
- X/*#define SYSTEM_MBOX "$HOME/.mbox" /* uncomment and/or change if the
- X preset default mailbox is *not*
- X either /usr/spool/mail/$USER or /usr/mail/$USER (it will supersede
- X the value of SYSTEM_MAILBOX) */
- X
- X/*#define console ":/dev/console" /* uncomment if you want procmail to
- X use the console (or any other
- X terminal) to print any error messages that could not be dumped in the
- X "logfile". (Only recommended for debugging purposes, if you have
- X trouble creating a "logfile") */
- X
- X/************************************************************************
- X * Only edit below this line if you *think* you know what you are doing *
- X ************************************************************************/
- X
- X#define NOBODY_uid 0xfffe /* default uid when no valid recipient */
- X#define NOBODY_gid 0xfffe /* default gid when no valid recipient */
- X
- X#define INIT_UMASK 077
- X#define DEFlinebuf 2048 /* default max expanded line length */
- X#define BLKSIZ 16384 /* blocksize while reading/writing */
- X#define STDBUF 1024 /* blocksize for emulated stdio */
- X#define HOSTNAMElen 8 /* nr of significant chararacters for HOST */
- X#define PROCMAILRC ".procmailrc"
- X#define DEFsuspend 16 /* multi-purpose 'idle loop' period */
- X#define DEFlocksleep 8
- X#define TOkey "^TO"
- X#define TOsubstitute "^(To|Cc|Apparently-To):.*"
- X#define DEFshellmetas "&|<>~;?*[]=" /* never put '$' in here */
- X#define DEFmaildir "/usr/spool/mail"
- X#define DEFdefault "$ORGMAIL"
- X#define DEFdefaultlock "LOCKFILE=$DEFAULT$LOCKEXT"
- X#define DEFmsgprefix "msg."
- X#define DEFsendmail "/usr/lib/sendmail"
- X#define DEFlockext ".lock"
- X#define DEFshellflags "-c"
- X#define DEFlocktimeout 3600 /* defaults to one hour */
- X#define DEFtimeout (DEFlocktimeout-60) /* 60 seconds to clean up */
- X#define DEFnoresretry 2 /* default nr of retries if no resources left */
- X
- X#define BinSh "/bin/sh"
- X#define Tmp "/tmp"
- X#define DevNull "/dev/null"
- X#define DIRSEP "/" /* directory separator symbols, the */
- X /* last one should be the most common one */
- X
- X#define EOFName " \t\n#`'\");"
- X
- X#define VERSIONOPT 'v' /* option to display version */
- X#define PRESERVOPT 'p' /* preserve environment */
- X#define TEMPFAILOPT 't' /* return EX_TEMPFAIL on error */
- X#define DELIVEROPT 'd' /* deliver mail to named recipient */
- X#define PROCMAIL_USAGE \
- X "Usage: procmail [-vpt] [-d recipient ] [ parameter=value | rcfile ] ...\n"
- X
- X#define MINlinebuf 128 /* minimal LINEBUF length (don't change this) */
- X#define FROM_EXPR "\n\nFrom +[^\t\n ]+ +[^\t\n ]"
- X#define FROM "From "
- X#define NSUBJECT "^Subject:.*$"
- X#define MAXSUBJECTSHOW 78
- X#define FOLDER " Folder: "
- X#define LENtSTOP 9 /* tab stop at which message length will be logged */
- X
- X#define TABCHAR "\t"
- X#define TABWIDTH 8
- X
- X#define RECFLAGS "HBDAhbfcwi"
- X#define HEAD_GREP 0
- X#define BODY_GREP 1
- X#define DISTINGUISH_CASE 2
- X#define ALSO_NEXT_RECIPE 3
- X#define PASS_HEAD 4
- X#define PASS_BODY 5
- X#define FILTER 6
- X#define CONTINUE 7
- X#define WAIT_EXIT 8
- X#define IGNORE_WRITERR 9
- X
- X#define ESCAP '>'
- X
- X /* some formail-specific configuration options */
- X
- X#define UNKNOWN "foo@bar" /* formail default originator name */
- X#define OLD_PREFIX "Old-" /* formail field-Old-prefix */
- X
- X#define FM_SKIP '+' /* skip the first nnn messages */
- X#define FM_TOTAL '-' /* only spit out a total of nnn messages */
- X#define FM_BOGUS 'b' /* leave bogus Froms intact */
- X#define FM_FORCE 'f' /* force formail to accept an arbitrary format */
- X#define FM_REPLY 'r' /* generate an auto-reply header */
- X#define FM_KEEPB 'k' /* keep the header, when replying */
- X#define FM_TRUST 't' /* trust the sender to supply a valid header */
- X#define FM_SPLIT 's' /* split it up */
- X#define FM_NOWAIT 'n' /* don't wait for the programs */
- X#define FM_EVERY 'e' /* split on every From line */
- X#define FM_DIGEST 'd' /* split up digests */
- X#define FM_QUIET 'q' /* ignore write errors on stdout */
- X#define FM_REN_INSERT 'i' /* rename and insert a field */
- X#define FM_DEL_INSERT 'I' /* delete and insert a field */
- X#define FM_USAGE \
- X "Usage: formail [+nnn] [-nnn] [-bfrktnedq] [-iI field] [-s command arg ...]\n"
- END_OF_FILE
- if test 4838 -ne `wc -c <'procmail/config.h'`; then
- echo shar: \"'procmail/config.h'\" unpacked with wrong size!
- fi
- # end of 'procmail/config.h'
- fi
- if test -f 'procmail/examples/1rmail' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'procmail/examples/1rmail'\"
- else
- echo shar: Extracting \"'procmail/examples/1rmail'\" \(400 characters\)
- sed "s/^X//" >'procmail/examples/1rmail' <<'END_OF_FILE'
- X#!/bin/sh
- X#
- X# specify the mailbox file you want to read on the command line
- X#
- XMAILDIR=$HOME/Mail
- Xcd $MAILDIR
- XLOCKFILE=$HOME/.lockmail
- Xif lockfile -! -r1 $LOCKFILE
- Xthen
- X echo Mail is currently arriving, please wait...
- X while
- X lockfile -! -4 -r2 $LOCKFILE
- X do
- X echo Mail is still arriving...
- X done
- Xfi
- Xtrap "rm -f $LOCKFILE;exit 0" 0 1 2 3 15
- X#
- X# Call you favourite mailer here.
- X#
- X/usr/ucb/mail -f $*
- END_OF_FILE
- if test 400 -ne `wc -c <'procmail/examples/1rmail'`; then
- echo shar: \"'procmail/examples/1rmail'\" unpacked with wrong size!
- fi
- # end of 'procmail/examples/1rmail'
- fi
- if test -f 'procmail/examples/advanced' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'procmail/examples/advanced'\"
- else
- echo shar: Extracting \"'procmail/examples/advanced'\" \(7409 characters\)
- sed "s/^X//" >'procmail/examples/advanced' <<'END_OF_FILE'
- XDiscusses:
- X 1. Crossmounted mailboxes
- X 2. Procmail as an integrated local mail delivery agent
- X 3. Security considerations (when installing procmail suid root)
- X 4. How to generate autoreplies
- X 5. Some exorbitant examples of rcfile formats
- X 6. Some advanced examples of the use of the 'A' flag
- X
- X ---
- X
- X1. Crossmounted mailboxes
- X ----------------------
- X
- XFor users that have crossmounted mailboxes (i.e. you can access the very
- Xsame mail from a whole bunch of different workstations), but on machines
- Xwith differing architectures (i.e. you need different executables), and they
- Xhave to explicitly use (i.e. the system administrator did not arrange,
- Xfor example, /usr/local/bin/procmail to have exactly the right contents
- Xdepending on from which machine it is called) two executables of procmail,
- XI have the following suggestion to use as a .forward file (examples are for
- Xsparc and sun3 architectures):
- X
- X"|IFS=' ';if /usr/bin/sparc;then exec /home/berg/bin.sun4/procmail;else exec /home/berg/bin.sun3/procmail;fi"
- X
- Xor alternatively:
- X
- X"|IFS=' ';exec /home/berg/bin.`/usr/bin/arch`/procmail"
- X
- XPlease note, in the .forward file there can NOT be any newlines between
- Xthe doublequotes, i.e. the former example *has* to be typed in as one long
- Xline.
- X
- X ---
- X
- X2. Procmail as an integrated local mail delivery agent
- X ---------------------------------------------------
- X
- XCompletely integrating procmail in the mail delivery means that mail is
- Xdelivered as normal, unless a .procmailrc file is present in the home
- Xdirectory of the recipient. This will be completely independent of the
- Xfact if a .forward file is present. This will not break anything, it
- Xjust makes the use of procmail easier because people are not required to
- Xstart up procmail from within their .forward files. Creation of a .procmailrc
- Xfile will suffice.
- X
- XIn order to do this, the following line should be in your sendmail.cf
- X(this way sendmail will start up procmail with root priv, procmail will
- Ximmediately setuid itself to the recipient's uid):
- X
- XMlocal, P=/usr/local/bin/procmail, F=lsSDFMuhP, S=10, R=20, A=procmail -d $u
- X
- XIf your sendmail does not allow starting programs with root privs (the
- X'S' flag), you can instead make procmail suid root. This will not create
- Xa security hole, procmail will normally setuid immediately to the real
- Xuid (effectively losing root privs), or will immediately setuid to the
- Xrecipient's uid (and be completely loyal to the recipient's absent or present
- X.procmailrc file). Actually installing procmail suid root is a slightly more
- Xflexible approach (not at all more dangerous).
- X
- XIf using the suid root version of procmail, you only need to insert the
- Xfollowing: line in your sendmail.cf:
- X
- XMlocal, P=/usr/local/bin/procmail, F=lsDFMuhP, S=10, R=20, A=procmail -d $u
- X
- XSo, to summarise, if you install procmail not-suid-root you should use the
- Xfirst rule (with the 'S' flag), and if you install it suid-root you should
- Xuse the second rule (without the 'S' flag). If you install procmail
- Xnot-suid-root you can not use the second rule, since procmail will not be
- Xable to change uid to the recipient, and therefore it can not read/write
- Xthe recipient's files (including any .procmailrc). The alternative would
- Xbe that procmail already has the recipient's uid upon startup, this is not
- Xpossible in sendmail without changing some configuration options.
- X
- X ---
- X
- X3. Security considertations (when installing procmail suid root)
- X -------------------------------------------------------------
- X
- XIf in EXPLICIT DELIVERY mode (typically when called from within sendmail)
- Xprocmail will ALWAYS change UID and gid to the RECIPIENT's defaults as soon as
- Xit starts reading the recipient's $HOME/.procmailrc file.
- X
- XIF NOT in explicit delivery mode (typically when called from within the
- Xrecipient's $HOME/.forward file) procmail will ALWAYS change UID and gid to
- Xthe real uid and gid of the INVOKER (effectively losing any suid or sgid
- Xpriviliges).
- X
- XThese two precautions should effectively eliminate any security holes because
- Xprocmail will always have the uid of the person whose commands it is executing.
- X
- X ---
- X
- X4. How to generate autoreplies
- X ---------------------------
- X
- XUsing a recipe like the following, you can generate autoreplies to mail
- Xreceived by you:
- X
- X: 2 h c
- X!^From +(postmaster|Mailer)
- X!^From +your_own_login_name
- X| formail -r | (cat; echo "Mail received.") | $SENDMAIL -t
- X
- XAs you can see, I made sure that neither bouncing mail (from postmaster or the
- Xmailer-daemon), nor mail coming from yourself will be autoreplied. If this
- Xprecaution would not be taken, disaster could result ("ringing" mail).
- XThe abovementioned recipe should be inserted before all other recipes in
- Xyour rcfile, however, it is advisable to put it *after* any recipes that
- Xprocess mailinglist subscriptions; it generally is not a good idea to
- Xgenerate autoreplies to mailinglists.
- X
- X ---
- X
- X5. Some exorbitant examples of rcfile formats
- X ------------------------------------------
- X
- X# Now follows an example of what you can do in a procmailrc file
- XHELLO=oneword
- XHELLO="two words"
- XHELLO='two words' HELLO = one\
- Xword
- XHELLO=two\ words
- XHELLO=two\ `echo words`
- XHELLO= # empty
- XHELLO # This will wipe "HELLO" from the environment
- XHELLO = "three words"\ yes
- XHELLO = "$HELLO `cat somefile` " # Trailing blanks
- XHELLO = "wheeee`date`${HELLO} this works too" HELLO = 'But so does this!'
- X
- X# As you can see, every trick in the book of /bin/sh programming can be used
- X# (and more).
- X
- XLOCALLOCKFILE = llf
- X
- X ::$LOCALLOCKFILE
- Xgrep for this
- X |$HELLO # calls up a program named "But" with 3 arguments
- X
- X:: "test ing" # lockfilename with a space in it
- Xgrep for this
- X |$HELLO
- X
- X:
- Xor for this
- X|"$HELLO" # tries to call up a program named "But so does this!"
- X
- X:
- Xand this
- X|$HELLO \
- Xthere # action lines can be continued
- X
- X ---
- X
- X6. Some advanced examples of the use of the 'A' flag
- X -------------------------------------------------
- X
- X:c # Specify the 'c' otherwise we never arrive at the next recipe
- X^From Myfriend
- Xevery_message_from_my_friend # Mailbox for everything he/she writes
- X
- X:Ac # Note the 'c' again
- X! my_other_friend # Forward everything Myfriend writes to my_other_friend
- X
- X:1Ac
- X^Subject:.*jokes
- X! my_third_friend # Forward everything Myfriend writes about jokes
- X # to my_third_friend
- X
- X:2A
- X^Subject:.*parties
- X!beach
- X! my_third_friend # Forward everything Myfriend writes about parties,
- X # except beach parties, to my_third_friend
- X
- X:A # Provide a mail sink, in order to fake procmail into
- X/dev/null # believing that the mail was absorbed/delivered,
- X # even if the mail was about beach parties :-).
- X # This is not the best solution though, better would be to
- X # rearrange these last five recipes so that the current
- X # number one or two is last, the current number five can be
- X # omitted then.
- X
- X ---
- END_OF_FILE
- if test 7409 -ne `wc -c <'procmail/examples/advanced'`; then
- echo shar: \"'procmail/examples/advanced'\" unpacked with wrong size!
- fi
- # end of 'procmail/examples/advanced'
- fi
- if test -f 'procmail/lockfile.c' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'procmail/lockfile.c'\"
- else
- echo shar: Extracting \"'procmail/lockfile.c'\" \(2781 characters\)
- sed "s/^X//" >'procmail/lockfile.c' <<'END_OF_FILE'
- X/************************************************************************
- X * lockfile.c a conditional semaphore-file creator *
- X * *
- X * Seems to be perfect. *
- X * *
- X * Created by S.R.van den Berg, The Netherlands *
- X * This file can be freely copied for any use. *
- X ************************************************************************/
- X#ifdef RCS
- Xstatic char rcsid[]="$Id: lockfile.c,v 2.8 1991/10/22 15:31:26 berg Rel $";
- X#endif
- Xstatic char rcsdate[]="$Date: 1991/10/22 15:31:26 $";
- X#include "config.h" /* overkill, I know, only need DIRSEP */
- X#include "includes.h"
- X#include "exopen.h"
- X
- Xvolatile int exitflag;
- Xpid_t thepid;
- Xconst char dirsep[]=DIRSEP;
- X
- Xvoid failure()
- X{ exitflag=1;
- X}
- X
- Xmain(argc,argv)const int argc;const char*argv[];
- X{ const char**p,*cp;int sleepsec,retries,invert,force,suspend,retval=0;
- X static char usage[]=
- X "Usage: lockfile -nnn | -rnnn | -! | -lnnn | -snnn | file ...\n";
- X sleepsec=8;force=retries=invert=0;suspend=16;thepid=getpid();
- X if(argc<2)
- X { putse(usage);return EX_USAGE;
- X }
- Xagain:
- X p=argv+1;signal(SIGHUP,failure);signal(SIGINT,failure);
- X signal(SIGQUIT,failure);signal(SIGTERM,failure);
- X while(*p)
- X if(*(cp= *p++)=='-')
- X switch(cp[1])
- X { case '!':invert=1;break;
- X case 'r':retries=strtol(cp+2,(char**)0,10);break;
- X case 'l':force=strtol(cp+2,(char**)0,10);break;
- X case 's':suspend=strtol(cp+2,(char**)0,10);break;
- X default:
- X if(cp[1]-'0'>(unsigned)9)
- X { putse(usage);retval=EX_USAGE;goto failurel;
- X }
- X if(sleepsec>=0)
- X sleepsec=strtol(cp+1,(char**)0,10);
- X }
- X else if(sleepsec<0)
- X unlink(cp);
- X else
- X { while(0>NFSxopen(cp))
- X { struct stat buf;time_t t;
- X if(exitflag||retries==1)
- X {
- Xfailurel: sleepsec= -1;p[-1]=0;goto again;
- X }
- X if(force&&(t=time((time_t*)0),!stat(cp,&buf))&&force<t-buf.st_mtime)
- X { unlink(cp);putse("lockfile: Forcing lock on \"");putse(cp);
- X putse("\"\n");sleep(suspend);
- X }
- X else
- X sleep(sleepsec);
- X if(retries)
- X retries--;
- X }
- X }
- X return retval?retval:invert^(sleepsec<0)?EX_CANTCREAT:EX_OK;
- X}
- X
- Xputse(a)char*a;
- X{ char*b;
- X b=a-1;
- X while(*++b);
- X write(STDERR,a,(size_t)(b-a));
- X}
- X
- XNFSxopen(name)char*name;
- X{ char*p,*q;int j= -1,i;
- X for(q=name;p=strpbrk(q,dirsep);q=p+1);
- X i=q-name;
- X if(!(p=malloc(i+UNIQnamelen)))
- X return exitflag=1;
- X strncpy(p,name,i);
- X if(unique(p,p+i,0))
- X j=myrename(p,name);
- X free(p);return j;
- X}
- X
- Xvoid*tmalloc(len)const size_t len; /* stub */
- X{ return malloc(len);
- X}
- X
- Xropen(name,mode,mask)const char*const name;const int mode;const mode_t mask;
- X{ return open(name,mode,mask); /* stub */
- X}
- X
- Xrclose(fd)const int fd; /* stub */
- X{ return close(fd);
- X}
- X
- Xwriteerr(a)const char*const a; /* stub */
- X{
- X}
- END_OF_FILE
- if test 2781 -ne `wc -c <'procmail/lockfile.c'`; then
- echo shar: \"'procmail/lockfile.c'\" unpacked with wrong size!
- fi
- # end of 'procmail/lockfile.c'
- fi
- if test -f 'procmail/man/formail.man' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'procmail/man/formail.man'\"
- else
- echo shar: Extracting \"'procmail/man/formail.man'\" \(5362 characters\)
- sed "s/^X//" >'procmail/man/formail.man' <<'END_OF_FILE'
- X.de Id
- X.ds Rv \\$3
- X.ds Dt \\$4
- X..
- X.Id $Id: formail.man,v 2.8 1991/10/18 15:53:26 berg Rel $
- X.de Sh
- X.br
- X.ne 9
- X.SH "\\$1"
- X..
- X.de Ss
- X.br
- X.ne 9
- X.SS "\\$1"
- X..
- X.de Tp
- X.br
- X.ne 9
- X.TP "\\$1"
- X..
- X.TH FORMAIL 1 \*(Dt BuGless
- X.SH NAME
- Xformail \- mail (re)formatter
- X.SH SYNOPSIS
- X.B formail
- X[
- X.I "\fB\+FM_SKIP+\fPskip"
- X] [
- X.I "\fB\+FM_TOTAL+\fPtotal"
- X] [
- X.B \-+FM_BOGUS++FM_FORCE++FM_REPLY++FM_KEEPB++FM_TRUST++FM_NOWAIT++FM_EVERY++FM_DIGEST++FM_QUIET+
- X]
- X.if n .ti +0.5i
- X[
- X.B \-+FM_REN_INSERT+
- X.I header field
- X] [
- X.B \-+FM_DEL_INSERT+
- X.I header field
- X]
- X.if n .ti +0.5i
- X[
- X.B \-+FM_SPLIT+
- X.I command
- X.I arg
- X\&.\|.\|.
- X]
- X.Sh DESCRIPTION
- X.LP
- X.B formail
- Xis a filter that can be used to force mail into mailbox format, perform real
- Xrigorous `+FROM+' escaping, generate auto-replying headers, do simple
- Xheader munging or split up a
- Xmailbox/digest/articles file. The mail/mailbox/article contents will be
- Xexpected on stdin.
- X.LP
- XIf formail is supposed to determine the sender of the mail, but is unable
- Xto find any, it will substitute `+UNKNOWN+'.
- X.LP
- XIf formail is started without any command line options, it will force any
- Xmail coming from stdin into mailbox format and will escape
- X.B all
- Xbogus `+FROM+' lines with a `+ESCAP+'.
- X.Sh OPTIONS
- X.Tp 0.5i
- X.B \-+FM_BOGUS+
- XDon't escape any bogus mailbox headers (i.e. lines starting with `+FROM+').
- X.Tp
- X.B \-+FM_FORCE+
- XForce formail to simply pass along any non-mailbox format (i.e. don't
- Xgenerate a `+FROM+' line as the first line).
- X.Tp
- X.B \-+FM_REPLY+
- XGenerate an auto-reply header.
- X.Tp
- X.B \-+FM_KEEPB+
- XWhen generating the auto-reply header, keep the body as well. If used
- Xtogether with the
- X.B \-+FM_BOGUS+
- Xoption then the body will not be escaped.
- X.Tp
- X.B \-+FM_TRUST+
- XTrust the sender to have used a valid return address in his header. This
- Xoption will be most usefull when generating auto-reply headers from news
- Xarticles. If this option is not turned on, formail tries to digest the most
- Xprobable valid return address itself.
- X.Tp
- X.B \-+FM_SPLIT+
- XThe input will be split up into seperate mail messages, and piped into
- Xa program one by one (a new program is started for every part).
- X.B \-+FM_SPLIT+
- Xhas to be the last option specified, the first argument following it
- Xis expected to be the name of a program, any other arguments will be passed
- Xalong to it.
- X.Tp
- X.B \-+FM_NOWAIT+
- XTell formail not to wait for every program to finish before starting the next.
- X.Tp
- X.B \-+FM_EVERY+
- XConsider every line starting with `+FROM+' to be the start of a new mail
- Xmessage (this is normally not the case).
- X.Tp
- X.B \-+FM_DIGEST+
- XEnables formail to split up digests/articles into their original parts.
- X.Tp
- X.B \-+FM_QUIET+
- XTells formail to ignore any write errors on stdout.
- X.Tp
- X.I "\fB\-+FM_REN_INSERT+\fP header field"
- XAppend a custom
- X.I header field
- Xonto the header, makes sure that any previous similar header fields
- Xare renamed by prepending an ``+OLD_PREFIX+'' prefix. If
- X.I header field
- Xconsists only of a field-name, it will not be appended.
- X.Tp
- X.I "\fB\-+FM_DEL_INSERT+\fP header field"
- XSame as
- X.B \-+FM_REN_INSERT+
- Xexcept that previous similar header fields are simply removed.
- X.Tp
- X.I "\fB\+FM_SKIP+\fPskip"
- XSkip the first
- X.I skip
- Xmessages while splitting.
- X.Tp
- X.I "\fB\+FM_TOTAL+\fPtotal"
- XOutput at most
- X.I total
- Xmessages while splitting.
- X.Sh EXAMPLES
- X.LP
- XTo use it as a general formatter in front of procmail include the following
- Xprocmail recipe at the top of your .procmailrc file:
- X.RS
- X:0
- X.br
- Xformail
- X.RE
- X.LP
- XTo split up a digest one usually uses:
- X.RS
- Xformail +FM_SKIP+1 -+FM_DIGEST++FM_SPLIT+ cat >>the_mailbox_of_your_choice
- X.RE
- Xor
- X.RS
- Xformail +FM_SKIP+1 -+FM_DIGEST++FM_SPLIT+ procmail
- X.RE
- X.LP
- XTo supersede the Reply-To: field in a header you could use:
- X.RS
- Xformail -+FM_REN_INSERT+ "Reply-To: foo@bar"
- X.RE
- X.Sh MISCELLANEOUS
- X.LP
- XThe regular expression that is used to find `real' postmarks is:
- X.RS
- X\\n\\n+FROM++[^\\t\\n ]+ +[^\\n\\t ]
- X.RE
- X.Sh "SEE ALSO"
- X.BR mail (1),
- X.BR binmail (1),
- X.BR sendmail (8),
- X.BR procmail (1),
- X.BR sh (1)
- X.Sh DIAGNOSTICS
- X.Tp 2.3i
- XCan't fork
- XToo many processes on this machine.
- X.Tp
- XCouldn't write to stdout
- XThe program that formail was trying to pipe into didn't accept all the data
- Xformail sent to it; this diagnostic can be disabled by the
- X.B \-+FM_QUIET+
- Xoption.
- X.Tp
- XFailed to execute "x"
- XProgram not in path, or not executable.
- X.Tp
- XFile table full
- XToo many open files on this machine.
- X.Tp
- XInvalid field-name: "x"
- XThe specified field-name "x" does not contain a colon.
- X.Sh WARNINGS
- X.LP
- XYou can save yourself and others a lot of mischief if you try to avoid using
- Xthis autoreply feature on mails coming through mailinglists. Depending
- Xon the format of the incoming mail (which in turn depends on both the
- Xoriginal sender's mail agent and the mailinglist setup) formail could
- Xdecide to generate an autoreply header that replies to the list (if
- Xthe original sender was carefull enough though, formail will be able to pick
- Xhis/her address, instead of the list's). Now if the list is not intelligent
- Xenough (most aren't) this autoreply will be widely distributed.
- X.Sh BUGS
- X.LP
- Xformail does not do full RFC 822 parsing while generating a `+FROM+' or
- Xa `To: ' line, hence it can be fooled by some real tricky escaped/quoted
- Xstrings with `<', `>' or `(' characters in them.
- X.Sh AUTHOR
- X.LP
- XStephen R. van den Berg at RWTH-Aachen, Germany
- X.RS
- Xberg@messua.informatik.rwth-aachen.de
- X.br
- Xberg@physik.tu-muenchen.de
- X.RE
- END_OF_FILE
- if test 5362 -ne `wc -c <'procmail/man/formail.man'`; then
- echo shar: \"'procmail/man/formail.man'\" unpacked with wrong size!
- fi
- # end of 'procmail/man/formail.man'
- fi
- if test -f 'procmail/nonint.c' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'procmail/nonint.c'\"
- else
- echo shar: Extracting \"'procmail/nonint.c'\" \(7124 characters\)
- sed "s/^X//" >'procmail/nonint.c' <<'END_OF_FILE'
- X/************************************************************************
- X * Collection of routines that don't return int *
- X * *
- X * Copyright (c) 1990-1991, S.R.van den Berg, The Netherlands *
- X * The sources can be freely copied for non-commercial use. *
- X * #include "README" *
- X * *
- X ************************************************************************/
- X#ifdef RCS
- Xstatic char rcsid[]="$Id: nonint.c,v 2.8 1991/10/18 15:33:23 berg Rel $";
- X#endif
- X#include "config.h"
- X#include "procmail.h"
- X
- X#define nomemretry noresretry
- X#define noforkretry noresretry
- X
- Xvoid*tmalloc(len)const size_t len; /* this malloc can survive a temporary */
- X{ void*p;int i; /* "out of swap space" condition */
- X if(p=malloc(len))
- X return p;
- X if(p=malloc(1))
- X free(p); /* works on some systems with latent free */
- X for(lcking=2,i=nomemretry;i<0||i--;)
- X { suspend(); /* problems? don't panic, wait a few secs till */
- X if(p=malloc(len)) /* some other process has paniced (and died 8-) */
- X { lcking=0;return p;
- X }
- X }
- X nomemerr();
- X}
- X
- Xvoid*trealloc(old,len)void*const old;const size_t len;
- X{ void*p;int i;
- X if(p=realloc(old,len))
- X return p; /* for comment see tmalloc above */
- X if(p=malloc(1))
- X free(p);
- X for(lcking=2,i=nomemretry;i<0||i--;)
- X { suspend();
- X if(p=realloc(old,len))
- X { lcking=0;return p;
- X }
- X }
- X nomemerr();
- X}
- X /* line buffered to keep concurrent entries untangled */
- Xlog(new)const char*const new;
- X{ int lnew,i;static lold;static char*old;char*p;
- X if(lnew=strlen(new)) /* anything? */
- X {
- X#ifndef O_CREAT
- X lseek(STDERR,0L,SEEK_END); /* locking should be done actually */
- X#endif
- X if(nextexit)
- X goto direct; /* carefull, in terminate code */
- X i=lold+lnew;
- X if(p=lold?realloc(old,i):malloc(i)) /* unshelled malloc */
- X { memmove((old=p)+lold,new,(size_t)lnew); /* append */
- X if(p[(lold=i)-1]=='\n') /* EOL? */
- X { rwrite(STDERR,p,i);lold=0;free(p); /* flush the line(s) */
- X }
- X }
- X else /* no memory, force flush */
- X { if(lold)
- X { rwrite(STDERR,old,i);lold=0;free(old);
- X }
- Xdirect: rwrite(STDERR,new,lnew);
- X }
- X }
- X}
- X
- X#include "shell.h"
- X
- Xpid_t sfork() /* this fork can survive a temporary */
- X{ pid_t i;int r; /* "process table full" condition */
- X r=noforkretry;
- X while((i=fork())==-1)
- X { lcking=3;
- X if(!(r<0||r--))
- X break;
- X suspend();
- X }
- X lcking=0;return i;
- X}
- X
- Xextern char*lastexec,*backblock; /* see retint.c for comment */
- Xextern long backlen;
- Xextern pid_t pidfilt,pidchild;
- Xextern pbackfd[2];
- X
- Xvoid sterminate()
- X{ static const char*const msg[]={newline,0,"memory\n","fork\n",
- X "file descriptor\n","hard lock\n"};
- X ignoreterm();
- X if(pidchild>0) /* don't kill what is not ours, we might be root */
- X kill(pidchild,SIGTERM);
- X if(!nextexit)
- X { nextexit=1;log("Terminating prematurely");
- X if(1!=lcking)
- X { if(1<lcking)
- X log(whilstwfor);
- X log(msg[lcking]);terminate();
- X }
- X }
- X}
- X
- Xvoid stermchild()
- X{ if(pidfilt>0) /* don't kill what is not ours, we might be root */
- X kill(pidfilt,SIGTERM);
- X log("Rescue of unfiltered data ");
- X if(dump(PWRB,backblock,backlen)) /* pump back the data via the backpipe */
- X log("failed\n");
- X else
- X log("succeeded\n");
- X exit(EX_UNAVAILABLE);
- X}
- X
- Xvoid ftimeout()
- X{ alarm(0);alrmtime=0;
- X if(pidchild>0&&!kill(pidchild,SIGTERM)) /* carefull, killing again */
- X { log("Timeout, terminating");logqnl(lastexec);
- X }
- X signal(SIGALRM,ftimeout);
- X}
- X
- Xlong dump(s,source,len)const int s;const char*source;long len;
- X{ int i;
- X if(s>=0)
- X { lockfd(s);lastdump=len;mboxseparator(s); /* prepend optional separator */
- X#ifndef O_CREAT
- X lseek(s,0L,SEEK_END);
- X#endif
- X while(i=rwrite(s,source,BLKSIZ<len?BLKSIZ:(int)len))
- X { if(i<0)
- X { i=0;goto writefin;
- X }
- X len-=i;source+=i;
- X }
- X if(!len&&(lastdump<2||!(source[-1]=='\n'&&source[-2]=='\n')))
- X lastdump++,rwrite(s,newline,1); /* message always ends with a */
- X mboxseparator(s); /* newline and an optional custom separator */
- Xwritefin:
- X unlockfd();rclose(s);return ignwerr?(ignwerr=0):len-i;
- X }
- X return len?len:-1; /* return an error even if nothing was to be sent */
- X}
- X
- Xlong pipin(line,source,len)char*const line;char*source;long len;
- X{ int poutfd[2];
- X rpipe(poutfd);
- X if(!(pidchild=sfork())) /* spawn program */
- X { rclose(PWRO);rclose(rc);getstdin(PRDO);callnewprog(line);
- X }
- X rclose(PRDO);
- X if(forkerr(pidchild,line))
- X return 1;
- X if(len=dump(PWRO,source,len)) /* dump mail in the pipe */
- X writeerr(line); /* pipe was shut in our face, get mad */
- X if(pwait&&waitfor(pidchild)!=EX_OK) /* optionally check the exitcode */
- X { progerr(line);len=1;
- X }
- X pidchild=0;
- X if(!sh)
- X concatenate(line);
- X lastfolder=cstr(lastfolder,line);return len;
- X}
- X
- Xchar*readdyn(bf,filled)char*bf;long*const filled;
- X{ int i;long oldsize;
- X oldsize= *filled;goto jumpin;
- X do
- X { *filled+=i; /* change listed buffer size */
- Xjumpin:
- X bf=realloc(bf,*filled+BLKSIZ); /* dynamically adjust the buffer size */
- Xjumpback:;
- X }
- X while(0<(i=rread(STDIN,bf+*filled,BLKSIZ))); /* read mail */
- X if(pidchild>0)
- X { pidchild=0;getstdin(PRDB); /* filter ready, get backpipe */
- X if(1==rread(STDIN,buf,1)) /* backup pipe closed? */
- X { bf=realloc(bf,(*filled=oldsize+1)+BLKSIZ);bf[oldsize]= *buf;
- X goto jumpback; /* filter goofed, rescue data */
- X }
- X }
- X pidchild=0; /* child must be gone by now */
- X if(!*filled)
- X return realloc(bf,1); /* +1 for housekeeping purposes */
- X return realloc(bf,*filled+1); /* minimise the buffer space */
- X}
- X
- Xchar*fromprog(name,dest)char*const name;char*dest;
- X{ int pinfd[2];long nls;
- X rpipe(pinfd);inittmout(name);
- X if(!(pidchild=sfork())) /* spawn program */
- X { rclose(STDIN);opena(devnull);rclose(PRDI);rclose(rc);rclose(STDOUT);
- X rdup(PWRI);rclose(PWRI);callnewprog(name);
- X }
- X rclose(PWRI);nls=0;
- X if(!forkerr(pidchild,name))
- X { while(0<rread(PRDI,dest,1)) /* read its lips */
- X if(*dest=='\n') /* carefull with newlines */
- X nls++; /* trailing newlines should be discarded */
- X else
- X { if(nls)
- X for(dest[nls]= *dest;*dest++='\n',--nls;); /* fill them in */
- X dest++;
- X }
- X waitfor(pidchild);
- X }
- X pidchild=0;rclose(PRDI);*dest='\0';return dest;
- X}
- X
- Xchar*cat(a,b)const char*const a,*const b;
- X{ return strcat(strcpy(buf,a),b);
- X}
- X
- Xchar*tstrdup(a)const char*const a;
- X{ int i;
- X i=strlen(a)+1;return tmemmove(malloc(i),a,i);
- X}
- X
- Xconst char*tgetenv(a)const char*const a;
- X{ const char*b;
- X return(b=getenv(a))?b:"";
- X}
- X
- Xchar*cstr(a,b)const char*const a,*const b; /* dynamic buffer management */
- X{ if(a)
- X free(a);
- X return tstrdup(b);
- X}
- X
- Xlong renvint(i,env)const long i;const char*const env;
- X{ const char*p;long t;
- X t=strtol(env,&p,10);return p==env?i:t; /* parse it like a decimal nr */
- X}
- X
- Xchar*egrepin(expr,source,len,casesens)const char*expr,*source;
- X const long len;
- X{ source=regexec(expr=regcomp(expr,!casesens),source,len,!casesens);free(expr);
- X return(char*)source;
- X}
- END_OF_FILE
- if test 7124 -ne `wc -c <'procmail/nonint.c'`; then
- echo shar: \"'procmail/nonint.c'\" unpacked with wrong size!
- fi
- # end of 'procmail/nonint.c'
- fi
- echo shar: End of archive 3 \(of 4\).
- cp /dev/null ark3isdone
- MISSING=""
- for I in 1 2 3 4 ; do
- if test ! -f ark${I}isdone ; then
- MISSING="${MISSING} ${I}"
- fi
- done
- if test "${MISSING}" = "" ; then
- echo You have unpacked all 4 archives.
- rm -f ark[1-9]isdone
- else
- echo You still must unpack the following archives:
- echo " " ${MISSING}
- fi
- exit 0
- exit 0 # Just in case...
- --
- Kent Landfield INTERNET: kent@sparky.IMD.Sterling.COM
- Sterling Software, IMD UUCP: uunet!sparky!kent
- Phone: (402) 291-8300 FAX: (402) 291-4362
- Please send comp.sources.misc-related mail to kent@uunet.uu.net.
-