home *** CD-ROM | disk | FTP | other *** search
- From: berg@pool.informatik.rwth-aachen.de (Stephen R. van den Berg)
- Newsgroups: comp.sources.misc
- Subject: v43i062: procmail - mail processing package v3.03, Part07/10
- Date: 5 Jul 1994 20:50:14 -0500
- Organization: Sterling Software
- Sender: kent@sparky.sterling.com
- Approved: kent@sparky.sterling.com
- Message-ID: <2vd2km$ibo@sparky.sterling.com>
- X-Md4-Signature: c65bf62b00583bb4815408464adda8da
-
- Submitted-by: berg@pool.informatik.rwth-aachen.de (Stephen R. van den Berg)
- Posting-number: Volume 43, Issue 62
- Archive-name: procmail/part07
- Environment: sendmail, ZMailer, smail, MMDF, mailsurr, UNIX, POSIX
- Supersedes: procmail: Volume 38, Issue 19-31
-
- #! /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".
- # Contents: procmail-3.03/FAQ procmail-3.03/examples/advanced
- # procmail-3.03/initmake procmail-3.03/src/includes.h
- # procmail-3.03/src/lockfile.c procmail-3.03/src/setid.c
- # Wrapped by kent@sparky on Tue Jul 5 20:42:14 1994
- PATH=/bin:/usr/bin:/usr/ucb:/usr/local/bin:/usr/lbin:$PATH ; export PATH
- echo If this archive is complete, you will see the following message:
- echo ' "shar: End of archive 7 (of 10)."'
- if test -f 'procmail-3.03/FAQ' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'procmail-3.03/FAQ'\"
- else
- echo shar: Extracting \"'procmail-3.03/FAQ'\" \(9416 characters\)
- sed "s/^X//" >'procmail-3.03/FAQ' <<'END_OF_FILE'
- X------------------------------------------------------------------------------
- X---------------------- Frequently Asked Questions ----------------------------
- X------------------------------------------------------------------------------
- X
- X1. How do I go about setting up a mailinglist or a mail-archive server?
- X
- X Look in the SmartList directory, start reading the INTRO file,
- X it describes it in detail and should get you started.
- 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 MMDF users should note that they need a .maildelivery file *instead*
- X of a .forward file (see the man page for more detailed information).
- X
- X If however, procmail has been integrated in the maildelivery system
- X (i.e. if your system administrator installed it that way, ask him/her),
- X then you no longer need the .forward files in your home directory,
- X having a .procmailrc file will suffice.
- X
- X On some systems .forward files are not checked.
- X It might be possible that your system supports a command like:
- X mail -F "|/usr/local/bin/procmail"
- X to set up forwarding to a program.
- X If that doesn't seem to work it might be worth trying to put a line
- X looking like this:
- X Forward to |/usr/local/bin/procmail
- X or if that doesn't work, try:
- X Pipe to /usr/local/bin/procmail
- X as the only line in your mail spool file (e.g. /usr/mail/$LOGNAME), as
- X well as doing a "chmod 06660 /usr/mail/$LOGNAME". For more information
- X on such systems, do a "man mail".
- X
- X If all of this doesn't work, procmail can be called on a periodical
- X basis, either via "cron", "at" or whenever you start reading mail (or
- X log in). For a sample script look in the NOTES section of the
- X procmail(1) 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. In any case, if this should occur, I'd
- X appreciate a mail from you (so I can try to fix the autoconf script
- X to recognise your compiler correctly as well).
- X
- X6. The compiler refuses to compile regexp.c, what is the problem?
- X
- X Try compiling that module with optimisation turned off.
- X
- X7. 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
- X8. Where do I look for examples about:
- X One home directory, several machine architectures?
- X Procmail as an integrated local mail delivery agent? (generic,
- X sendmail, ZMailer, smail, SysV mailsurr)
- X Changing the mail spool directory to $HOME for all users
- X Security considerations (when installing procmail suid root)
- X
- X Well, this probably is your lucky day :-), all these topics are covered
- X in the examples/advanced file.
- X
- X Other examples (e.g. for autoreplies) are most likely to be found by
- X typing: man procmailex
- X
- X9. How do I use procmail as a general mail filter inside sendmail?
- X
- X See EXAMPLES section of the procmail(1) man page.
- X
- X10. Why do I have to insert my login name after the '#' in the .forward or
- X .maildelivery file?
- X
- X Some mailers `optimise' maildelivery and take out duplicates from
- X Cc:, Bcc: and alias lists before delivery. If two or more persons on
- X such a list would have identical .forward files, then the mailer will
- X eliminate all but one. Adding a `#' with your login name following
- X it will make the .forward files unique, and will ensure that the mailer
- X doesn't optimise away some addresses.
- X
- X11. How do I view the man pages?
- X
- X If the man(1) program on your system understands the MANPATH
- X environment variable, make sure that the installation directory listed
- X in the Makefile for the manpages is included in your MANPATH. If your
- X man program does not support MANPATH, make sure that the man pages
- X are installed in one of the standard man directories, like under
- X /usr/man. If you do not want to install the man pages before viewing
- X them, you can view an individual man file by typing something like:
- X nroff -man procmail.1 | more
- X
- X12. The leading From_ line on all my arriving mail shows the wrong time.
- X Before putting procmail in the .forward file everything was OK.
- X
- X This is a known bug in sendmail-5.65c+IDA. The real fix would be
- X to upgrade to sendmail 6.x or later. For a quick fix, see the
- X procmailex man page.
- X
- X13. When sending mail to someone with procmail in his/her .forward I sometimes
- X get back an error saying: "Cannot mail directly to programs."
- X
- X This is a known bug in some older sendmails that mistakenly drop
- X their root privileges when they are given the -t flag. Either
- X make sure that your sendmail always forwards to a mailserver first or
- X upgrade to sendmail 6.x or later.
- X
- X14. My mailtool sometimes reports that it is confused about the state of
- X the mailbox, or I get "Couldn't unlock" errors from procmail now and then.
- X
- X This is a known bug in the OpenLook mailtool. It holds on to the
- X kernel lock on the mail-spoolfile most of the time, and releases
- X this lock when it shouldn't. Either ask for a bugfix from your
- X vendor (I'm not sure if a bugfix exists), or make sure that during
- X the compilation of procmail both the fcntl() and lockf() locking
- X methods are disabled (see config.h).
- X
- X15. I sometimes get these `Lock failure on "/usr/mail/$LOGNAME.lock"' errors
- X from procmail. What do I do about it?
- X
- X The problem here is that as long as procmail has not read a
- X $HOME/.procmailrc file, it can hang on to the sgid mail permission
- X (which it needs in order to create a lockfile in /usr/mail).
- X I.e. if procmail delivers mail to a user without a $HOME/.procmailrc
- X file, procmail *can* (and does) use the /usr/mail/$LOGNAME.lock file.
- X
- X If, however, it finds a $HOME/.procmailrc file, procmail has to let go
- X of the sgid mail permission because otherwise any ordinary user could
- X abuse that.
- X
- X There are several solutions to this problem:
- X - Some systems support the sticky bit on directories (when set only
- X allows the owner of a file in that directory to rename or remove
- X it). This enables you to make /usr/spool/mail drwxrwxrwt. It is
- X thus effectively world writable, but all the mailboxes in it are
- X protected because only the mailbox owner can remove or rename it.
- X - If your system did not exhibit the !@#$%^&* POSIX semantics for
- X setgid(), procmail would have been able to switch back and forth
- X between group mail and the group the recipient belongs to without
- X creating security holes.
- X - If your system supported setrgid() or setregid() or setresgid()
- X with BSD semantics, procmail would have been able to switch...
- X (see the previous point).
- X - You could simply put the following at the end of your .procmailrc
- X file:
- X
- X LOCKFILE # removes any preexisting lockfile
- X LOG=`lockfile $DEFAULT$LOCKEXT`
- X TRAP="rm -f $DEFAULT$LOCKEXT"
- X :0
- X $DEFAULT
- X
- X - You could, instead of using /usr/mail/$LOGNAME, use a file below
- X your home directory as your default mailbox.
- X - Or, you could still use /usr/mail/$LOGNAME as the mailbox, but
- X simply instruct procmail to use a different lockfile. This can
- X be achieved by putting following recipe at the bottom of
- X your .procmailrc file:
- X
- X :0:$HOME/.lockmail
- X $DEFAULT
- X
- X You have to make sure that all other programs that update your
- X system mailbox will be using the same lockfile of course.
- X - You can ignore the problem if you know that both your mail reader
- X and procmail use an overlapping kernel locking method.
- X
- X
- X16. 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. Or, alternatively, you could submit
- X your question to the procmail mailinglist (see the man page for the
- X exact addresses, or try "procmail -v", or look in the patchlevel.h
- X file).
- END_OF_FILE
- if test 9416 -ne `wc -c <'procmail-3.03/FAQ'`; then
- echo shar: \"'procmail-3.03/FAQ'\" unpacked with wrong size!
- fi
- # end of 'procmail-3.03/FAQ'
- fi
- if test -f 'procmail-3.03/examples/advanced' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'procmail-3.03/examples/advanced'\"
- else
- echo shar: Extracting \"'procmail-3.03/examples/advanced'\" \(9931 characters\)
- sed "s/^X//" >'procmail-3.03/examples/advanced' <<'END_OF_FILE'
- X
- XDiscusses:
- X 1. One home directory, several machine architectures
- X 2. Procmail as an integrated local mail delivery agent
- X 2a.Special directions for sites with sendmail
- X 2b.Special directions for sites with ZMailer
- X 2c.Special directions for sites with smail
- X 2d.Special directions for sites with SysV /etc/mail/mailsurr
- X 3. Changing the mail spool directory to $HOME for all users
- X 4. Security considerations (when installing procmail suid root)
- X
- X ---
- X
- X1. One home directory, several machine architectures
- X -------------------------------------------------
- X
- XFor users that have the very same home directory on machines with differing
- Xarchitectures (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 ||exit 75 #YOUR_USERNAME"
- X
- Xor alternatively:
- X
- X"|IFS=' '&& exec /home/berg/bin.`/usr/bin/arch`/procmail ||exit 75 #YOUR_USERNAME"
- 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
- XIf, on the other hand, you have to log in to every machine to read mail
- Xarrived for you on that machine, a different solution might be more
- Xappropriate.
- X
- XIf you have sendmail v6.xx and later, you simply create two .forward files.
- XIn the .forward file you put:
- X
- XYOUR_LOGIN_NAME@your.favourite.machine
- X
- XAnd, in a second file named .forward.your.favourite.machine you put:
- X
- X"|exec /usr/local/bin/procmail #YOUR_USERNAME"
- X
- XIf you have an older sendmail, you could put something like the following two
- Xlines in your .forward file:
- X
- XYOUR_LOGIN_NAME@your.favourite.machine
- X"|IFS=' ';test .`/bin/uname -n` != .your.favourite.machine || exec /usr/local/bin/procmail #YOUR_USERNAME"
- X
- XThe leading dots are important. Check what `/bin/uname -n` returns on
- Xyour.favourite.machine, and substitute that for your.favourite.machine in the
- Xsample .forward file. If your system does not have /bin/uname, check if there
- Xis a /bin/hostname.
- X
- XWith some sendmails, the last suggestion causes you to get a superfluous
- Xcopy in the system mailfolder. If that is the case, you'll have to change
- Xyour .forward to something like:
- X
- X"|IFS=' ';if test .`/bin/uname -n` == .your.favourite.machine ; then exec /usr/local/bin/procmail; else exec /usr/lib/sendmail -oi YOUR_LOGIN_NAME@your.favourite.machine; fi"
- 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
- XThe generic way to accomplish this (works with sendmail, smail and any other
- Xmail system that uses a local mail delivery program that takes the mail-
- Xto-be-delivered on stdin and the recipient(s) on the command line, with or
- Xwithout the "-d" option) is this:
- X
- XMove your current local mail delivery agent (e.g. /bin/mail, /bin/lmail,
- X/usr/lib/mail/mail.local, etc.) out of the way, and create a (symbolic or hard)
- Xlink from there to procmail, as in "ln /usr/local/bin/procmail /bin/lmail".
- X
- XBeware, however, that if you are using this method, /bin/mail can *only* be
- Xused to deliver mail. On many systems /bin/mail has several uses (also to
- Xread mail or check for mail). So, it would definitely be preferred if you
- Xcould edit the invocation of /bin/mail from within your mail transport agent
- Xto invoke procmail instead (with appropriate flags, if needed). Special
- Xdirections detailing this process for some of the more popular MTAs are
- Xincluded in subsections below.
- X
- XIn addition to needing root privileges upon startup, on some systems procmail
- Xneeds to be sgid to daemon or mail. One way to check is by looking at the
- Xcurrent mail delivery agent (usually /bin/mail) and to mimic its permissions,
- Xowner and group. If you're not quite sure, just type "make recommend" and some
- Xsuitable recommendations will be made for your particular environment.
- X
- XThe same might apply to the "lockfile" program, in order for it to be able to
- Xcreate and unlink lockfiles in the mail spool directory it might need to be
- Xsgid to daemon or mail, not to worry however, "lockfile" will not enable users
- Xto abuse the sgid/suid-ness.
- X
- X ---
- X
- X2a.Special directions for sites with sendmail
- X ------------------------------------------
- X
- XThe following lines should take the place of the standard Mlocal definition in
- Xyour sendmail.cf:
- X
- XMlocal, P=/usr/local/bin/procmail, F=lsSDFMhPfn, S=10, R=20,
- X A=procmail -a $h -d $u
- X
- XAs for the fields "S=10, R=20": if your system uses others or none on the
- Xcurrent Mlocal definition, use those instead of "S=10, R=20".
- X
- XTo impose a 2MB limit on mails, you could add a `Maxsize=' field like in:
- X
- XMlocal, P=/usr/local/bin/procmail, F=lsSDFMhPfn, S=10, R=20, M=2000000
- X A=procmail -a $h -d $u
- X
- XIn order to take advantage of the meta argument that can be passed to
- Xprocmail you'd have to change to $#local mailer rule to set the $@ host name
- X(which will be substituted for $h in the mailer definition).
- X
- XSince you are editing the sendmail.cf file now anyway, you might as well setup
- Xan extra `procmail' mailer. This Mprocmail can then be used as a general mail
- Xfilter. For more information, see EXAMPLES section the procmail(1) man page.
- X
- X ---
- X
- X2b.Special directions for sites with ZMailer
- X -----------------------------------------
- X
- XThe following line should be inserted into (or take the place of any previous
- Xlocal definition in) your sm.conf file for the Transport Agent:
- X
- Xlocal sSPfn /usr/local/bin/procmail procmail -a $h -d $u
- X
- X ---
- X
- X2c.Special directions for sites with smail
- X ---------------------------------------
- X
- XFor smail 2.x users there are two options:
- X i. Move the current local-mail-delivery program (probably /bin/lmail) out of
- X the way, make a symbolic or hard link from procmail to the name of that
- X program (e.g. "ln /usr/local/bin/procmail /bin/lmail")
- X ii.Make sure the following macro is defined in src/defs.h:
- X #define LMAIL(frm,sys) "/usr/local/bin/procmail -d"
- X
- XFor smail 3.x users there are also two options:
- X i. The same solution as for smail 2.x (however, method ii is preferred)
- X ii.Replace any existing "local"-entry in the /usr/lib/smail/transports file
- X (create one, if need be) with the following two lines:
- X
- Xlocal: return_path, local, from, driver=pipe; user=root,
- X cmd="/usr/local/bin/procmail -d $($user$)"
- X
- X ---
- X
- X2d.Special directions for sites with SysV /etc/mail/mailsurr
- X ---------------------------------------------------------
- X
- XSome systems use a SysV /bin/mail that supports mailsurr. To interface
- Xprocmail with mailsurr the following two lines should be inserted in the
- X/etc/mail/mailsurr file (preferably at the bottom):
- X
- X'(.+)' '([^@!]+)' '<S=0;C=67,75;F=*;
- X /usr/local/bin/procmail -f \\1 -d \\2'
- X
- X ---
- X
- X3. Changing the mail spool directory to $HOME for all users
- X --------------------------------------------------------
- X
- XThere are many different reasons why more and more sites decide not to
- Xstore mail in /usr/spool/mail or /usr/mail anymore.
- XSome of the obvious advantages when storing mail in the recipient's home
- Xdirectory are:
- X - Mail is automatically subject to the user's quota limitations.
- X - Often there is more room on the home partition(s) than on that
- X one /usr/mail partition.
- X
- XThe quota limitations also apply to /usr/spool/mail or /usr/mail if procmail
- Xdoes the delivery. These quota limitations often do not work with the
- Xregular /bin/mail since that usually writes the mailbox with root permissions
- X(eluding the quota restrictions).
- X
- XHowever, if you are going to install procmail as the integrated local
- Xdelivery agent, and you want mail to be delivered to, say, $HOME/.mail
- Xby default, this is what you have to do:
- X
- X Edit the procmail*/config.h file. Uncomment and possibly change
- X the SYSTEM_MBOX define. Procmail now delivers there by default.
- X
- X In order to make sure that normal mailtools can find the new
- X system mailboxes, you should make sure that every user has the
- X MAIL environment variable set to be equal to whatever you
- X defined SYSTEM_MBOX to be. Some braindamaged mail programs
- X do not pick up the MAIL environment variable, these either
- X have to be patched/recompiled or you have to create symbolic
- X links in /usr/mail to every person's new mailbox.
- X
- X ---
- X
- X4. Security considerations (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
- Xprivileges).
- 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
- XTo summarise, procmail will only behave better if made suid/sgid something, in
- Xfact, making procmail suid/sgid something will *improve* security on systems
- Xwhich have dynamically linked libraries.
- X
- X ---
- END_OF_FILE
- if test 9931 -ne `wc -c <'procmail-3.03/examples/advanced'`; then
- echo shar: \"'procmail-3.03/examples/advanced'\" unpacked with wrong size!
- fi
- # end of 'procmail-3.03/examples/advanced'
- fi
- if test -f 'procmail-3.03/initmake' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'procmail-3.03/initmake'\"
- else
- echo shar: Extracting \"'procmail-3.03/initmake'\" \(9335 characters\)
- sed "s/^X//" >'procmail-3.03/initmake' <<'END_OF_FILE'
- X#! /bin/sh
- X:
- X# Copyright (c) 1992-1994, S.R. van den Berg, The Netherlands
- X#$Id: initmake,v 1.53 1994/05/26 14:10:48 berg Exp $
- X
- Xif test -z "$IFS"
- Xthen IFS=" \
- X \
- X
- X"
- X export IFS
- Xfi
- X
- XPATH=.:$PATH
- XBSHELL=$1
- X
- XO="cd ."
- Xif $O
- Xthen
- X:
- Xelse
- X echo "Your BSHELL=$BSHELL seems to be severely handicapped."
- X case "$BSHELL" in
- X *zsh*) ;;
- X *) echo "(If I wouldn't know better, I'd say you're trying to sell"
- X echo "me a buggy zsh :-)" ;;
- X esac
- X echo "Please edit the Makefile and try setting BSHELL to a shell which"
- X echo "is more backwards compatible with a Bourne, Korn or POSIX shell."
- X exit 1
- Xfi
- X
- Xshift; MSHELL=$1
- Xshift; RM="$1"
- Xshift; MV="$1"
- Xshift; LN="$1"
- Xshift; SEARCHLIBS="$1"
- Xshift; LIBPATHS="$1"
- Xshift; DEVNULL=$1
- Xshift; MAKE="$1"
- Xshift; O=$1
- Xshift; CC="$1"
- Xshift; CFLAGS1="$1"
- Xshift; LDFLAGS1="$1"
- Xshift; BINSS="$1"
- Xshift; MANS1S="$1"
- Xshift; MANS5S="$1"
- Xshift; SUBDIRS="$1"
- Xshift; BINDIR="$1"
- X
- Xtest 1 != $# &&
- X echo "Don't start this script directly, use \`make init'" && exit 1
- X
- Xtest -z "$MSHELL" || SHELL=$MSHELL
- Xcase "$SHELL" in
- X *sh*)
- X case "$SHELL" in
- X *csh*) echo "Warning: really perverted make detected"; SHELL="";;
- X *zsh*) $RM src/_autotst
- X $SHELL <<HERE
- X O="echo test >src/_autotst"
- X exec 2>$DEVNULL
- X \$O
- XHERE
- X if test ! -f src/_autotst
- X then
- X echo "Warning: your $SHELL is broken, avoiding it"; SHELL=""
- X fi ;;
- X esac
- X if test ! -z "$SHELL"
- X then
- X $SHELL <<HERE
- X exec 2>$DEVNULL
- X echo test >src/_autotst
- X echo test >src/_autotst
- XHERE
- X if test $? = 1
- X then
- X echo "Warning: your $SHELL has noclobber turned on, avoiding it"
- X SHELL=""
- X fi
- X fi
- X $RM src/_autotst;;
- X *) echo "Warning: perverted make detected"; SHELL="";;
- Xesac
- Xtest -z "$SHELL" && SHELL=$BSHELL
- X
- Xexport SHELL PATH
- X
- XFGREP="fgrep" # POSIX, or not POSIX, that is the question...
- Xif test \^hello = "`echo '^hello' | grep -F '^hello' 2>&1`"
- Xthen FGREP="grep -F" # and POSIX it is!
- Xfi
- X
- Xecho hi | $FGREP hi >$DEVNULL
- Xt=$?
- Xecho ho | $FGREP hi >$DEVNULL
- Xf=$?
- Xif test 0 != $t -o 0 = $f
- Xthen
- X echo "Your \"$FGREP\" program seems to be incapable of returning a proper"
- X echo "exitvalue depending on the success of the search. This script can"
- X echo "not work without it."
- X exit 2
- Xfi
- X
- Xif test ! -z "$LD_LIBRARY_PATH"
- Xthen
- X echo '***************************** WARNING *********************************'
- X echo '* You seem to have set the LD_LIBRARY_PATH variable, this might cause *'
- X echo '* some trouble during the execution of this autoconf script. If the *'
- X echo '* the make does not finish by itself, do a: "make clean", *'
- X echo '* clear LD_LIBRARY_PATH from the environment, and start over. *'
- X echo '***************************** WARNING *********************************'
- Xfi
- X
- Xcd src # diving into the source directory ######
- X
- Xnewln=""
- X$RM _autotst.rrr _autotst
- Xecho hi >_autotst.rrr
- Xif $LN _autotst.rrr _autotst
- Xthen
- X:
- Xelse
- X $LN -s _autotst.rrr _autotst && LN="$LN -s" && newln=yes
- Xfi
- X
- Xcat >_autotst.c <<HERE
- Xmain()
- X{ return 0;
- X}
- XHERE
- X$RM _autotst.rrr _autotst.$O _autotst
- X
- Xcc=""
- X
- Xfor a in "$CC" cc gcc
- Xdo
- X echo $a $CFLAGS1 _autotst.c -o _autotst $LDFLAGS1 >>_autotst.rrr
- X test -z "$cc" -a ! -z "$a" &&
- X (exec >>_autotst.rrr 2>&1; $a $CFLAGS1 _autotst.c -o _autotst $LDFLAGS1) &&
- X cc="$a"
- X echo "::::" >>_autotst.rrr
- Xdone
- Xif test -z "$cc"
- Xthen
- X echo 2>&1 "Whoeaaa! There's something fishy going on here."
- X echo 2>&1 "You have a look and see if you detect anything uncanny:"
- X echo 2>&1 "-------------------------------------------------------"
- X cat 2>&1 _autotst.rrr
- X echo 2>&1 "-------------------------------------------------------"
- X echo 2>&1 "I suggest you take a look at the definition of CFLAGS* and CC"
- X echo 2>&1 "in the Makefile before you try make again."
- X exit 1
- Xfi
- X$RM _autotst.rrr _autotst.$O _autotst
- Xecho "$cc seems to work fine, using that as the C-compiler"
- X
- Xcat >_autotst.c <<HERE
- X#include <sys/types.h>
- X#include <stdio.h>
- X#include <sys/stat.h>
- Xmain()
- X{ struct stat buf;return!&buf;
- X}
- XHERE
- X
- XCFLAGS=""
- X
- Xcase "$CFLAGS1" in
- X *-D_POSIX_SOURCE*);;
- X *)
- X if $cc -c $CFLAGS1 _autotst.c >$DEVNULL 2>&1
- X then
- X :
- X else
- X $RM _autotst.$O
- X $cc -c $CFLAGS1 -D_POSIX_SOURCE _autotst.c >$DEVNULL 2>&1 &&
- X CFLAGS=" -D_POSIX_SOURCE"
- X fi;;
- Xesac
- X
- XLDFLAGSC=""
- X
- Xtest -f _autotst.$O || $cc -c $CFLAGS1 $CFLAGS _autotst.c >$DEVNULL 2>&1
- X$cc $CFLAGS1 $CFLAGS _autotst.$O -o _autotst $LDFLAGS1 -lc >_autotst.rrr 2>&1 \
- X && if grep "[\"']c['\"]" _autotst.rrr >$DEVNULL ||
- X fgrep libc _autotst.rrr >$DEVNULL
- X then
- X :
- X else
- X LDFLAGSC=" -lc"
- X fi
- X
- XLDFLAGS="$SEARCHLIBS"
- Xfirstrun=yes
- Xcheckpath=no
- X
- Xwhile $RM _autotst
- X $cc $CFLAGS1 $CFLAGS _autotst.$O -o _autotst $LDFLAGS1 $LDFLAGS \
- X $LDFLAGSC >_autotst.rrr 2>&1
- X test $firstrun = yes -o ! -f _autotst
- Xdo
- X set dummy $LDFLAGS
- X shift
- X echo 2>&1 " ...scanning for $# libraries..."
- X NEWLDFLAGS=""
- X for lib in `echo _dummy_ $LDFLAGS | sed -e s/-l//g`
- X do
- X if test _dummy_ != $lib
- X then
- X a=-l$lib
- X ( exec <_autotst.rrr
- X while read b
- X do
- X case ":$b:" in
- X *_autotst.$O*) ;;
- X *lib$lib[!a-z_]*|*$a[!a-z_]*|*[!a-z]$lib[!a-z_]*) exit 1;;
- X esac
- X done
- X exit 0
- X )
- X if test $? = 0
- X then
- X found=yes
- X if test $checkpath = yes
- X then
- X OLDIFS="$IFS"; IFS=":$IFS"
- X found=no
- X for libpath in $LIBPATHS $LD_LIBRARY_PATH
- X do
- X set $libpath/*lib$lib[A-Z.]*
- X test -f $1 && found=yes
- X done
- X IFS="$OLDIFS"
- X fi
- X test yes = $found && NEWLDFLAGS="$NEWLDFLAGS $a"
- X fi
- X fi
- X done
- X if test a"$LDFLAGS" = a"$NEWLDFLAGS"
- X then
- X if test $checkpath = yes
- X then
- X echo 2>&1 "Whoeaaa! There's something fishy going on here."
- X echo 2>&1 "You have a look and see if you detect anything uncanny:"
- X echo 2>&1 "*******************************************************"
- X cat 2>&1 _autotst.rrr
- X echo 2>&1 "*******************************************************"
- X echo 2>&1 \
- X "I suggest you take a look at the definition of LDFLAGS* and SEARCHLIBS"
- X echo 2>&1 "in the Makefile before you try make again."
- X echo 2>&1 \
- X "Also: write me a mail showing the errorlog you just generated."
- X echo 2>&1 "The errorlog can still be found in src/_autotst.rrr"
- X echo 2>&1 \
- X "It would be helpful if you could mention what machine and OS"
- X echo 2>&1 "you are trying to compile this on (uname -a). Thanks."
- X exit 1
- X fi
- X checkpath=yes
- X else
- X checkpath=no
- X fi
- X LDFLAGS="$NEWLDFLAGS"
- X firstrun=no
- Xdone
- X
- X$RM _autotst.$O _autotst.c _autotst
- Xcd .. # returning to the main procmail directory ######
- X
- XLDFLAGS="$LDFLAGS$LDFLAGSC"
- X
- Xtest -z "$CFLAGS" || echo "Added CFLAGS=$CFLAGS"
- Xtest -z "$LDFLAGS" || echo "Added LDFLAGS=$LDFLAGS"
- X
- Xfor a in $SUBDIRS
- Xdo
- X if test ! -f $a/Makefile.init
- X then
- X case "$LN" in
- X *-s*) cp $a/Makefile $a/Makefile.init ;;
- X *) $LN $a/Makefile $a/Makefile.init
- X $RM $a/Makefile
- X $LN $a/Makefile.init $a/Makefile ;;
- X esac
- X fi
- Xdone
- X
- Xtest -f Makefile.0 || sed -e '/^# Makefile - mark/,$ !d' <Makefile >Makefile.0
- Xsed -e '/^# Makefile - mark/,$ d' <Makefile >_Makefile
- Xecho "# Makefile.1 - mark, don't (re)move this, a sed script needs it
- X" >>_Makefile
- X
- Xtest a$SHELL != a$MSHELL && echo "SHELL = $SHELL" >>_Makefile
- Xecho "FGREP = $FGREP" >>_Makefile
- Xtest -z "$newln" || echo "LN = $LN" >>_Makefile
- Xtest -z "$MAKE" && echo "MAKE = make" >>_Makefile
- Xtest a"$cc" != a"$CC" && echo "CC = $cc" >>_Makefile
- X
- Xecho "CFLAGS = \$(CFLAGS1)$CFLAGS" >>_Makefile
- Xecho "LDFLAGS = \$(LDFLAGS1)$LDFLAGS" >>_Makefile
- Xecho >>_Makefile
- X
- XMANSS=""
- XMANS1=""
- XMANS5=""
- XMANS=""
- XNMANS=""
- XBINS=""
- XNBINS=""
- Xfor a in $MANS1S
- Xdo
- X MANSS="$MANSS $a.1"
- X MANS1="$MANS1 $a.\$(MAN1SUFFIX)"
- Xdone
- Xfor a in $MANS5S
- Xdo
- X MANSS="$MANSS $a.5"
- X MANS5="$MANS5 $a.\$(MAN5SUFFIX)"
- Xdone
- Xfor a in $MANSS
- Xdo
- X MANS="$MANS new/$a"
- X NMANS="$NMANS ../new/$a"
- Xdone
- Xfor a in $BINSS
- Xdo
- X BINS="$BINS new/$a"
- X NBINS="$NBINS ../new/$a"
- Xdone
- X
- Xecho "BINS=$BINS" >>_Makefile
- Xecho "MANS=$MANS" >>_Makefile
- Xecho "MANS1=$MANS1" >>_Makefile
- Xecho "MANS5=$MANS5" >>_Makefile
- Xecho "MANSS=$MANSS" >>_Makefile
- Xecho "NBINS=$NBINS" >>_Makefile
- Xecho "NMANS=$NMANS" >>_Makefile
- Xecho >>_Makefile
- X
- Xfor a in $SUBDIRS
- Xdo
- X sed -e '1,/^# Makefile.0 - mark/ d' <_Makefile >$a/_Makefile
- X cat $a/Makefile.0 >>$a/_Makefile
- Xdone
- X
- Xecho "BINDIR=$BINDIR" >>src/_Makefile
- X
- Xfor a in $BINSS
- Xdo
- X echo >>src/_Makefile
- X echo "../new/$a: $a ../config.check" >>src/_Makefile
- X echo " @\$(RM) \$@" >>src/_Makefile
- X echo " \$(LN) ../src/$a \$@" >>src/_Makefile
- Xdone
- X
- Xfor a in $MANSS
- Xdo
- X echo >>man/_Makefile
- X echo "../new/$a: $a ../config.check" >>man/_Makefile
- X echo " @\$(RM) \$@" >>man/_Makefile
- X echo " \$(LN) ../man/$a \$@" >>man/_Makefile
- Xdone
- X
- Xfor a in $MANS1S
- Xdo
- X echo >>man/_Makefile
- X echo "$a.1: $a.man man.sed mansed" >>man/_Makefile
- X echo \
- X " \$(SHELL) ./mansed \$(SHELL) $a.man \$@ \"\$(RM)\" \$(DEVNULL)" \
- X >>man/_Makefile
- Xdone
- X
- Xfor a in $MANS5S
- Xdo
- X echo >>man/_Makefile
- X echo "$a.5: $a.man man.sed mansed" >>man/_Makefile
- X echo \
- X " \$(SHELL) ./mansed \$(SHELL) $a.man \$@ \"\$(RM)\" \$(DEVNULL)" \
- X >>man/_Makefile
- Xdone
- X
- Xcat Makefile.1 >>_Makefile
- X$MV _Makefile Makefile
- X
- Xsleep 1 # Some machines are just too speedy, make gets confused
- X
- Xfor a in $SUBDIRS
- Xdo
- X echo "#" >>$a/_Makefile
- X $MV $a/_Makefile $a/Makefile
- Xdone
- END_OF_FILE
- if test 9335 -ne `wc -c <'procmail-3.03/initmake'`; then
- echo shar: \"'procmail-3.03/initmake'\" unpacked with wrong size!
- fi
- chmod +x 'procmail-3.03/initmake'
- # end of 'procmail-3.03/initmake'
- fi
- if test -f 'procmail-3.03/src/includes.h' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'procmail-3.03/src/includes.h'\"
- else
- echo shar: Extracting \"'procmail-3.03/src/includes.h'\" \(9973 characters\)
- sed "s/^X//" >'procmail-3.03/src/includes.h' <<'END_OF_FILE'
- X/*$Id: includes.h,v 1.44 1994/06/24 10:44:57 berg Exp $*/
- X
- X#include "../autoconf.h"
- X#ifdef NO_const
- X#ifdef const
- X#undef const
- X#endif
- X#define const
- X#endif
- X#include "../config.h"
- X /* not all the "library identifiers" specified here need to be
- X available for all programs in this package; some have substitutes
- X as well (see autoconf); this is just an informal list */
- X
- X#ifndef _HPUX_SOURCE
- X#define _HPUX_SOURCE /* sad, but needed on HP-UX when compiling -Aa */
- X#endif
- X#ifndef NO_FIX_MALLOC
- X#define NO_FIX_MALLOC /* we don't need a `fixed' malloc(0) call */
- X#endif /* saves a few bytes in some implementations */
- X
- X#include <sys/types.h> /* pid_t mode_t uid_t gid_t off_t */
- X#ifndef LIMITS_H_MISSING
- X#include <limits.h> /* absolutely nothing, just for fun */
- X#undef LIMITS_H_MISSING
- X#endif
- X#ifndef UNISTD_H_MISSING
- X#include <unistd.h> /* open() read() write() close() dup() pipe()
- X /* fork() getuid() geteuid() getgid() getegid()
- X getpid() execve() execvp() sleep() setuid()
- X setgid() setruid() setrgid() setegid()
- X chown() nice() */
- X#else
- X#undef UNISTD_H_MISSING
- X#endif
- X#include <stdio.h> /* setbuf() fclose() stdin stdout stderr
- X /* fopen() fread() fwrite() fgetc() getc()
- X fdopen() putc() fputs() printf() sprintf()
- X fprintf() sscanf() FILE EOF */
- X#ifndef STDDEF_H_MISSING
- X#include <stddef.h> /* ptrdiff_t size_t */
- X#else
- X#undef STDDEF_H_MISSING
- X#endif
- X#ifndef STDLIB_H_MISSING
- X#include <stdlib.h> /* getenv() malloc() realloc() free()
- X /* strtol() exit() */
- X#endif
- X#include <time.h> /* time() ctime() time_t */
- X#include <fcntl.h> /* fcntl() struct flock O_RDONLY O_WRONLY
- X /* O_APPEND O_CREAT O_EXCL */
- X#include <grp.h> /* getgrgid() struct group */
- X#include <pwd.h> /* getpwuid() getpwnam() struct passwd */
- X#ifndef DIRENT_H_MISSING
- X#include <dirent.h> /* opendir() readdir() closedir() DIR
- X /* struct dirent */
- X#endif
- X#ifndef SYS_WAIT_H_MISSING
- X#include <sys/wait.h> /* wait() waitpid() WIFEXITED() WIFSTOPPED()
- X /* WEXITSTATUS() WTERMSIG() */
- X#else
- X#undef SYS_WAIT_H_MISSING
- X#endif
- X#ifndef SYS_UTSNAME_H_MISSING
- X#include <sys/utsname.h> /* uname() utsname */
- X#endif
- X#include <sys/stat.h> /* stat() S_ISDIR() S_ISREG() struct stat
- X /* chmod() mkdir() */
- X#include <signal.h> /* signal() kill() alarm() SIG_IGN SIGHUP
- X /* SIGINT SIGQUIT SIGALRM SIGTERM */
- X#ifndef STRING_H_MISSING
- X#include <string.h> /* strcpy() strncpy() strcat() strlen()
- X /* strspn() strcspn() strchr() strcmp()
- X strncmp() strpbrk() strstr() memmove() */
- X#endif
- X#ifndef MATH_H_MISSING
- X#include <math.h> /* pow() */
- X#endif
- X#ifndef SYSLOG_H_MISSING
- X#include <syslog.h> /* openlog() syslog() closelog() LOG_EMERG
- X /* LOG_ALERT LOG_ERR LOG_NOTICE LOG_PID
- X LOG_MAIL */
- X#endif
- X#include <errno.h> /* EINTR EEXIST ENFILE EACCES EAGAIN EXDEV */
- X#ifndef SYSEXITS_H_MISSING
- X#include <sysexits.h> /* EX_OK EX_USAGE EX_NOINPUT EX_NOUSER
- X /* EX_UNAVAILABLE EX_OSERR EX_OSFILE
- X EX_CANTCREAT EX_IOERR EX_TEMPFAIL EX_NOPERM
- X */
- X#endif
- X
- X#ifdef STDLIB_H_MISSING
- X#undef STDLIB_H_MISSING
- Xvoid*malloc(),*realloc();
- Xconst char*getenv();
- X#endif
- X#ifdef DIRENT_H_MISSING
- X#undef DIRENT_H_MISSING
- X#ifndef NDIR_H_MISSING
- X#include <ndir.h>
- X#define dirent direct
- X#else
- X#undef NDIR_H_MISSING
- X#ifndef SYS_NDIR_H_MISSING
- X#include <sys/ndir.h>
- X#define dirent direct
- X#else
- X#undef SYS_NDIR_H_MISSING
- X#ifndef SYS_DIR_H_MISSING
- X#include <sys/dir.h>
- X#define dirent direct
- X#else /* due to brain-damaged NeXT sys/dirent.h contents */
- X#undef SYS_DIR_H_MISSING
- X#ifndef SYS_DIRENT_H_MISSING /* sys/dirent.h must be moved down here */
- X#include <sys/dirent.h>
- X#else
- X/*#undef SYS_DIRENT_H_MISSING /* needed by autoconf */
- X/* I give up, I can only hope that your system defines DIR and struct dirent */
- X#endif
- X#endif
- X#endif
- X#endif
- X#endif /* DIRENT_H_MISSING */
- X#ifdef STRING_H_MISSING
- X#undef STRING_H_MISSING
- X#include <strings.h>
- X#ifndef strchr
- Xchar*strchr();
- X#endif
- Xchar*strpbrk();
- X#endif
- X#ifdef SYS_UTSNAME_H_MISSING
- X#undef SYS_UTSNAME_H_MISSING
- X#define NOuname
- X#endif
- X#ifdef MATH_H_MISSING
- X#undef MATH_H_MISSING
- Xdouble pow();
- X#endif
- X#ifdef SYSEXITS_H_MISSING
- X#undef SYSEXITS_H_MISSING
- X /* Standard exit codes, original list maintained
- X by Eric Allman (eric@berkeley.edu) */
- X#define EX_OK 0
- X#define EX_USAGE 64
- X#define EX_NOINPUT 66
- X#define EX_NOUSER 67
- X#define EX_UNAVAILABLE 69
- X#define EX_OSERR 71
- X#define EX_OSFILE 72
- X#define EX_CANTCREAT 73
- X#define EX_IOERR 74
- X#define EX_TEMPFAIL 75
- X#define EX_NOPERM 77
- X#endif
- X
- X#if O_SYNC
- X#else
- X#undef O_SYNC
- X#define O_SYNC 0
- X#endif
- X#ifndef O_RDONLY
- X#define O_RDONLY 0
- X#define O_WRONLY 1
- X#endif
- X#ifndef SEEK_SET
- X#define SEEK_SET 0
- X#define SEEK_CUR 1
- X#define SEEK_END 2
- X#endif
- X#ifndef tell
- X#define tell(fd) lseek(fd,(off_t)0,SEEK_CUR)
- X#endif
- X
- X#ifndef EWOULDBLOCK
- X#define EWOULDBLOCK EACCES
- X#endif
- X#ifndef EAGAIN
- X#define EAGAIN EINTR
- X#endif
- X
- X#ifndef EOF
- X#define EOF (-1)
- X#endif
- X
- X#ifndef S_ISDIR
- X#define S_ISDIR(mode) (((mode)&S_IFMT)==S_IFDIR)
- X#ifndef S_IFDIR
- X#define S_IFDIR 0040000
- X#endif
- X#endif
- X
- X#ifndef S_ISREG
- X#define S_ISREG(mode) (((mode)&S_IFMT)==S_IFREG)
- X#ifndef S_IFREG
- X#define S_IFREG 0100000
- X#endif
- X#endif
- X
- X#ifndef S_ISLNK
- X#ifndef S_IFLNK
- X#define lstat(path,stbuf) stat(path,stbuf)
- X#define S_ISLNK(mode) 0
- X#else
- X#define S_ISLNK(mode) (((mode)&S_IFMT)==S_IFLNK)
- X#endif
- X#endif
- X
- X#ifndef S_IFMT
- X#define S_IFMT 0170000
- X#endif
- X
- X#ifndef S_IRWXU
- X#define S_IRWXU 00700
- X#define S_IRWXG 00070
- X#define S_IRWXO 00007
- X#endif
- X#ifndef S_IWUSR
- X#ifdef S_IREAD
- X#define S_IRUSR S_IREAD
- X#define S_IWUSR S_IWRITE
- X#define S_IXUSR S_IEXEC
- X#else
- X#define S_IRUSR 0400
- X#define S_IWUSR 0200
- X#define S_IXUSR 0100
- X#endif /* S_IREAD */
- X#define S_IRGRP 0040
- X#define S_IWGRP 0020
- X#define S_IXGRP 0010
- X#define S_IROTH 0004
- X#define S_IWOTH 0002
- X#define S_IXOTH 0001
- X#endif /* S_IWUSR */
- X#ifndef S_ISGID
- X#define S_ISUID 04000
- X#define S_ISGID 02000
- X#endif
- X#ifndef S_ISVTX
- X#define S_ISVTX 01000
- X#endif
- X
- X#ifdef WMACROS_NON_POSIX
- X#undef WMACROS_NON_POSIX
- X#ifdef WIFEXITED
- X#undef WIFEXITED
- X#endif
- X#ifdef WIFSTOPPED
- X#undef WIFSTOPPED
- X#endif
- X#ifdef WEXITSTATUS
- X#undef WEXITSTATUS
- X#endif
- X#ifdef WTERMSIG
- X#undef WTERMSIG
- X#endif
- X#endif /* WMACROS_NON_POSIX */
- X
- X#ifndef WIFEXITED
- X#define WIFEXITED(waitval) (!((waitval)&255))
- X#endif
- X#ifndef WIFSTOPPED
- X#define WIFSTOPPED(waitval) (((waitval)&255)==127)
- X#endif
- X#ifndef WEXITSTATUS
- X#define WEXITSTATUS(waitval) ((waitval)>>8&255)
- X#endif
- X#ifndef WTERMSIG
- X#define WTERMSIG(waitval) ((waitval)&255)
- X#endif
- X
- Xextern /*const*/char**environ;
- Xextern int errno;
- X
- X#ifndef STDIN_FILENO
- X#define STDIN 0
- X#define STDOUT 1
- X#define STDERR 2
- X#else
- X#define STDIN STDIN_FILENO
- X#define STDOUT STDOUT_FILENO
- X#define STDERR STDERR_FILENO
- X#endif
- X
- X#ifdef NO_fcntl_LOCK
- X#ifndef NOfcntl_lock
- X#define NOfcntl_lock
- X#endif
- X#endif
- X#ifdef NO_lockf_LOCK
- X#ifdef USElockf
- X#undef USElockf
- X#endif
- X#endif
- X#ifdef NO_flock_LOCK
- X#ifdef USEflock
- X#undef USEflock
- X#endif
- X#endif
- X
- X#ifdef SYSLOG_H_MISSING
- X#undef SYSLOG_H_MISSING
- X#define openlog(ident,logopt,facility) 0
- X#define syslog (void)
- X#define LOG_EMERG 0
- X#define LOG_ALERT 0
- X#define LOG_ERR 0
- X#define LOG_NOTICE 0
- X#endif
- X
- X#ifndef NOuname
- X#ifndef P /* SINIX V5.23 has the wrong prototype for uname() */
- Xextern int uname(); /* so we fix it :-) */
- X#define Uname(name) ((int(*)(struct utsname*))uname)(name)
- X#else
- X#define Uname(name) uname(name) /* no fix needed */
- X#endif /* P */
- X#endif /* NOuname */
- X /* NEWS OS 5.X has the wrong prototype here */
- X#define Fdopen(fd,type) ((FILE*)fdopen(fd,type))
- X
- X#ifndef strchr /* for very old K&R compatible include files with */
- X#ifdef P /* new K&R libraries */
- X#ifdef void
- X#ifdef NO_const
- Xextern char*strchr();
- Xextern char*strpbrk();
- Xextern char*strstr();
- Xextern void*memmove();
- X#endif
- X#endif
- X#endif
- X#endif
- X
- X#define Const /*const*/ /* Convex cc doesn't grok this */
- X
- X#ifndef P /* no prototypes without const */
- X#ifdef NO_const
- X#define P(args) ()
- X#endif
- X#endif
- X
- X#ifdef NOrename
- X#undef NOrename
- X#define rename(old,new) (-(link(old,new)||unlink(old)))
- X#endif
- X
- X#ifndef NOsetregid
- X#ifdef NOsetrgid
- X#define setrgid(gid) setregid(gid,-1)
- X#define setruid(uid) setreuid(uid,-1)
- X#endif
- X#ifdef NOsetegid
- X#define setegid(gid) setregid(-1,gid)
- X#endif
- X#else
- X#ifndef NOsetresgid
- X#ifdef NOsetrgid
- X#define setrgid(gid) setresgid(gid,-1,-1)
- X#define setruid(uid) setresuid(uid,-1,-1)
- X#endif
- X#ifdef NOsetegid
- X#define setegid(gid) setresgid(-1,gid,-1)
- X#endif
- X#else
- X#ifdef NOsetrgid
- X#define setrgid(gid) (-1)
- X#define setruid(uid) (-1)
- X#endif
- X#ifdef NOsetegid
- X#define setegid(gid) setgid(gid)
- X#endif
- X#endif
- X#endif
- X
- X#ifdef NOsetrgid
- X#undef NOsetrgid
- X#endif
- X#ifdef NOsetegid
- X#undef NOsetegid
- X#endif
- X#ifdef NOsetregid
- X#undef NOsetregid
- X#endif
- X#ifdef NOsetresgid
- X#undef NOsetresgid
- X#endif
- X
- X#ifdef NOpow
- X#define tpow(x,y) (x)
- X#else
- X#define tpow(x,y) pow(x,y)
- X#endif
- X
- X#ifdef NOmkdir
- X#undef NOmkdir
- X#define mkdir(dir,mode) (-1)
- X#endif
- X
- X#ifdef NOwaitpid
- X#undef NOwaitpid
- X#define waitpid(pid,stat_loc,options) 0
- X#endif
- X
- X#ifdef NOmemmove
- X#define memmove(to,from,count) smemmove(to,from,count)
- X#endif
- X
- X#ifdef SLOWstrstr
- X#ifdef strstr
- X#undef strstr
- X#endif
- X#define strstr(haystack,needle) sstrstr(haystack,needle)
- X#endif
- X
- X#ifndef P
- X#define P(args) args
- X#endif
- X#define Q(args) () /* needed until function definitions are ANSI too */
- X
- X#ifdef oBRAIN_DAMAGE
- X#undef oBRAIN_DAMAGE
- X#undef offsetof
- X#endif
- X#ifndef offsetof
- X#define offsetof(s,m) ((char*)&(((s*)sizeof(s))->m)-(char*)sizeof(s))
- X#endif
- X
- X#define SETerrno(v) (errno=(v)) /* multi-threading errno hook */
- X
- X#define PROGID /*const*/char progid[]="Stephen R. van den Berg"
- X#define maxindex(x) (sizeof(x)/sizeof((x)[0])-1)
- X#define STRLEN(x) (sizeof(x)-1)
- X#define ioffsetof(s,m) ((int)offsetof(s,m))
- X#define numeric(x) ((unsigned)(x)-'0'<='9'-'0')
- X#define charNUM(num,v) char num[8*sizeof(v)*4/10+1+1]
- X
- X#define mx(a,b) ((a)>(b)?(a):(b))
- X
- Xtypedef unsigned char uschar; /* sometimes uchar is already typedef'd */
- X#ifdef uchar
- X#undef uchar
- X#endif
- X#define uchar uschar
- X
- X#ifdef NO_const
- X#undef NO_const
- X#endif
- END_OF_FILE
- if test 9973 -ne `wc -c <'procmail-3.03/src/includes.h'`; then
- echo shar: \"'procmail-3.03/src/includes.h'\" unpacked with wrong size!
- fi
- # end of 'procmail-3.03/src/includes.h'
- fi
- if test -f 'procmail-3.03/src/lockfile.c' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'procmail-3.03/src/lockfile.c'\"
- else
- echo shar: Extracting \"'procmail-3.03/src/lockfile.c'\" \(9833 characters\)
- sed "s/^X//" >'procmail-3.03/src/lockfile.c' <<'END_OF_FILE'
- X/************************************************************************
- X * lockfile - The conditional semaphore-file creator *
- X * *
- X * It has been designed to be able to be run sgid mail or *
- X * any gid you see fit (in case your mail spool area is *not* *
- X * world writable, but group writable), without creating *
- X * security holes. *
- X * *
- X * Seems to be relatively bug free. *
- X * *
- X * Copyright (c) 1990-1994, S.R. van den Berg, The Netherlands *
- X * #include "../README" *
- X ************************************************************************/
- X#ifdef RCS
- Xstatic /*const*/char rcsid[]=
- X "$Id: lockfile.c,v 1.28 1994/06/28 16:56:21 berg Exp $";
- X#endif
- Xstatic /*const*/char rcsdate[]="$Date: 1994/06/28 16:56:21 $";
- X#include "includes.h"
- X#include "sublib.h"
- X#include "exopen.h"
- X#include "mcommon.h"
- X
- X#ifndef SYSTEM_MBOX
- X#define SYSTEM_MBOX SYSTEM_MAILBOX
- X#endif
- X
- Xstatic volatile exitflag;
- Xpid_t thepid;
- Xuid_t uid;
- Xgid_t sgid;
- Xstatic char systm_mbox[]=SYSTEM_MBOX;
- Xstatic const char dirsep[]=DIRSEP,lockext[]=DEFlockext,
- X nameprefix[]="lockfile: ",lgname[]="LOGNAME",home[]="HOME";
- X
- Xstatic void failure P((void)) /* signal trap */
- X{ exitflag=2; /* merely sets a flag */
- X}
- X /* see locking.c for comment on xcreat() */
- Xstatic int xcreat(name,tim)const char*const name;time_t*const tim;
- X{ char*p,*q;int j= -1;size_t i;struct stat stbuf;
- X for(q=(char*)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,LOCKperm,0,doCHECK|doLOCK))
- X stat(p,&stbuf),*tim=stbuf.st_mtime,j=myrename(p,name);
- X free(p);
- X return j;
- X}
- X
- Xvoid elog(a)const char*const a;
- X{ write(STDERR,a,strlen(a));
- X}
- X
- Xvoid nlog(a)const char*const a;
- X{ elog(nameprefix);elog(a); /* decent error messages should start with this */
- X}
- X
- Xstatic size_t parsecopy(dest,org,pass)char*const dest;const char*org;
- X const struct passwd*const pass; /* try and digest the mailbox-lockfile name */
- X{ size_t len;const char*chp;char*p;unsigned i;
- X for(p=dest,len=STRLEN(lockext)+1;;)
- X { switch(*org)
- X { case '$': /* we substitute */
- X if(!strncmp(++org,lgname,STRLEN(lgname)))
- X org+=STRLEN(lgname),chp=pass->pw_name; /* $LOGNAME and */
- X else if(!strncmp(org,home,STRLEN(home)))
- X org+=STRLEN(home),chp=pass->pw_dir; /* $HOME */
- X else
- X goto capac; /* no other fancy stuff */
- X if((i= *org)-'a'<='z'-'a'||i-'A'<='Z'-'A'||numeric(i)||i=='_')
- X goto capac;
- X if(p)
- X p+=strlen(strcpy(p,chp)); /* paste it in */
- X len+=strlen(chp);
- X continue;
- X default:
- X if(p)
- X *p++= *org; /* simply copy everything else */
- X len++;org++;
- X continue; /* except suspicious looking characters */
- X case '\'':case '`':case '"':case '\\':case '{':
- X goto capac;
- X case '\0':;
- X }
- X if(p)
- X { if(p==dest||!strchr(dirsep,*dest)) /* absolute path wanted */
- Xcapac: { nlog("Sorry, but turning this mess into a useable mailbox \
- Xexceeds my humble\ncapacities");
- X return 0;
- X }
- X strcpy(p,lockext);
- X }
- X return len;
- X }
- X}
- X
- Xstatic PROGID;
- X
- Xmain(argc,argv)const char*const argv[];
- X{ const char*const*p,*const*lastf;char*cp;uid_t uid;
- X int sleepsec,retries,invert,force,suspend,retval=EX_OK,virgin=1;
- X static const char usage[]="Usage: lockfile -nnn | -r nnn | -l nnn | -s nnn \
- X| -! | -ml | -mu | file ...\n";
- X if(argc<=1) /* sanity check, any argument at all? */
- X goto usg;
- X sleepsec=DEFlocksleep;retries= -1;suspend=DEFsuspend;thepid=getpid();force=0;
- X uid=getuid();signal(SIGPIPE,SIG_IGN);
- Xagain:
- X invert=(char*)progid-(char*)progid;qsignal(SIGHUP,failure);
- X qsignal(SIGINT,failure);qsignal(SIGQUIT,failure);qsignal(SIGTERM,failure);
- X for(lastf=p=argv;--argc;)
- X if(*(cp=(char*)*++p)=='-')
- X for(cp++;;)
- X { char*cp2=cp;int i;
- X switch(*cp++)
- X { case '!':invert^=1; /* invert the exitcode */
- X continue;
- X case 'r':case 'l':case 's':
- X if(!*cp&&(cp=(char*)*++p,!--argc)) /* concatenated/seperate */
- X goto eusg;
- X i=strtol(cp,&cp,10);
- X switch(*cp2)
- X { case 'r':retries=i;
- X goto checkrdec;
- X case 'l':force=i;
- X goto checkrdec;
- X default:
- X if(i<0) /* suspend should be >=0 */
- X goto eusg;
- X suspend=i;
- X goto checkrdec;
- X }
- X case HELPOPT1:case HELPOPT2:elog(usage);
- X elog(
- X "\t-nnn\twait nnn seconds between locking attempts\
- X\n\t-r nnn\tmake at most nnn retries before giving up on a lock\
- X\n\t-l nnn\tset locktimeout to nnn seconds\
- X\n\t-s nnn\tsuspend nnn seconds after a locktimeout occurred\
- X\n\t-!\tinvert the exit code of lockfile\
- X\n\t-ml\tlock your system mail-spool file\
- X\n\t-mu\tunlock your system mail-spool file\n");
- X goto xusg;
- X default:
- X if(sleepsec>=0) /* is this still the first pass? */
- X { if((sleepsec=strtol(cp2,&cp,10))<0)
- X goto eusg;
- Xcheckrdec: if(cp2==cp)
- Xeusg: { elog(usage); /* regular usage message */
- Xxusg: retval=EX_USAGE;
- X goto nfailure;
- X }
- X }
- X else /* no second pass, so leave sleepsec<0 */
- X strtol(cp2,&cp,10); /* and discard the number */
- X continue;
- X case 'm': /* take $LOGNAME as a hint, check if valid */
- X { struct passwd*pass;static char*ma;size_t alen;
- X if(*cp&&cp[1]||ma&&sleepsec>=0) /* second pass? */
- X goto eusg;
- X if(!ma) /* ma initialised last time? */
- X { if(!((ma=(char*)getenv(lgname))&&(pass=getpwnam(ma))&&
- X pass->pw_uid==uid||(pass=getpwuid(uid))))
- X { nlog("Can't determine your mailbox, who are you?\n");
- X goto nfailure; /* panic, you're not in /etc/passwd */
- X }
- X if(!(alen=parsecopy((char*)0,systm_mbox,pass)))
- X { cp=systm_mbox;
- X goto lfailure; /* couldn't digest */
- X } /* mailbox */
- X if(!(ma=malloc(alen))) /* ok, make some room */
- X goto outofmem;
- X parsecopy(ma,systm_mbox,pass); /* and fill her up */
- X }
- X switch(*cp)
- X { default:
- X goto eusg; /* somebody goofed again */
- X case 'l': /* lock the mailbox */
- X if(sleepsec>=0) /* first pass? */
- X { cp=ma;
- X goto stilv; /* yes, lock it! */
- X }
- X case 'u': /* unlock the mailbox */
- X if(unlink(ma))
- X { nlog("Can't unlock \"");elog(ma);elog("\"");
- X if(*cp=='l') /* they messed up, give them a hint */
- X elog(" again,\n already dropped my privileges");
- X elog("\n");
- X }
- X else
- X virgin=0;
- X }
- X }
- X case '\0':;
- X }
- X break;
- X }
- X else if(sleepsec<0) /* second pass, release everything we acquired */
- X unlink(cp);
- X else
- X { time_t t;int permanent;
- X setgid(getgid()); /* just to be on the safe side */
- Xstilv: virgin=0;permanent=nfsTRY;
- X while(0>xcreat(cp,&t)) /* try and lock */
- X { struct stat stbuf;
- X if(exitflag) /* time to stop? */
- X { if(exitflag==1) /* was it failure() or malloc() */
- Xoutofmem: retval=EX_OSERR,nlog("Out of memory");
- X else
- X retval=EX_TEMPFAIL,nlog("Signal received");
- X goto lfailure;
- X }
- X switch(errno) /* why did the lock not succeed? */
- X { case EEXIST: /* hmmm..., by force then? */
- X if(force&&!lstat(cp,&stbuf)&&force<t-stbuf.st_mtime)
- X { nlog(unlink(cp)?"Forced unlock denied on \"":
- X "Forcing lock on \"");
- X elog(cp);elog("\"\n");sleep(suspend); /* important */
- X }
- X else /* no forcing now */
- X switch(retries) /* await your turn like everyone else */
- X { case 0:nlog("Sorry");retval=EX_CANTCREAT;
- X goto lfailure; /* patience exhausted, give up */
- X default:retries--; /* count sheep */
- X case -1:sleep(sleepsec); /* wait and see */
- X }
- X break;
- X case ENOSPC:
- X#ifdef EDQUOT
- X case EDQUOT:
- X#endif
- X case ENOENT:case ENOTDIR:case EIO:case EACCES:
- X if(!--permanent) /* NFS sporadically generates these */
- X { sleep(sleepsec); /* unwarranted, so ignore them first */
- X continue;
- X }
- X default: /* but, it seems to persist, so give up */
- X nlog("Try praying");retval=EX_UNAVAILABLE;
- X#ifdef ENAMETOOLONG
- X goto lfailure;
- X case ENAMETOOLONG:
- X if(0<(permanent=strlen(cp)-1)&& /* can we truncate it? */
- X !strchr(dirsep,cp[permanent-1]))
- X { nlog("Truncating \"");elog(cp); /* then try it */
- X elog("\" and retrying lock\n");cp[permanent]='\0';
- X break;
- X } /* otherwise, forget it */
- X nlog("Filename too long");retval=EX_UNAVAILABLE;
- X#endif
- Xlfailure: elog(", giving up on \"");elog(cp);elog("\"\n");
- Xnfailure: sleepsec= -1;argc=lastf-argv+1; /* mark sleepsec */
- X goto again;
- X } /* for second pass, and adjust argc to the no. of args parsed */
- X permanent=nfsTRY; /* refresh the NFS-error-ignore count */
- X }
- X lastf=p; /* last valid file */
- X }
- X if(retval==EX_OK&&virgin) /* any errors? did we do anything? */
- Xusg:
- X { elog(usage);
- X return EX_USAGE;
- X }
- X if(invert)
- X switch(retval) /* we only invert the regular cases */
- X { case EX_OK:
- X return EX_CANTCREAT;
- X case EX_CANTCREAT:
- X return EX_OK;
- X }
- X return retval; /* all other exitcodes remain */
- X}
- X
- Xvoid*tmalloc(len)const size_t len; /* stub */
- X{ void*p;
- X if(!(p=malloc(len)))
- X exitflag=1; /* signal out of memory */
- X return p;
- X}
- X
- Xvoid tfree(p)void*const p; /* stub */
- X{ free(p);
- X}
- X
- Xint ropen(name,mode,mask)const char*const name;const int mode;
- X const mode_t mask;
- X{ return open(name,mode,mask); /* stub */
- X}
- X
- Xint rwrite(fd,a,len)const int fd;const void*const a;const int len; /* stub */
- X{ return write(fd,a,len);
- X}
- X
- Xint rclose(fd)const int fd; /* stub */
- X{ return close(fd);
- X}
- X
- Xvoid writeerr(a)const char*const a; /* stub */
- X{
- X}
- END_OF_FILE
- if test 9833 -ne `wc -c <'procmail-3.03/src/lockfile.c'`; then
- echo shar: \"'procmail-3.03/src/lockfile.c'\" unpacked with wrong size!
- fi
- # end of 'procmail-3.03/src/lockfile.c'
- fi
- if test -f 'procmail-3.03/src/setid.c' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'procmail-3.03/src/setid.c'\"
- else
- echo shar: Extracting \"'procmail-3.03/src/setid.c'\" \(1181 characters\)
- sed "s/^X//" >'procmail-3.03/src/setid.c' <<'END_OF_FILE'
- X/************************************************************************
- X * setid executes commands under a different *
- X * uid/gid (can only be executed by root) *
- X * This program is used by the SmartList installation script only. *
- X ************************************************************************/
- X/*$Id: setid.c,v 1.7 1994/06/28 16:56:47 berg Exp $*/
- X#include "includes.h"
- X
- X#define CHECK_FILE "install.sh"
- X
- Xmain(argc,argv)const int argc;const char*const argv[];
- X{ struct passwd*p;char*nargv[2];
- X if(argc!=2&&argc!=3||geteuid()||!(p=getpwnam(argv[1])))
- X { fprintf(stderr,"Usage: setid user [directory]\n");
- X return EX_USAGE;
- X }
- X endpwent();initgroups(argv[1],p->pw_gid);setgid(p->pw_gid);setuid(p->pw_uid);
- X if(fopen(CHECK_FILE,"r"))
- X { struct stat stbuf;
- X if(argc==2||!stat(argv[2],&stbuf)&&
- X stbuf.st_uid==p->pw_uid&&
- X stbuf.st_gid==p->pw_gid)
- X nargv[0]=getenv("SHELL"),nargv[1]=0,execve(nargv[0],nargv,environ);
- X else
- X fprintf(stderr,
- X "Please create %s with the correct owner and group first\n",argv[2]);
- X }
- X else
- X fprintf(stderr,
- X "Please make sure %s can read & access the source tree\n",argv[1]);
- X return EX_UNAVAILABLE;
- X}
- END_OF_FILE
- if test 1181 -ne `wc -c <'procmail-3.03/src/setid.c'`; then
- echo shar: \"'procmail-3.03/src/setid.c'\" unpacked with wrong size!
- fi
- # end of 'procmail-3.03/src/setid.c'
- fi
- echo shar: End of archive 7 \(of 10\).
- cp /dev/null ark7isdone
- MISSING=""
- for I in 1 2 3 4 5 6 7 8 9 10 ; do
- if test ! -f ark${I}isdone ; then
- MISSING="${MISSING} ${I}"
- fi
- done
- if test "${MISSING}" = "" ; then
- echo You have unpacked all 10 archives.
- rm -f ark[1-9]isdone ark[1-9][0-9]isdone
- else
- echo You still must unpack the following archives:
- echo " " ${MISSING}
- fi
- exit 0
- exit 0 # Just in case...
-