home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Usenet 1994 October
/
usenetsourcesnewsgroupsinfomagicoctober1994disk2.iso
/
misc
/
volume38
/
procmail
/
part11
< prev
next >
Wrap
Text File
|
1993-07-05
|
49KB
|
1,641 lines
Newsgroups: comp.sources.misc
From: berg@pool.informatik.rwth-aachen.de (Stephen R. van den Berg)
Subject: v38i030: procmail - mail processing package v2.90, Part11/11
Message-ID: <1993Jul1.151726.22321@sparky.imd.sterling.com>
X-Md4-Signature: 57d24e9ee95c5deb649eed0ad013f5f3
Sender: kent@sparky.imd.sterling.com (Kent Landfield)
Organization: Sterling Software
Date: Thu, 1 Jul 1993 15:17:26 GMT
Approved: kent@sparky.imd.sterling.com
Submitted-by: berg@pool.informatik.rwth-aachen.de (Stephen R. van den Berg)
Posting-number: Volume 38, Issue 30
Archive-name: procmail/part11
Environment: sendmail, smail, MMDF, mailsurr, UNIX, POSIX
Supersedes: procmail: Volume 35, Issue 21-32,124,125
#! /bin/sh
# This is a shell archive. Remove anything before this line, then unpack
# it by saving it into a file and typing "sh file". To overwrite existing
# files, type "sh file -c". You can also feed this as standard input via
# unshar, or by typing "sh <file", e.g.. If this archive is complete, you
# will see the following message at the end:
# "End of archive 11 (of 11)."
# Contents: procmail/examples/forward procmail/man/procmail.man
# procmail/src/autoconf
# Wrapped by berg@tubastos on Thu Jul 1 14:06:19 1993
PATH=/bin:/usr/bin:/usr/ucb ; export PATH
if test -f 'procmail/examples/forward' -a "${1}" != "-c" ; then
echo shar: Will not clobber existing file \"'procmail/examples/forward'\"
else
echo shar: Extracting \"'procmail/examples/forward'\" \(57 characters\)
sed "s/^X//" >'procmail/examples/forward' <<'END_OF_FILE'
X"|IFS=' ';exec /usr/local/bin/procmail #YOUR_LOGIN_NAME"
END_OF_FILE
if test 57 -ne `wc -c <'procmail/examples/forward'`; then
echo shar: \"'procmail/examples/forward'\" unpacked with wrong size!
fi
# end of 'procmail/examples/forward'
fi
if test -f 'procmail/man/procmail.man' -a "${1}" != "-c" ; then
echo shar: Will not clobber existing file \"'procmail/man/procmail.man'\"
else
echo shar: Extracting \"'procmail/man/procmail.man'\" \(17351 characters\)
sed "s/^X//" >'procmail/man/procmail.man' <<'END_OF_FILE'
X.Id $Id: procmail.man,v 1.23 1993/06/30 16:01:33 berg Exp $
X.TH PROCMAIL 1 \*(Dt BuGless
X.na
X.SH NAME
Xprocmail \- autonomous mail processor
X.SH SYNOPSIS
X.B procmail
X.RB [ \-@PRESERVOPT@@TEMPFAILOPT@ ]
X.RB [ "\-@FROMWHOPT@ \fIfromwhom\fP" ]
X.RI [ "parameter\fB=\fPvalue " | " rcfile" ]
X\&.\|.\|.
X.br
X.B procmail
X.RB [ \-@PRESERVOPT@@TEMPFAILOPT@ ]
X.RB [ "\-@FROMWHOPT@ \fIfromwhom\fP" ]
X.RB [ "\-@ARGUMENTOPT@ \fIargument\fP" ]
X.B \-@DELIVEROPT@
X.I recipient
X\&.\|.\|.
X.br
X.B procmail
X.RB [ \-@PRESERVOPT@@TEMPFAILOPT@ ]
X.B \-@MAILFILTOPT@
X.RI [ "parameter\fB=\fPvalue" ]
X\&.\|.\|.
X.I rcfile mail_from rcpt_to
X\&.\|.\|.
X.br
X.B procmail
X.B \-@VERSIONOPT@
X.ad
X.Sh DESCRIPTION
XFor a quick start, see
X.B NOTES
Xat the end.
X.PP
X.B Procmail
Xshould be invoked automatically over the
X.B @DOT_FORWARD@
Xfile mechanism as soon as mail arrives. Alternatively, when installed by
Xa system administrator, it can be invoked from within the mailer immediately.
XWhen invoked, it first sets some environment variables to default values,
Xreads the mail message from stdin until an EOF, separates the body from the
Xheader, and then, if no command line arguments are present, it starts to look
Xfor a file named
X.B @PROCMAILRC@
Xin your home directory. According to the processing recipes in this file,
Xthe mail message that just arrived gets distributed into the right folder
X(and more).
X.PP
XIf running suid root or with root privileges, procmail will be able to
Xperform as a functionally enhanced, backwards compatible mail delivery agent.
X.PP
XProcmail can also be used as a general purpose mail filter, i.e. provisions
Xhave been made to enable procmail to be invoked in a special sendmail rule.
X.PP
XThe rcfile format is described in detail in the
X.BR procmailrc (5)
Xman page.
X.PP
XExamples for rcfile recipes can be looked up in the
X.BR procmailex (5)
Xman page.
X.Ss Signals
X.Tp 1.2i
X.B TERMINATE
XTerminate prematurely and requeue the mail.
X.Tp
X.B HANGUP
XTerminate prematurely and bounce the mail.
X.Tp
X.B INTERRUPT
XTerminate prematurely and bounce the mail.
X.Tp
X.B QUIT
XTerminate prematurely and silently lose the mail.
X.Tp
X.B ALARM
XForce a timeout (see
X.BR TIMEOUT).
X.Sh OPTIONS
X.Tp 0.5i
X.B \-@VERSIONOPT@
XProcmail will print its version number and exit.
X.Tp
X.B \-@PRESERVOPT@
XPreserve any old environment. Normally procmail clears the environment
Xupon startup@KEEPENV@. However, in any case: any default values will override
Xany preexisting environment variables, i.e. procmail will not pay any attention
Xto any predefined environment variables, it will happily overwrite them
Xwith its own defaults.
X.Tp
X.B \-@TEMPFAILOPT@
XMake procmail fail softly, i.e. if procmail cannot deliver the mail to
Xany of the destinations you gave, the mail will not bounce, but will return
Xto the mailqueue. Another delivery-attempt will be made at some time in
Xthe future.
X.Tp
X.I "\fB\-@FROMWHOPT@\fP fromwhom"
XCauses procmail to regenerate the leading `@FROM@' line with
X.I fromwhom
Xas the sender (instead of \-@FROMWHOPT@ one could use the alternate and
Xobsolete \-@ALTFROMWHOPT@).
X.Tp
X.I "\fB\-@ARGUMENTOPT@\fP argument"
XThis will set $1 to be equal to
X.IR argument .
XIt can be used to pass meta information along to procmail. This is
Xtypically done by passing along the $@x information from the sendmail
Xmailer rule.
X.Tp
X.I "\fB\-@DELIVEROPT@\fP recipient .\|.\|."
XThis turns on explicit delivery mode, delivery will be to the local user
X.IR recipient .
XThis, of course, only is possible if procmail has root privileges.
XProcmail will setuid to the intended recipients and shall
X.I only
Xread the recipient's @PROCMAILRC@ file (if present, if not, delivery is like
Xordinary mail).
X.Tp
X.B \-@MAILFILTOPT@
XTurns procmail into a general purpose mail filter. In this mode an rcfile
Xmust be specified on the command line. You should also specify the
Xenvelope sender and one or more envelope recipient addresses on the command
Xline so that the mail can be transparently resent if needed.
XFor some typical usage of this option you should look in the
X.B EXAMPLES
Xsection below.
X.Sh ARGUMENTS
XAny arguments containing an '=' are considered to be environment variable
Xassignments, they will
X.I all
Xbe evaluated after the default values have been
Xassigned and before the first rcfile is opened.
X.PP
XAny other arguments are presumed to be rcfile paths (either absolute,
Xor if they start with `@chCURDIR@@MCDIRSEP@' relative to the current
Xdirectory;
X.B any other relative
Xpath is relative to $HOME); procmail will start with the first one it finds
Xon the command line. The following ones will only be parsed if the preceding
Xones have a not matching HOST-directive entry, or in case they should not
Xexist.
X.PP
XIf no rcfiles are specified, it looks for
X.BR $HOME/@PROCMAILRC@ .
XIf not even that can be found, processing will continue according to
Xthe default settings of the environment variables and the ones specified
Xon the command line.
X.Sh EXAMPLES
XExamples for rcfile recipes can be looked up in the
X.BR procmailex (5)
Xman page.
XA small sample rcfile can be found in the
X.B NOTES
Xsection below.
X.PP
XThe
X.B \-@MAILFILTOPT@
Xoption is typically used when procmail is called from within a rule in the
Xsendmail.cf file. In order to be able to do this it is convenient to create
Xan extra `procmail' mailer in your sendmail.cf file (in addition to the perhaps
Xalready present `local' mailer that starts up procmail). To create such a
X`procmail' mailer I'd suggest something like:
X.Sx 2
XMprocmail, P=@BINDIR@/procmail, F=mSDFMhun, S=11, R=21,
X A=procmail \-@MAILFILTOPT@ $h $u
X.Ex
XThis enables you to use rules like the following (most likely in ruleset 0)
Xto filter mail through the procmail mailer (please note the leading tab
Xto continue the rule, and the tab to separate the comments):
X.Sx 4
XR$*<@some.where>$*
X $#procmail $@/etc/some.rc $:$1@some.where.procmail$2
XR$*<@somehost.somewhere.procmail>$*
X $1<@somehost.somewhere>$* Already filtered, map back
X.Ex
XAnd /etc/some.rc could be as simple as:
X.Sx 6
X:0 # sink all junk mail
X* ^Subject:.*junk
X/dev/null
X
X:0 # pass along all other mail
X! \-oi \-f "$@"
X.Ex
X.Sh FILES
X.Tp 2.3i
X.B /etc/passwd
Xto set the recipient's LOGNAME, HOME and SHELL variable defaults
X.Tp
X.B @SYSTEM_MBOX@
Xsystem mailbox
X.Tp
X.B $HOME/@PROCMAILRC@
Xdefault rcfile
X.Tp
X.B @SYSTEM_MBOX@@DEFlockext@
Xlockfile for the system mailbox (not used by procmail automatically, unless
X$DEFAULT equals @SYSTEM_MBOX@ and procmail is delivering to $DEFAULT)
X.Tp
X.B @DEFsendmail@
Xdefault mail forwarder
X.Tp
X.B @UNIQ_PREFIX@????`hostname`
Xtemporary `unique' zero-length files created by procmail
X.Sh "SEE ALSO"
X.na
X.nh
X.BR procmailrc (5),
X.BR procmailex (5),
X.BR sh (1),
X.BR csh (1),
X.BR mail (1),
X.BR mailx (1),
X.BR binmail (1),
X.BR uucp (1),
X.BR aliases (5),
X.BR sendmail (8),
X.BR egrep (1),
X.BR grep (1),
X.BR biff (1),
X.BR comsat (8),
X.BR lockfile (1),
X.BR formail (1),
X.BR cron (1)
X.hy
X.ad
X.Sh DIAGNOSTICS
X.Tp 2.3i
XAutoforwarding mailbox found
XThe system mailbox had its suid or sgid bit set, procmail terminates with
XEX_NOUSER assuming that this mailbox must not be delivered to.
X.Tp
XBad substitution of "x"
XNot a valid environment variable name specified.
X.Tp
XConflicting options
XNot all option combinations are useful
X.Tp
XCouldn't create "x"
XThe system mailbox was missing and could not/will not be created.
X.Tp
XCouldn't determine implicit lockfile from "x"
XThere were no `>>' redirectors to be found, using simply `$LOCKEXT' as
Xlocallockfile.
X.Tp
XCouldn't unlock "x"
XLockfile was already gone, or write permission to the directory were the
Xlockfile is has been denied.
X.Tp
XDeadlock attempted on "x"
XThe locallockfile specified on this recipe is equal to a still active
X$LOCKFILE.
X.Tp
XError while writing to "x"
XNonexistent subdirectory, no write permission, pipe died or disk full.
X.Tp
XExceeded LINEBUF
XBuffer overflow detected, LINEBUF was too small, memory might be corrupted.
X.Tp
XExcessive output quenched from "x"
XThe program or filter "x" tried to produce too much output for the current
XLINEBUF, discarded the rest.
X.Tp
XExtraneous filter-flag ignored
XYou specified the `@FILTER@'-flag on a recipe with a filename as the
Xdestination, or where stdout is captured.
X.Tp
XFailed forking "x"
XProcess table is full (and NORESRETRY has been exhausted).
X.Tp
XFailed to execute "x"
XProgram not in path, or not executable.
X.Tp
XForced unlock denied on "x"
XNo write permission in the directory where
X.B lockfile
X"x" resides, or more than one procmail trying to force a lock at exactly the
Xsame time.
X.Tp
XForcing lock on "x"
X.B Lockfile
X"x" is going to be removed by force because of a timeout (see also:
X.BR LOCKTIMEOUT ).
X.Tp
XInvalid regexp "x"
XThe regular expression "x" contains errors (most likely some missing or
Xextraneous parens).
X.Tp
XKernel-lock failed
XWhile trying to use the kernel-supported locking calls, one of them failed
X(usually indicates an OS error), procmail ignores this error and proceeds.
X.Tp
XKernel-unlock failed
XSee above.
X.Tp
XLock failure on "x"
XCan only occur if you specify some real weird (and illegal) lockfilenames
Xor if the
X.B lockfile
Xcould not be created because of insufficient permissions or nonexistent
Xsubdirectories.
X.Tp
XMissing name
XThe \-@FROMWHOPT@ option needs an extra argument
X.Tp
XMissing argument
XYou specified the \-@ARGUMENTOPT@ option but forgot the argument
X.Tp
XMissing rcfile
XYou specified the \-@MAILFILTOPT@ option, procmail expects the name of an
Xrcfile as argument
X.Tp
XMissing recipient
XYou specified the \-@DELIVEROPT@ option or called procmail under a different
Xname, it expects one or more recipients as arguments
X.Tp
XOut of memory
XThe system is out of swap space (and NORESRETRY has been exhausted).
X.Tp
XProcessing continued
XThe unrecognised options on the command line are ignored, proceeding as
Xusual.
X.Tp
XProgram failure of "x"
XProgram that was started by procmail didn't return EX_OK (=@EX_OK@).
X.Tp
XSkipped: "x"
XCouldn't do anything with "x" in the rcfile (syntax error), ignoring it.
X.Tp
XSuspicious rcfile
XThe owner of the rcfile was not the recipient, or the directory that contained
Xit was world writeable (the rcfile was not used)
X.Tp
XTerminating prematurely whilst waiting for .\|.\|.
XProcmail received a signal while it was waiting for .\|.\|.
X.Tp
XTimeout, terminating "x"
XTimeout has occurred on program/filter "x".
X.Tp
XTruncating "x" and retrying lock
X"x" does not seem to be a valid filename or the file is not empty.
X.Tp
XReiterating kernel-lock
XWhile attempting several locking methods, one of these failed. Procmail will
Xreiterate until they all succeed in rapid succession.
X.Tp
XRescue of unfiltered data succeeded/failed
XA filter returned unsuccessfully, procmail tried to get back the original text.
X.Tp
XUnexpected EOL
XMissing closing quote, or trying to escape EOF.
X.Tp
XUnknown user "x"
XThe specified recipient does not have a corresponding uid.
X.Sh "EXTENDED DIAGNOSTICS"
X.Tp 2.3i
XAssigning "x"
XEnvironment variable assignment.
X.Tp
XBypassed locking "x"
XThe mail spool directory was not accessible to procmail, it relied solely
Xon kernel locks.
X.Tp
XExecuting "x"
XStarting program "x". If it is started by procmail directly (without an
Xintermediate shell), procmail will show where it separated the arguments
Xby inserting commas.
X.Tp
XHOST mismatched "x"
XThis host was called "x", HOST contained something else.
X.Tp
XLocking "x"
XCreating lockfile "x".
X.Tp
XLinking to "x"
XCreating a hardlink between directory folders.
X.Tp
XMatch on "x"
XCondition matched.
X.Tp
XNo match on "x"
XCondition didn't match, recipe skipped.
X.Tp
XNotified comsat: "$LOGNAME@offset:file"
XSent comsat/biff a notice that mail arrived for user $LOGNAME at `offset'
Xin `file'.
X.Tp
XOpening "x"
XOpening file "x" for appending.
X.Tp
XRcfile: "x"
XRcfile changed to "x".
X.Tp
XUnlocking "x"
XRemoving lockfile "x" again.
X.Sh WARNINGS
XYou should create a shell script that uses
X.BR lockfile (1)
Xbefore invoking your mail shell on any mailbox file other than the system
Xmailbox (unless of course, your mail shell uses the same lockfiles (local
Xor global) you specified in your rcfile).
X.PP
XIn the unlikely event that you absolutely need to kill procmail before it has
Xfinished, first try and use the regular kill command (i.e.
X.I not
Xkill -9, see the subsection
X.I Signals
Xfor suggestions), otherwise some
X.I lockfiles
Xmight not get removed.
X.PP
XBeware when using the
X.B \-@TEMPFAILOPT@
Xoption, if procmail repeatedly is unable to deliver the mail (e.g. due to
Xan incorrect rcfile), the system mailqueue could fill up. This could
Xaggravate both the local postmaster and other users.
X.Sh BUGS
XAfter removing a lockfile by force, procmail waits $SUSPEND seconds before
Xcreating a new lockfile so that another process that decides to remove the
Xstale lockfile will not remove the newly created lock by mistake.
X.PP
XProcmail uses the regular TERMINATE signal to terminate any runaway filter,
Xbut it does not check if the filter responds to that signal and it only sends
Xit to the filter itself, not to any of the filter's children.
X.Sh MISCELLANEOUS
XWhen appending to regular mailfolders any lines in the body of the message that
Xlook like postmarks are prepended with `@ESCAP@' (disarms bogus mailheaders).
XThe regular expression that is used to search for these postmarks is:
X.Rs
X`@FROM_EXPR@'
X.Re
X.PP
XIf the destination name used in explicit delivery mode is not in /etc/passwd,
Xprocmail will proceed as if explicit delivery mode was not in effect.
XIf not in explicit delivery mode and
Xshould the uid procmail is running under, have no corresponding /etc/passwd
Xentry, then HOME will default to @RootDir@, LOGNAME will default to #uid and
XSHELL will default to @BinSh@.
X.PP
XWhen in explicit delivery mode, procmail will generate a leading `@FROM@'
Xline if none is present. If one is already present@TRUSTED_IDS@ procmail will
Xleave it intact.
X.PP
XFor security reasons procmail will only use an rcfile if it is owned by the
Xrecipient or if the directory it is contained in, is not world writeable.
X.PP
XIf @SYSTEM_MBOX@ is a bogus mailbox (i.e. does not belong to the recipient,
Xis unwriteable, is a symbolic link or is a hard link), procmail will upon
Xstartup try to rename it into a file starting with `@BOGUSprefix@' and
Xending in an inode-sequence-code. If this turns out to be impossible,
X.B ORGMAIL
Xwill have
X.I no
Xinitial value, and hence will inhibit delivery without a proper rcfile.
X.PP
XWhen delivering to directories (or to MH folders) you
X.B don't
Xneed to use lockfiles to prevent several concurrently running procmail
Xprograms from messing up.
X.PP
XDelivering to MH folders is slightly more time consuming than delivering
Xto normal directories or mailboxes, because procmail has to search for
Xthe next available number (instead of having the filename immediately
Xavailable).
X.PP
XOn general failure procmail will return EX_CANTCREAT, unless option
X.B \-@TEMPFAILOPT@
Xis specified, in which case it will return EX_TEMPFAIL.
X.PP
XTo make `egrepping' of headers more consistent, procmail concatenates all
Xcontinued header fields; but only internally. When delivering the mail, line
Xbreaks will appear as before.
X.PP
XIf procmail is called under a different name than `procmail' (i.e. if it
Xis linked to another name and invoked as such), it comes up in explicit
Xdelivery mode, and expects the recipients' names as command line arguments
X(as if \-@DELIVEROPT@ had been specified).
X.PP
XComsat/biff notifications are done using @COMSATprotocol@. They are sent off
Xonce when procmail generates the regular logfile entry. The notification
Xmessages have the following extended format (or as close as you can get when
Xfinal delivery was not to a file):
X.Rs
X$LOGNAME@offset_of_message_in_mailbox@COMSATxtrsep@absolute_path_to_mailbox
X.Re
X.PP
XWhenever procmail itself opens a file to deliver to, it
X@KERNEL_LOCKING@.
X.PP
XProcmail is NFS-resistant and eight-bit clean.
X.br
X.ne 11
X.Sh NOTES
XCalling up procmail with the \-@HELPOPT1@ or \-@HELPOPT2@ options will cause
Xit to display a command-line help and recipe flag quick-reference page.
X.PP
X@CF_procmail@
XIn this case your $HOME/@DOT_FORWARD@ (beware, it
X.B has
Xto be world readable) file should contain the line below. Be sure to include
Xthe single and double quotes, and it
X.I must
Xbe an
X.I absolute
Xpath. The `#YOUR_LOGIN_NAME' is not actually a parameter that is required by
Xprocmail, in fact, it will be discarded by sh before procmail ever sees it;
Xit is however a necessary kludge against overoptimising sendmail programs:
X.PP
X.na
X.nf
X@FW_content@
X.fi
X.ad
X.PP
XProcmail can also be invoked to postprocess an already filled system
Xmailbox. This can be useful if you don't want to or can't use a
X$HOME/@DOT_FORWARD@ file (in which case the following script could
Xperiodically be called from within
X.BR cron (1),
Xor whenever you start reading mail):
X.Rs
X#!/bin/sh
X
Xif test -s $@SYSTEM_MBOX@
Xthen
X umask 077
X lockfile \-l3600 $HOME/.newmail.lock
X lockfile \-l3600 \-ml
X cat @SYSTEM_MBOX@ >>$HOME/.newmail &&
X cat /dev/null >@SYSTEM_MBOX@
X lockfile \-mu
X formail \-@FM_SPLIT@ procmail <$HOME/.newmail
X rm \-f $HOME/.newmail $HOME/.newmail.lock
Xfi
Xexit 0
X.Re
X.br
X.ne 14
X.Ss "A sample small @PROCMAILRC@:"
X.na
X.nf
XPATH=/bin:/usr/bin:@BINDIR@
XMAILDIR=$HOME/Mail #you'd better make sure it exists
XDEFAULT=$MAILDIR/mbox
XLOGFILE=$MAILDIR/from
X:0:
X* ^From.*berg
Xfrom_me
X:0
X* ^Subject:.*Flame
X/dev/null
X.fi
X.ad
END_OF_FILE
if test 17351 -ne `wc -c <'procmail/man/procmail.man'`; then
echo shar: \"'procmail/man/procmail.man'\" unpacked with wrong size!
fi
# end of 'procmail/man/procmail.man'
fi
if test -f 'procmail/src/autoconf' -a "${1}" != "-c" ; then
echo shar: Will not clobber existing file \"'procmail/src/autoconf'\"
else
echo shar: Extracting \"'procmail/src/autoconf'\" \(27101 characters\)
sed "s/^X//" >'procmail/src/autoconf' <<'END_OF_FILE'
X#! /bin/sh
X:
X#$Id: autoconf,v 1.56 1993/06/23 14:35:13 berg Exp $
X
X# All possible entries in autoconf.h:
X
X# #define UNISTD_H_MISSING
X# #define STDDEF_H_MISSING
X# #define STDLIB_H_MISSING
X# #define DIRENT_H_MISSING
X# #define SYS_DIRENT_H_MISSING
X# #define NDIR_H_MISSING
X# #define SYS_NDIR_H_MISSING
X# #define SYS_DIR_H_MISSING
X# #define SYS_WAIT_H_MISSING
X# #define SYS_UTSNAME_H_MISSING
X# #define STRING_H_MISSING
X# #define SYSEXITS_H_MISSING
X#Ok #define SYS_FILE_H_MISSING
X# #define const
X# #define volatile
X# #define P(args) ()
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 off_t;
X# typedef long time_t;
X# #define NOmemmove
X# #define NObcopy
X# #define NOstrcspn
X# #define NOstrpbrk
X# #define NOopendir
X# #define NOrename
X# #define NOsetrgid
X# #define NOsetregid
X# #define NOmkdir
X# #define NOuname
X# #define NOstrstr
X# #define NOstrtol
X# #define strchr(s,c) index(s,c)
X# #define initgroups(n,g)
X#Ok #define endpwent()
X#Ok #define endgrent()
X#Ok #define endhostent()
X#Ok #define endservent()
X#Ok #define endprotoent()
X# #define h_0addr_list h_addr
X#Ok #define NO_COMSAT
X# #define _GUID_T
X#Ok #define UDP_protocolno 17
X#Ok #define BIFF_serviceport "512"
X#Ok #define IP_localhost {127,0,0,1,}
X# #define WMACROS_NON_POSIX
X# #define oBRAIN_DAMAGE
X#Ok #define LD_ENV_FIX
X#Ok #define GOT_bin_test
X#Ok #define SMALLHEAP
X# #define NOfcntl_lock
X#Ok #define USElockf
X#Ok #define USEflock
X#Ok #define SYSTEM_MAILBOX "/usr/spool/mail/$LOGNAME"
X#Ok #define SENDMAIL "/usr/lib/sendmail"
X#Ok #define CF_no_procmail_yet
X
X# A conforming ANSI compiler and POSIX library should not have any defines not
X# marked as "Ok" in the autoconf.h file.
X# Anything else indicates failure of your system to comply with either
X# the ANSI or POSIX standards (but procmail should be installable anyway).
X
XSHELL=$1
XPATH=.:$PATH
Xshift; RM="$1"
Xshift; MV="$1"
Xshift; DEVNULL=$1
Xshift; FGREP="$1"
Xshift; MAKE="$1"
Xshift; O=$1
Xshift; LOCKINGTEST="$1"
Xshift; ACONF=$1
X
Xtest 1 != $# &&
X echo "Don't start this script directly, use \`make ../autoconf.h'" && exit 1
X
Xexport SHELL PATH
X
XOLDTESTDIRS=""
Xtailpid=""
Xecho "" >_locktst.pid
X
Xif test -f $ACONF
Xthen
X trap "kill \`cat _locktst.pid\` 2>$DEVNULL;cp $ACONF $ACONF.tmp
X $RM -r \$OLDTESTDIRS;test ! -z \"\$tailpid\" && kill \$tailpid 2>$DEVNULL
X kill \`cat _locktst.pid\` 2>$DEVNULL; exit 1" 1 2 3 15
Xelse
X trap "kill \`cat _locktst.pid\` 2>$DEVNULL;$RM -r \$OLDTESTDIRS $ACONF.tmp
X mv $ACONF $ACONF.tmp 2>$DEVNULL
X test ! -z \"\$tailpid\" && kill \$tailpid 2>$DEVNULL
X kill \`cat _locktst.pid\` 2>$DEVNULL; exit 1" 1 2 3 15
Xfi
X
Xnocore=yes
Xtest -f core && nocore=no
X
Xcat 2>&1 <<HERE
X==============================================================================
XIn order for the kernel-locking tests to work as intended I have to be able to
Xtest-lock files on as many semantically different filesystems as possible (for
Xmore information about this, READ PARAGRAPH TWO in INSTALL). To suppress this
Xprompt you can set the LOCKINGTEST variable in the Makefile.
X
XPlease add writeable directories to the list. You should only add directories
Xthat reside on filesystems that have unique characterics. E.g. if you have
Xseveral remote NFS partitions, pick some unique client-server pairs, there is
Xlittle use in picking the same server twice from the same client-machine.
XAn excellent candidate would be a remotely mounted mail spool directory.
X==============================================================================
XHERE
X
Xtestdirs="/tmp ."
Xb=dummy
Xwhile test ! -z "$b"
Xdo
X echo 2>&1 ""
X b=""
X OLDTESTDIRS="$TESTDIRS"
X TESTDIRS=""
X for a in $testdirs
X do $RM -r $a/_locktest
X if mkdir $a/_locktest
X then
X b="$b $a"
X TESTDIRS="$TESTDIRS $a/_locktest"
X else
X echo 2>&1 "Can't create $a/_locktest"
X fi
X done
X OLDTESTDIRS="$TESTDIRS"
X testdirs="$b"
X echo 2>&1 ""
X echo 2>&1 "I will temporarily use a testdirectory named _locktest"
X echo 2>&1 "in the following directories:"
X echo 2>&1 ""
X echo 2>&1 $testdirs
X echo 2>&1 ""
X echo 2>&1 "If you would like to add any, please specify them below,"
X echo 2>&1 "press return to continue:"
X echo 2>&1 ""
X if test -z "$LOCKINGTEST"
X then
X read b
X elif test dummy = "$LOCKINGTEST"
X then
X b=""
X else
X testdirs=""; b="$LOCKINGTEST"; LOCKINGTEST=dummy
X echo $b
X fi
X testdirs="$testdirs $b"
Xdone
X
Xcat >grepfor <<HERE
X$FGREP -e "\$1" _autotst.rrr >$DEVNULL && echo "\$2" >>$ACONF
XHERE
Xchmod 0755 grepfor
X
Xcat >$ACONF <<HERE
X/* This file was automagically generated by autoconf */
X
XHERE
X
Xecho >_locktst.h
X
X$RM _autotst.$O
X
Xcat >_autotst.c <<HERE
X#include "$ACONF"
X#include <sys/types.h>
X#include <time.h>
Xvoid*vvoid;
Xmain(){int i;char*p="t";
X {time_t vtime_t;i=vtime_t=1;}
X {off_t voff_t;i=voff_t=1;}
X vvoid=p;
X return !vvoid;}
X#include <unistd.h>
Xstruct {char a;char b;} setsid;
XHERE
X
Xif $MAKE _autotst.$O 2>&1 | $FGREP -v include/ >_autotst.rrr
X test -f _autotst.$O
Xthen
X echo "#define setsid()" >>_locktst.h
Xelse
X grepfor void '#define void char'
X grepfor time_t 'typedef long time_t;'
X grepfor off_t 'typedef long off_t;'
X if $FGREP setsid _autotst.rrr >$DEVNULL 2>&1
X then
X :
X else
X echo "#define setsid()" >>_locktst.h
X $MAKE _autotst.$O 2>&1 >$DEVNULL
X test -f _autotst.$O || echo "#define UNISTD_H_MISSING" >>$ACONF
X fi
Xfi
X
X$RM _autotst.$O _autotst
X
Xcat >_autotst.c <<HERE
X#include "$ACONF"
X#include <sys/types.h>
X#ifndef UNISTD_H_MISSING
X#include <unistd.h>
X#endif
X#include <fcntl.h>
X#ifndef SYS_FILE_H_MISSING
X#include <sys/file.h>
X#endif
Xmain(){
X#ifdef F_SETLKW
X fcntl(0,F_SETLKW,0);
X#endif
X#ifdef F_LOCK
X lockf(0,F_LOCK,(off_t)0);
X#endif
X#ifdef LOCK_EX
X flock(0,LOCK_EX);
X#endif
X return 0;}
XHERE
X
Xecho 'Initiating fcntl()/kernel-locking-support tests'
Xif $MAKE _autotst.$O >$DEVNULL 2>&1
Xthen
X:
Xelse
X $RM _autotst.$O
X echo "#define SYS_FILE_H_MISSING" >>$ACONF
X if $MAKE _autotst.$O >_autotst.rrr 2>&1
X then
X :
X else
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 kill -15 $$
X fi
Xfi
X$MAKE _autotst >_autotst.rrr 2>&1
X$RM _autotst.$O _autotst
X
X$FGREP fcntl _autotst.rrr >$DEVNULL && echo "#undef F_SETLKW" >>_locktst.h
X$FGREP lockf _autotst.rrr >$DEVNULL && echo "#undef F_LOCK" >>_locktst.h
X$FGREP flock _autotst.rrr >$DEVNULL && cat >>_locktst.h <<HERE
X#ifdef LOCK_EX
X#undef LOCK_EX
X#endif
X#ifndef SYS_FILE_H_MISSING
X#define SYS_FILE_H_MISSING
X#endif
XHERE
X
Xcat >_autotst.c <<HERE
X#include "$ACONF"
X#include "../config.h"
X#include <sys/types.h>
X#ifndef UNISTD_H_MISSING
X#include <unistd.h> /* getpid() getppid() */
X#endif
X#include <stdio.h>
X#include <time.h>
X#include <fcntl.h>
X#include <signal.h> /* SIGKILL */
X#ifndef tell
X#define tell(fd) lseek(fd,(off_t)0,SEEK_CUR)
X#endif
X#define EX_OK 0
X#include "_locktst.h"
X#ifndef SYS_FILE_H_MISSING
X#include <sys/file.h>
X#endif
X#ifndef SEEK_SET
X#define SEEK_SET 0
X#define SEEK_CUR 1
X#define SEEK_END 2
X#endif
X
X#define MIN_locks 128 /* minimum of consecutive successful locks */
X#define SLEEP_loop 64 /* iterations in the busy loop */
X#define SLEEP_delay 0 /* sleep() time per busy iteration */
X#define SLEEP_retreat 1 /* extra sleep() when quota reached */
X#define TIME_OUT_SEC 16 /* initial timeout per lock */
X#define NR_of_forks 8 /* concurrent test-programs */
X#define NR_of_lockfiles 2 /* lockfiles used in testing (<=4) */
X#define GROW 3 /* when timing got worse */
X#define DECAY 7/8 /* when timing got better */
X#define GOBBLE 256 /* for the SunOS crash test */
X
X#define LOCKS_per_child (((MIN_locks+NR_of_forks-1)/NR_of_forks+1)/2)
X#define SHIFT_childno 3
X#define MASK_fileno ((1<<SHIFT_childno)-1)
X#define MASK_childno (~MASK_fileno)
X
X#ifdef NO_fcntl_LOCK
X#undef F_SETLKW
X#endif
X#ifdef NO_lockf_LOCK
X#undef F_LOCK
X#endif
X#ifdef NO_flock_LOCK
X#undef LOCK_EX
X#endif
X
X#define FIRST_lock 0x04 /* testing is in order of importance */
X#define MSK_fcntl 0x04 /* don't change this order unless you */
X#define MSK_lockf 0x02 /* change locking.c as well, fdlock() */
X#define MSK_flock 0x01
X
Xint dolock,child[NR_of_forks],timeout,fdcollect;
Xchar dirlocktest[]="_locktest";
X
Xvoid stimeout()
X{ timeout=1;close(fdcollect);killchildren();
X}
X
Xvoid terminate()
X{ stimeout();exit(1);
X}
X
Xstatic unsigned long seed;
X
Xunsigned psrand()
X{ return(unsigned)(seed*=69069L)>>8;
X}
X
Xunsigned sfork()
X{ int pid;
X while((pid=fork())<0)
X fprintf(stderr,"Couldn't fork _locktst, retrying\n"),sleep(TIME_OUT_SEC);
X return pid;
X}
X
Xmain(argc,argv)char*argv[];
X{ int goodlock,testlock,i,pip[2],pipw[2];unsigned otimet,dtimet;
X static char filename[]="_locktst.l0";
X close(0);goodlock=0;testlock=FIRST_lock;signal(SIGPIPE,SIG_DFL);
X if(sfork()) /* try to ditch the controlling tty */
X return EX_OK; /* mainly to prevent rather messy kernel-diagnostics */
X setsid(); /* from appearing on your tty */
X do
X { int countlocks;
X signal(SIGTERM,SIG_DFL);argc=1;dolock=goodlock|testlock;
X do
X { char*curdir;
X curdir=argv[argc];otimet=time((time_t*)0);
X if(sfork())
X { close(1);close(2);i=NR_of_lockfiles;chdir(curdir);
X chdir(dirlocktest);
X do /* prime the lock, see if it vanishes */
X { filename[sizeof filename-2]='0'+--i;
X lseek(goodlock=open(filename,O_WRONLY),(off_t)0,SEEK_END);
X fdlock(goodlock);
X }
X while(i);
X for(;;) /* synchronising "busy"-wait */
X sleep(TIME_OUT_SEC); /* until the games can be started */
X }
X sleep(1);pipe(pip);pipe(pipw);i=NR_of_forks;*child=0;
X fprintf(stderr,"\nStarting test %x on %s\n",dolock,curdir);
X while((child[--i]=sfork())&&i); /* divide and conquer */
X if(!*child)
X { unsigned char lockflag;int fd,childno=i<<SHIFT_childno;
X int mylocks=LOCKS_per_child;
X close(pipw[0]);close(pip[0]);close(1);
X seed=time((time_t*)0)+getpid()|1;chdir(curdir);chdir(dirlocktest);
X close(pipw[1]);
X for(;;) /* and lock away! */
X { filename[sizeof filename-2]='0'+(i=psrand()%NR_of_lockfiles);
X lockflag=childno|i<<1|1;
X lseek(fd=open(filename,O_WRONLY),(off_t)0,SEEK_END);
X if(sfdlock(fd))
X lockflag&=~1,fprintf(stderr,"XX%02x",lockflag);
X write(pip[1],&lockflag,1);
X fprintf(stderr,"%2x%02x",i,childno>>SHIFT_childno);
X lseek(fd,(off_t)0,SEEK_END);write(fd,&lockflag,1);
X for(i=SLEEP_loop;i;i--,time((time_t*)0),sleep(SLEEP_delay));
X lockflag&=~1;write(pip[1],&lockflag,1);
X if(fdunlock()||close(fd))
X { write(pip[1],&lockflag,1);fprintf(stderr,"XX%02x",lockflag);
X return 1;
X }
X if(--mylocks<0)
X sleep(SLEEP_retreat);
X }
X }
X signal(SIGTERM,terminate);
X ;{ unsigned char lckdfil[NR_of_lockfiles],curflag;
X int j,ppid; /* give all children a chance */
X ppid=getppid();
X if(sfork()) /* discard the old body, let init adopt our children */
X return EX_OK;
X ;{ FILE*fp;
X if(fp=fopen("_locktst.pid","w"))
X fprintf(fp,"%ld",(long)getpid()),fclose(fp);
X }
X countlocks=MIN_locks;close(pip[1]);close(pipw[1]);
X for(j=NR_of_lockfiles;lckdfil[--j]=0,j;);
X timeout=0;sleep(1);read(pipw[0],&curflag,1);close(pipw[0]);
X kill(ppid,SIGKILL);fdcollect=pip[0];signal(SIGALRM,stimeout);
X dtimet=(((unsigned)time((time_t*)0)-otimet)*GROW)+TIME_OUT_SEC;
X do
X { unlink("_locktst.alive");alarm(dtimet+2); /* watchdog */
X dtimet=(otimet=time((time_t*)0)-otimet)>dtimet?
X otimet*GROW:otimet+(dtimet-otimet)*DECAY+1; /* load dependent */
X otimet=time((time_t*)0);
X }
X while(1==read(fdcollect,&curflag,1)&&
X (j=lckdfil[i=(curflag&MASK_fileno)>>1],!timeout)&&
X ((j^(lckdfil[i]=curflag))==1||!(j&1)&&curflag&1)&&--countlocks);
X alarm(0);close(fdcollect);killchildren();
X fprintf(stdout,
X "/*locktype: %x, countlocks: %x, timeout %x, watchdog %x, %s*/\n",
X dolock,countlocks,timeout,dtimet,curdir);fflush(stdout);
X }
X }
X while(!countlocks&&argv[++argc]);
X if(!countlocks) /* Hurray! Locking was flawless */
X goodlock=dolock; /* make a mark on our colt */
X }
X while(testlock>>=1);
X if(!(goodlock&MSK_fcntl)) /* report our findings */
X puts("#define NOfcntl_lock");
X if(goodlock&MSK_lockf)
X puts("#define USElockf");
X if(goodlock&MSK_flock)
X { puts("#define USEflock");
X#ifdef SYS_FILE_H_MISSING
X puts("#define SYS_FILE_H_MISSING");
X#endif
X }
X puts("Kernel-locking tests completed.");
X return EX_OK;
X}
X
Xkillchildren()
X{ int i;
X i=NR_of_forks;
X do
X if(child[--i]>0)
X kill(child[i],SIGTERM),child[i]=0;
X while(i);
X}
X
Xsfdlock(fd)
X{ int i;unsigned gobble[GOBBLE>>2];
X for(i=GOBBLE>>2;i;gobble[--i]=~(unsigned)0); /* SunOS crash test */
X return fdlock(fd);
X}
X
Xstatic oldfdlock;
X#ifdef F_SETLKW
Xstatic struct flock flck; /* why can't it be a local variable? */
X#endif
X#ifdef F_LOCK
Xstatic off_t oldlockoffset;
X#endif
X
Xfdlock(fd)
X{ int i;unsigned gobble[GOBBLE>>2];
X for(i=GOBBLE>>2;i;gobble[--i]=~(unsigned)0); /* SunOS crash test */
X oldfdlock=fd;fd=0;
X if(MSK_fcntl&dolock)
X#ifdef F_SETLKW
X { flck.l_type=F_WRLCK;flck.l_whence=SEEK_SET;flck.l_len=0;
X flck.l_start=tell(oldfdlock);fd|=fcntl(oldfdlock,F_SETLKW,&flck);
X }
X#else
X fd=1;
X#endif
X if(MSK_lockf&dolock)
X#ifdef F_LOCK
X oldlockoffset=tell(oldfdlock),fd|=lockf(oldfdlock,F_LOCK,(off_t)0);
X#else
X fd=1;
X#endif
X if(MSK_flock&dolock)
X#ifdef LOCK_EX
X fd|=flock(oldfdlock,LOCK_EX);
X#else
X fd=1;
X#endif
X return fd;
X}
X
Xfdunlock()
X{ int i;unsigned gobble[GOBBLE];
X for(i=GOBBLE;i;gobble[--i]=~(unsigned)0); /* SunOS crash test */
X if(MSK_flock&dolock)
X#ifdef LOCK_EX
X i|=flock(oldfdlock,LOCK_UN);
X#else
X i=1;
X#endif
X if(MSK_lockf&dolock)
X#ifdef F_LOCK
X { lseek(oldfdlock,oldlockoffset,SEEK_SET);
X i|=lockf(oldfdlock,F_LOCK,(off_t)2);i|=lockf(oldfdlock,F_ULOCK,(off_t)0);
X }
X#else
X i=1;
X#endif
X if(MSK_fcntl&dolock)
X#ifdef F_SETLKW
X { flck.l_len=2;i|=fcntl(oldfdlock,F_SETLK,&flck);flck.l_type=F_UNLCK;
X flck.l_len=0;i|=fcntl(oldfdlock,F_SETLK,&flck);
X }
X#else
X i=1;
X#endif
X if(!i)
X for(i=GOBBLE;i&&gobble[--i]==~(unsigned)0;);
X return i;
X}
XHERE
X
Xif $MAKE _autotst >_autotst.rrr 2>&1
Xthen
X:
Xelse
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 LDFLAGS*"
X echo 2>&1 "in the Makefile before you try make again."
X kill -15 $$
Xfi
X
X$MV _locktst _locktst.$$ 2>$DEVNULL
X$RM _autotst.$O _autotst.rrr locktst* 2>$DEVNULL
X$MV _autotst _locktst
X
Xfor b in $TESTDIRS
Xdo
X for a in 0 1 2 3
X do echo dummy_file >$b/_locktst.l$a
X done
Xdone
X
Xecho 2>&1 ""
X
X_locktst $TESTDIRS >_locktst.rrr 2>lock.log # will finish in the background
Xecho 'Proceeding with kernel-locking-support tests in the background'
X
Xcat >_autotst.c <<HERE
X#include "$ACONF"
X#ifndef UNISTD_H_MISSING
X#include <unistd.h> /* execvp() */
X#endif
Xmain()
X{ char r[]="",*const*p;char*q="";const char*s="";
X static struct{const int a;int b;}c[2];
X --(c+1)->b; /* AIX 3.1.5 machines can't do this */
X p= &q;
X execvp(q,p); /* IRIX 4.0.1 system-include files are wrong on this point */
X return r==s; /* Domain/OS warns here, not about "s==r" though */
X}
XHERE
X
Xecho 'Testing for const'
Xif $MAKE _autotst.$O 2>&1 | $FGREP -v include/ >_autotst.rrr
X test -f _autotst.$O
Xthen
X grepfor const '#define const'
Xelse
X echo '#define const' >>$ACONF
Xfi
X$RM _autotst.$O
X
Xcat >_autotst.c <<HERE
Xmain(){volatile int i;return(i=0);}
XHERE
X
Xecho 'Testing for volatile'
Xif $MAKE _autotst.$O >$DEVNULL 2>&1 && test -f _autotst.$O
Xthen
X:
Xelse
X echo '#define volatile' >>$ACONF
Xfi
X$RM _autotst.$O
X
Xif $FGREP const $ACONF >$DEVNULL
Xthen
X echo '#define P(args) ()' >>$ACONF
Xelse
X cat >_autotst.c <<HERE
Xmain(const argc,const char*const argv[]){return argc;}
XHERE
X
X echo 'Testing for prototypes'
X if $MAKE _autotst.$O >$DEVNULL 2>&1 && test -f _autotst.$O
X then
X :
X else
X echo '#define P(args) ()' >>$ACONF
X fi
X $RM _autotst.$O
Xfi
X
Xecho 'Checking for POSIX and ANSI system include files'
X
Xcat >_autotst.c <<HERE
X#include "includes.h"
Xint a;
XHERE
X
Xi0="";i1="";i2="";i3="";i4="";i5="";i6="";i7="";i8="";i9="";i10="";
Xoldi=""
X
Xwhile $MAKE _autotst.$O 2>&1 | $FGREP -v include/ >_autotst.rrr
X test ! -f _autotst.$O
Xdo
X test -z "$i0" && grepfor stddef.h "#define STDDEF_H_MISSING" && i0=I
X test -z "$i1" && grepfor stdlib.h "#define STDLIB_H_MISSING" && i1=I
X test -z "$i2" && grepfor dirent.h "#define DIRENT_H_MISSING" && i2=I
X test -z "$i3" && grepfor ndir.h "#define NDIR_H_MISSING" && i3=I
X test I = "$i3$i4" && grepfor sys/ndir.h "#define SYS_NDIR_H_MISSING" && i4=I
X test I = "$i4$i5" && grepfor sys/dir.h "#define SYS_DIR_H_MISSING" && i5=I
X test I = "$i5$i6" && grepfor sys/dirent.h "#define SYS_DIRENT_H_MISSING" \
X && i6=I
X test -z "$i7" && grepfor sys/wait.h "#define SYS_WAIT_H_MISSING" && i7=I
X test -z "$i8" && grepfor sys/utsname.h "#define SYS_UTSNAME_H_MISSING" &&
X i8=I
X test -z "$i9" && grepfor string.h "#define STRING_H_MISSING" && i9=I
X test -z "$i10" && grepfor sysexits.h "#define SYSEXITS_H_MISSING" && i10=I
X newi="$i0$i1$i2$i3$i4$i5$i6$i7$i8$i9$i10"
X if test a$oldi = a$newi
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 $MAKE _autotst.$O >_autotst.rrr 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*"
X echo 2>&1 "in the Makefile before you try make again."
X kill -15 $$
X fi
X oldi=$newi
X echo \
X " ...missing `expr $oldi : '.*'` include files, doublechecking..."
Xdone
X
X$RM _autotst.$O
X
Xcat >_autotst.c <<HERE
X#include "includes.h"
X#include "network.h"
Xint a;
XHERE
X
Xecho 'Checking for network/comsat/biff support'
X
Xif $MAKE _autotst.$O 2>&1 | $FGREP -v include/ >_autotst.rrr
X test -f _autotst.$O
Xthen
X:
Xelse
X echo "#define NO_COMSAT" >>$ACONF
Xfi
X
X$RM _autotst.$O
X
Xcat >_autotst.c <<HERE
X#include "includes.h"
X#ifndef NO_COMSAT
X#include "network.h"
X#endif
Xmain(){int i;
X {size_t vsize_t;i=vsize_t=1;}
X {pid_t vpid_t;i=vpid_t=1;}
X {mode_t vmode_t;i=vmode_t=1;}
X {uid_t vuid_t;i=vuid_t=1;}
X {gid_t vgid_t;i=vgid_t=1;}
X#ifndef NO_COMSAT
X {struct hostent host;i=!(host.h_addr_list=0);}
X#endif
X return !i;}
XHERE
X
Xecho 'Testing for void*,size_t,off_t,pid_t,time_t,mode_t,uid_t,gid_t'
X$MAKE _autotst.$O 2>&1 | $FGREP -v include/ >_autotst.rrr
X$RM _autotst.$O
X
Xgrepfor size_t 'typedef unsigned size_t;'
Xgrepfor pid_t 'typedef int pid_t;'
Xgrepfor mode_t 'typedef int mode_t;'
Xgrepfor uid_t 'typedef int uid_t;'
Xgrepfor gid_t 'typedef int gid_t;'
Xgrepfor h_addr_list '#define h_0addr_list h_addr' ||
X grepfor struct '#define h_0addr_list h_addr'
X
Xcat >_autotst.c <<HERE
X#include "includes.h"
Xmain(){int i;i=1;
X i+=WIFEXITED(i);
X i+=WIFSTOPPED(i);
X i+=WEXITSTATUS(i);
X return i;}
XHERE
X
Xecho 'Testing for WIFEXITED(), WIFSTOPPED() & WEXITSTATUS()'
Xif $MAKE _autotst.$O 2>&1 | $FGREP -v include/ >_autotst.rrr
Xthen
X grepfor struct '#define WMACROS_NON_POSIX' ||
X grepfor union '#define WMACROS_NON_POSIX'
Xelse
X echo '#define WMACROS_NON_POSIX' >>$ACONF
Xfi
X$RM _autotst.$O
X
Xcat >_autotst.c <<HERE
X#include "includes.h"
X#ifndef NO_COMSAT
X#include "network.h"
X#endif
Xmain(){char a[2];
X endpwent();endgrent();memmove(a,"0",1);bcopy("0",a,1);strcspn(a,"0");
X strtol("0",(char**)0,10);strchr("0",'0');strpbrk(a,"0");rename(a,"0");
X setrgid(0);setregid(0,0);opendir("0");initgroups("0",0);strstr("0","0");
X mkdir("0",0);
X#ifndef NOuname
X {struct utsname b;uname(&b);}
X#endif
X#ifndef NO_COMSAT
X gethostbyname("0");getprotobyname(COMSATprotocol);endhostent();endservent();
X endprotoent();
X#endif
X return 0;}
XHERE
X
Xecho 'Testing for memmove, strchr, strpbrk, strcspn, strtol, strstr,'
Xecho ' rename, setrgid, opendir & mkdir'
Xif $MAKE _autotst.$O >_autotst.rrr 2>&1
Xthen
X:
Xelse
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 "Your include files seem to be beyond repair <sigh>."
X echo 2>&1 "I give up."
X kill -15 $$
Xfi
X$MAKE _autotst 2>&1 | $FGREP -v include/ >_autotst.rrr
X$RM _autotst _autotst.$O
X
Xgrepfor strcspn '#define NOstrcspn'
Xgrepfor strpbrk '#define NOstrpbrk'
Xgrepfor opendir "
X#define NOopendir /* the readdir library does not seem to be available
X this will slightly affect the way a filenumber is
X selected in MH-folders by procmail */
X"
Xgrepfor rename '#define NOrename'
Xgrepfor setrgid '#define NOsetrgid' &&
X grepfor setregid '#define NOsetregid'
Xgrepfor mkdir '#define NOmkdir'
Xgrepfor strchr '#define strchr(s,c) index(s,c)'
Xgrepfor uname "\
X#define NOuname \
X/* the include files define it, the libraries don't */"
Xgrepfor initgroups '#define initgroups(n,g)'
Xgrepfor endpwent '#define endpwent()'
Xgrepfor endgrent '#define endgrent()'
Xif grepfor gethostbyname '#define NO_COMSAT'
Xthen
X:
Xelse
X grepfor getprotobyname '#define UDP_protocolno 17'
X grepfor endhostent '#define endhostent()'
X grepfor endservent '#define endservent()'
X grepfor endprotoent '#define endprotoent()'
Xfi
Xgrepfor strtol '#define NOstrtol'
Xgrepfor strstr '#define NOstrstr'
Xgrepfor memmove '#define NOmemmove' &&
Xif $FGREP -e bcopy _autotst.rrr >$DEVNULL
Xthen
X echo '#define NObcopy' >>$ACONF
X
X echo 'Testing for brain damage'
X cat >_autotst.c <<HERE
X#include "includes.h"
Xstruct tests{int a,b;};
Xmain(){
X return offsetof(struct tests,b);}
XHERE
X if $MAKE _autotst.$O >$DEVNULL 2>&1
X then
X :
X else
X echo 'Yep, it is' # ISC chokes on its own offsetof()
X echo '#define oBRAIN_DAMAGE' >>$ACONF
X fi
X $RM _autotst.$O
X
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 >$DEVNULL 2>&1
X
X if _autotst
X then
X echo 'Sorry, incompetent bcopy'
X echo '#define NObcopy' >>$ACONF
X fi
X $RM _autotst
Xfi
X
X$FGREP -e LD_ /bin/ld >/dev/null 2>&1 && echo "#define LD_ENV_FIX" >>$ACONF
Xtest -f /bin/test && echo "#define GOT_bin_test" >>$ACONF
X
Xcat >_autotst.c <<HERE
X#include "includes.h"
X#ifndef NO_COMSAT
X#include "network.h" /* also for ntohs() */
X#endif
Xmain(argc)
X{ unsigned long s=(size_t)~0;int i;
X for(i=1;s>>=1;i++);
X if(argc==1)
X {
X#ifndef NO_COMSAT
X#ifndef UDP_protocolno
X ;{ const struct protoent*p;
X if(p=getprotobyname(COMSATprotocol))
X { printf("#define UDP_protocolno %d\n",p->p_proto);
X#else
X ;{ if(1)
X {
X#endif
X ;{ const struct servent*serv;
X if(serv=getservbyname(COMSATservice,COMSATprotocol))
X printf("#define BIFF_serviceport \"%d\"\n",
X ntohs(serv->s_port));
X }
X#ifdef AF_INET
X ;{ const struct hostent*host;
X if(!strcmp("localhost",COMSAThost)&&
X (host=gethostbyname(COMSAThost))&&
X host->h_0addr_list&&host->h_addrtype==AF_INET&&
X host->h_length)
X { int j=host->h_length;
X const unsigned char*ad=(void*)host->h_0addr_list;
X printf("#define IP_localhost {");
X do printf("%d,",*ad++);
X while(--j);
X puts("}");
X }
X }
X#endif /* AF_INET */
X }
X else
X puts("#define NO_COMSAT");
X }
X#endif /* NO_COMSAT */
X if(i<=16)
X { puts("#define SMALLHEAP");return 1;
X }
X#ifdef _GUID_T /* ISC cc hack */
X ;{ struct passwd*p;
X if(sizeof(int)>sizeof(uid_t)&&(p=getpwnam("root"))&&(*p->pw_dir!='/'||
X (*p->pw_shell&&!(p->pw_shell)[1])))
X puts("#define _GUID_T\ntypedef int uid_t;\ntypedef int gid_t;");
X }
X#endif
X }
X#ifdef SYSTEM_MBOX
X if(argc==2)
X { printf("#define SYSTEM_MAILBOX %s\n",SYSTEM_MBOX);return 1;
X }
X#endif
X#ifdef DEFsendmail
X if(argc==3)
X { printf("#define SENDMAIL %s\n",DEFsendmail);return 1;
X }
X#endif
X return 0;
X}
XHERE
X
Xecho 'Determining the most applicable block size'
X
X$MAKE _autotst >$DEVNULL 2>&1
X_autotst >>$ACONF
X
Xfound=no
Xfor a in /usr/spool/mail /usr/mail /var/spool/mail /var/mail /spool/mail
Xdo
X test -d $a -a $found != yes &&
X echo '#define SYSTEM_MAILBOX "'$a'/$LOGNAME"' >>$ACONF && found=yes
Xdone
Xif test $found != yes && _autotst 2 >>$ACONF
Xthen
X echo '#define SYSTEM_MAILBOX "$HOME/.mail"' >>$ACONF
X echo Could not find the system-mailbox directory, supplied substitute
Xfi
X
Xcat >lookfor <<HERE
Xfor a in /usr/lib /lib /usr/etc /etc /usr/bin /bin /usr/local/bin /usr/lbin \
X /usr/local/lib /usr/local /usr/.lib /local/bin
Xdo
X if test -f "\$a/\$1"
X then
X echo "#define SENDMAIL \"\$a/\$1\"" >>$ACONF
X exit 0
X fi
Xdone
Xexit 1
XHERE
Xchmod 0755 lookfor
X
Xif lookfor sendmail || lookfor smail || lookfor rmail || lookfor mail
Xthen
X:
Xelif _autotst 2 3 >>$ACONF
Xthen
X echo 'Could not find any mailer. It should be a mailer accepting at least'
X echo 'one plain destination address as its only argument (any sendmail'
X echo 'compatible mailer will do), and the mail-to-be-sent on stdin.'
X echo 'What is your mailer called? (You can override this in config.h)'
X read a
X echo "#define SENDMAIL \"$a\"" >>$ACONF
Xfi
X
Xcat /usr/lib/sendmail.cf /etc/sendmail.cf 2>$DEVNULL |
X grep 'Mlocal.*procmail' >$DEVNULL ||
X echo '#define CF_no_procmail_yet' >>$ACONF
X
Xwhile $FGREP -e "Kernel-locking tests completed." _locktst.rrr >$DEVNULL; \
X test 0 != $?
Xdo
X if test -z "$tailpid"
X then
X echo "Waiting for the kernel-locking tests to finish..."
X exec 9>&2 2>$DEVNULL
X tail -f lock.log &
X tailpid=$!
X exec 2>&9 9>&-
X fi
X# if test ! -f _locktst.alive
X# then
X# echo >_locktst.alive
X# echo "Waiting for kernel-locking tests to finish..."
X# fi
X sleep 4
Xdone
Xexec 9>&2 2>$DEVNULL
Xtest ! -z "$tailpid" && kill $tailpid && echo && echo
Xtailpid=""
Xexec 2>&9 9>&-
Xecho "Collecting results from kernel-locking tests"
Xsed -e '/^Kernel-locking tests completed./,$ d' <_locktst.rrr >>$ACONF
Xif test -f core -a $nocore = yes
Xthen
X echo "Removing core file (probably from the locking tests)"
X $RM core
Xfi
X
X$RM -r $OLDTESTDIRS 2>$DEVNULL
X$RM _autotst* _locktst* lookfor grepfor 2>$DEVNULL
X
Xecho =============================autoconf.h===================================
Xcat $ACONF
Xecho ==========================================================================
END_OF_FILE
if test 27101 -ne `wc -c <'procmail/src/autoconf'`; then
echo shar: \"'procmail/src/autoconf'\" unpacked with wrong size!
fi
chmod +x 'procmail/src/autoconf'
# end of 'procmail/src/autoconf'
fi
echo shar: End of archive 11 \(of 11\).
cp /dev/null ark11isdone
MISSING=""
for I in 1 2 3 4 5 6 7 8 9 10 11 ; do
if test ! -f ark${I}isdone ; then
MISSING="${MISSING} ${I}"
fi
done
if test "${MISSING}" = "" ; then
echo You have unpacked all 11 archives.
rm -f ark[1-9]isdone ark[1-9][0-9]isdone
else
echo You still need to unpack the following archives:
echo " " ${MISSING}
fi
## End of shell archive.
exit 0
--
Sincerely, berg@pool.informatik.rwth-aachen.de
Stephen R. van den Berg (AKA BuGless). berg@physik.tu-muenchen.de
"Always look on the bright side of life!"
exit 0 # Just in case...