home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1994 October / usenetsourcesnewsgroupsinfomagicoctober1994disk2.iso / misc / volume43 / procmail / part07 < prev    next >
Encoding:
Internet Message Format  |  1994-07-05  |  54.6 KB

  1. From: berg@pool.informatik.rwth-aachen.de (Stephen R. van den Berg)
  2. Newsgroups: comp.sources.misc
  3. Subject: v43i062:  procmail - mail processing package v3.03, Part07/10
  4. Date: 5 Jul 1994 20:50:14 -0500
  5. Organization: Sterling Software
  6. Sender: kent@sparky.sterling.com
  7. Approved: kent@sparky.sterling.com
  8. Message-ID: <2vd2km$ibo@sparky.sterling.com>
  9. X-Md4-Signature: c65bf62b00583bb4815408464adda8da
  10.  
  11. Submitted-by: berg@pool.informatik.rwth-aachen.de (Stephen R. van den Berg)
  12. Posting-number: Volume 43, Issue 62
  13. Archive-name: procmail/part07
  14. Environment: sendmail, ZMailer, smail, MMDF, mailsurr, UNIX, POSIX
  15. Supersedes: procmail: Volume 38, Issue 19-31
  16.  
  17. #! /bin/sh
  18. # This is a shell archive.  Remove anything before this line, then feed it
  19. # into a shell via "sh file" or similar.  To overwrite existing files,
  20. # type "sh file -c".
  21. # Contents:  procmail-3.03/FAQ procmail-3.03/examples/advanced
  22. #   procmail-3.03/initmake procmail-3.03/src/includes.h
  23. #   procmail-3.03/src/lockfile.c procmail-3.03/src/setid.c
  24. # Wrapped by kent@sparky on Tue Jul  5 20:42:14 1994
  25. PATH=/bin:/usr/bin:/usr/ucb:/usr/local/bin:/usr/lbin:$PATH ; export PATH
  26. echo If this archive is complete, you will see the following message:
  27. echo '          "shar: End of archive 7 (of 10)."'
  28. if test -f 'procmail-3.03/FAQ' -a "${1}" != "-c" ; then 
  29.   echo shar: Will not clobber existing file \"'procmail-3.03/FAQ'\"
  30. else
  31.   echo shar: Extracting \"'procmail-3.03/FAQ'\" \(9416 characters\)
  32.   sed "s/^X//" >'procmail-3.03/FAQ' <<'END_OF_FILE'
  33. X------------------------------------------------------------------------------
  34. X---------------------- Frequently Asked Questions ----------------------------
  35. X------------------------------------------------------------------------------
  36. X
  37. X1. How do I go about setting up a mailinglist or a mail-archive server?
  38. X
  39. X    Look in the SmartList directory, start reading the INTRO file,
  40. X    it describes it in detail and should get you started.
  41. X
  42. X2. I installed procmail (i.e. typed 'make install'), but how am I supposed to
  43. X   use it?  When I type procmail on the command line it simply does nothing.
  44. X
  45. X    You're not supposed to start procmail from the command line.
  46. X    Be sure to have a .forward and a .procmailrc file in your home
  47. X    directory (see the examples subdirectory or the man page).
  48. X    MMDF users should note that they need a .maildelivery file *instead*
  49. X    of a .forward file (see the man page for more detailed information).
  50. X
  51. X    If however, procmail has been integrated in the maildelivery system
  52. X    (i.e. if your system administrator installed it that way, ask him/her),
  53. X    then you no longer need the .forward files in your home directory,
  54. X    having a .procmailrc file will suffice.
  55. X
  56. X    On some systems .forward files are not checked.
  57. X    It might be possible that your system supports a command like:
  58. X        mail -F "|/usr/local/bin/procmail"
  59. X    to set up forwarding to a program.
  60. X    If that doesn't seem to work it might be worth trying to put a line
  61. X    looking like this:
  62. X        Forward to |/usr/local/bin/procmail
  63. X    or if that doesn't work, try:
  64. X        Pipe to /usr/local/bin/procmail
  65. X    as the only line in your mail spool file (e.g. /usr/mail/$LOGNAME), as
  66. X    well as doing a "chmod 06660 /usr/mail/$LOGNAME".  For more information
  67. X    on such systems, do a "man mail".
  68. X
  69. X    If all of this doesn't work, procmail can be called on a periodical
  70. X    basis, either via "cron", "at" or whenever you start reading mail (or
  71. X    log in).  For a sample script look in the NOTES section of the
  72. X    procmail(1) man page.
  73. X
  74. X3. When I compile everything the compiler complains about invalid or illegal
  75. X   pointer combinations, but it produces the executables anyway.
  76. X   Should I be concerned?
  77. X
  78. X    Ignore these warnings, they simply indicate that either your compiler
  79. X    or your system include files are not ANSI/POSIX compliant.
  80. X    The compiler will produce correct code regardless of these warnings.
  81. X
  82. X4. The compiler seems to issue warnings about "loop not entered at top",
  83. X   is that a problem?
  84. X
  85. X    No, no problem at all, it just means I wrote the code :-).
  86. X    That's just about the only uncommon coding technique I use (don't
  87. X    think I don't try to avoid those jumps in loops, it's just that
  88. X    sometimes they are the best way to code it).  Use gcc if you want
  89. X    to avoid these warnings.
  90. X
  91. X5. The compiler complains about unmodifiable lvalues or assignments to const
  92. X   variables.  Now what?
  93. X
  94. X    Well, if the compiler produces the executables anyway everything
  95. X    probably is all right.    If it doesn't, you might try inserting a
  96. X    "#define const" in the autoconf.h file by hand.     However in any case,
  97. X    your compiler is broken; I would recommend submitting this as a
  98. X    compiler bug to your vendor.  In any case, if this should occur, I'd
  99. X    appreciate a mail from you (so I can try to fix the autoconf script
  100. X    to recognise your compiler correctly as well).
  101. X
  102. X6. The compiler refuses to compile regexp.c, what is the problem?
  103. X
  104. X    Try compiling that module with optimisation turned off.
  105. X
  106. X7. When I send myself a testmail, the mail bounces with the message: cannot
  107. X   execute binary file.     What am I doing wrong?
  108. X
  109. X    It is very well possible that mail is processed on a different
  110. X    machine from that where you usually read your mail.  Therefore you
  111. X    have to make sure that procmail has the right binary format to
  112. X    execute on those machines on which mail could arrive.  In order to
  113. X    get this right you might need to do some .forward file tweaking,
  114. X    look at the examples/advanced file for some suggestions.
  115. X
  116. X8. Where do I look for examples about:
  117. X    One home directory, several machine architectures?
  118. X    Procmail as an integrated local mail delivery agent? (generic,
  119. X     sendmail, ZMailer, smail, SysV mailsurr)
  120. X    Changing the mail spool directory to $HOME for all users
  121. X    Security considerations (when installing procmail suid root)
  122. X
  123. X    Well, this probably is your lucky day :-), all these topics are covered
  124. X    in the examples/advanced file.
  125. X
  126. X    Other examples (e.g. for autoreplies) are most likely to be found by
  127. X    typing:        man procmailex
  128. X
  129. X9. How do I use procmail as a general mail filter inside sendmail?
  130. X
  131. X    See EXAMPLES section of the procmail(1) man page.
  132. X
  133. X10. Why do I have to insert my login name after the '#' in the .forward or
  134. X   .maildelivery file?
  135. X
  136. X    Some mailers `optimise' maildelivery and take out duplicates from
  137. X    Cc:, Bcc: and alias lists before delivery.  If two or more persons on
  138. X    such a list would have identical .forward files, then the mailer will
  139. X    eliminate all but one.    Adding a `#' with your login name following
  140. X    it will make the .forward files unique, and will ensure that the mailer
  141. X    doesn't optimise away some addresses.
  142. X
  143. X11. How do I view the man pages?
  144. X
  145. X    If the man(1) program on your system understands the MANPATH
  146. X    environment variable, make sure that the installation directory listed
  147. X    in the Makefile for the manpages is included in your MANPATH.  If your
  148. X    man program does not support MANPATH, make sure that the man pages
  149. X    are installed in one of the standard man directories, like under
  150. X    /usr/man.  If you do not want to install the man pages before viewing
  151. X    them, you can view an individual man file by typing something like:
  152. X    nroff -man procmail.1 | more
  153. X
  154. X12. The leading From_ line on all my arriving mail shows the wrong time.
  155. X    Before putting procmail in the .forward file everything was OK.
  156. X
  157. X    This is a known bug in sendmail-5.65c+IDA.  The real fix would be
  158. X    to upgrade to sendmail 6.x or later.  For a quick fix, see the
  159. X    procmailex man page.
  160. X
  161. X13. When sending mail to someone with procmail in his/her .forward I sometimes
  162. X    get back an error saying: "Cannot mail directly to programs."
  163. X
  164. X    This is a known bug in some older sendmails that mistakenly drop
  165. X    their root privileges when they are given the -t flag.    Either
  166. X    make sure that your sendmail always forwards to a mailserver first or
  167. X    upgrade to sendmail 6.x or later.
  168. X
  169. X14. My mailtool sometimes reports that it is confused about the state of
  170. X    the mailbox, or I get "Couldn't unlock" errors from procmail now and then.
  171. X
  172. X    This is a known bug in the OpenLook mailtool.  It holds on to the
  173. X    kernel lock on the mail-spoolfile most of the time, and releases
  174. X    this lock when it shouldn't.  Either ask for a bugfix from your
  175. X    vendor (I'm not sure if a bugfix exists), or make sure that during
  176. X    the compilation of procmail both the fcntl() and lockf() locking
  177. X    methods are disabled (see config.h).
  178. X
  179. X15. I sometimes get these `Lock failure on "/usr/mail/$LOGNAME.lock"' errors
  180. X    from procmail.  What do I do about it?
  181. X
  182. X    The problem here is that as long as procmail has not read a
  183. X    $HOME/.procmailrc file, it can hang on to the sgid mail permission
  184. X    (which it needs in order to create a lockfile in /usr/mail).
  185. X    I.e. if procmail delivers mail to a user without a $HOME/.procmailrc
  186. X    file, procmail *can* (and does) use the /usr/mail/$LOGNAME.lock file.
  187. X
  188. X    If, however, it finds a $HOME/.procmailrc file, procmail has to let go
  189. X    of the sgid mail permission because otherwise any ordinary user could
  190. X    abuse that.
  191. X
  192. X    There are several solutions to this problem:
  193. X    - Some systems support the sticky bit on directories (when set only
  194. X      allows the owner of a file in that directory to rename or remove
  195. X      it).    This enables you to make /usr/spool/mail drwxrwxrwt.  It is
  196. X      thus effectively world writable, but all the mailboxes in it are
  197. X      protected because only the mailbox owner can remove or rename it.
  198. X    - If your system did not exhibit the !@#$%^&* POSIX semantics for
  199. X      setgid(), procmail would have been able to switch back and forth
  200. X      between group mail and the group the recipient belongs to without
  201. X      creating security holes.
  202. X    - If your system supported setrgid() or setregid() or setresgid()
  203. X      with BSD semantics, procmail would have been able to switch...
  204. X      (see the previous point).
  205. X    - You could simply put the following at the end of your .procmailrc
  206. X      file:
  207. X
  208. X        LOCKFILE        # removes any preexisting lockfile
  209. X        LOG=`lockfile $DEFAULT$LOCKEXT`
  210. X        TRAP="rm -f $DEFAULT$LOCKEXT"
  211. X            :0
  212. X            $DEFAULT
  213. X
  214. X    - You could, instead of using /usr/mail/$LOGNAME, use a file below
  215. X      your home directory as your default mailbox.
  216. X    - Or, you could still use /usr/mail/$LOGNAME as the mailbox, but
  217. X      simply instruct procmail to use a different lockfile.     This can
  218. X      be achieved by putting following recipe at the bottom of
  219. X      your .procmailrc file:
  220. X
  221. X        :0:$HOME/.lockmail
  222. X        $DEFAULT
  223. X
  224. X      You have to make sure that all other programs that update your
  225. X      system mailbox will be using the same lockfile of course.
  226. X    - You can ignore the problem if you know that both your mail reader
  227. X      and procmail use an overlapping kernel locking method.
  228. X
  229. X
  230. X16. None of the above topics cover my problem.    Should I panic?
  231. X
  232. X    Let me ask you a question :-), have you examined the CAVEATS, WARNINGS,
  233. X    BUGS and NOTES sections of the manual pages *closely* ?
  234. X    If you have, well, then panic.    Or, alternatively, you could submit
  235. X    your question to the procmail mailinglist (see the man page for the
  236. X    exact addresses, or try "procmail -v", or look in the patchlevel.h
  237. X    file).
  238. END_OF_FILE
  239.   if test 9416 -ne `wc -c <'procmail-3.03/FAQ'`; then
  240.     echo shar: \"'procmail-3.03/FAQ'\" unpacked with wrong size!
  241.   fi
  242.   # end of 'procmail-3.03/FAQ'
  243. fi
  244. if test -f 'procmail-3.03/examples/advanced' -a "${1}" != "-c" ; then 
  245.   echo shar: Will not clobber existing file \"'procmail-3.03/examples/advanced'\"
  246. else
  247.   echo shar: Extracting \"'procmail-3.03/examples/advanced'\" \(9931 characters\)
  248.   sed "s/^X//" >'procmail-3.03/examples/advanced' <<'END_OF_FILE'
  249. X
  250. XDiscusses:
  251. X        1. One home directory, several machine architectures
  252. X        2. Procmail as an integrated local mail delivery agent
  253. X        2a.Special directions for sites with sendmail
  254. X        2b.Special directions for sites with ZMailer
  255. X        2c.Special directions for sites with smail
  256. X        2d.Special directions for sites with SysV /etc/mail/mailsurr
  257. X        3. Changing the mail spool directory to $HOME for all users
  258. X        4. Security considerations (when installing procmail suid root)
  259. X
  260. X                ---
  261. X
  262. X1. One home directory, several machine architectures
  263. X   -------------------------------------------------
  264. X
  265. XFor users that have the very same home directory on machines with differing
  266. Xarchitectures (i.e. you need different executables), and they
  267. Xhave to explicitly use (i.e. the system administrator did not arrange,
  268. Xfor example, /usr/local/bin/procmail to have exactly the right contents
  269. Xdepending on from which machine it is called) two executables of procmail,
  270. XI have the following suggestion to use as a .forward file (examples are for
  271. Xsparc and sun3 architectures):
  272. X
  273. 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"
  274. X
  275. Xor alternatively:
  276. X
  277. X"|IFS=' '&& exec /home/berg/bin.`/usr/bin/arch`/procmail ||exit 75 #YOUR_USERNAME"
  278. X
  279. XPlease note, in the .forward file there can NOT be any newlines between
  280. Xthe doublequotes, i.e. the former example *has* to be typed in as one long
  281. Xline.
  282. X
  283. XIf, on the other hand, you have to log in to every machine to read mail
  284. Xarrived for you on that machine, a different solution might be more
  285. Xappropriate.
  286. X
  287. XIf you have sendmail v6.xx and later, you simply create two .forward files.
  288. XIn the .forward file you put:
  289. X
  290. XYOUR_LOGIN_NAME@your.favourite.machine
  291. X
  292. XAnd, in a second file named .forward.your.favourite.machine you put:
  293. X
  294. X"|exec /usr/local/bin/procmail #YOUR_USERNAME"
  295. X
  296. XIf you have an older sendmail, you could put something like the following two
  297. Xlines in your .forward file:
  298. X
  299. XYOUR_LOGIN_NAME@your.favourite.machine
  300. X"|IFS=' ';test .`/bin/uname -n` != .your.favourite.machine || exec /usr/local/bin/procmail #YOUR_USERNAME"
  301. X
  302. XThe leading dots are important.     Check what `/bin/uname -n` returns on
  303. Xyour.favourite.machine, and substitute that for your.favourite.machine in the
  304. Xsample .forward file.  If your system does not have /bin/uname, check if there
  305. Xis a /bin/hostname.
  306. X
  307. XWith some sendmails, the last suggestion causes you to get a superfluous
  308. Xcopy in the system mailfolder.    If that is the case, you'll have to change
  309. Xyour .forward to something like:
  310. X
  311. 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"
  312. X
  313. X                ---
  314. X
  315. X2. Procmail as an integrated local mail delivery agent
  316. X   ---------------------------------------------------
  317. X
  318. XCompletely integrating procmail in the mail delivery means that mail is
  319. Xdelivered as normal, unless a .procmailrc file is present in the home
  320. Xdirectory of the recipient.  This will be completely independent of the
  321. Xfact if a .forward file is present.  This will not break anything, it
  322. Xjust makes the use of procmail easier because people are not required to
  323. Xstart up procmail from within their .forward files.  Creation of a .procmailrc
  324. Xfile will suffice.
  325. X
  326. XThe generic way to accomplish this (works with sendmail, smail and any other
  327. Xmail system that uses a local mail delivery program that takes the mail-
  328. Xto-be-delivered on stdin and the recipient(s) on the command line, with or
  329. Xwithout the "-d" option) is this:
  330. X
  331. XMove your current local mail delivery agent (e.g. /bin/mail, /bin/lmail,
  332. X/usr/lib/mail/mail.local, etc.) out of the way, and create a (symbolic or hard)
  333. Xlink from there to procmail, as in "ln /usr/local/bin/procmail /bin/lmail".
  334. X
  335. XBeware, however, that if you are using this method, /bin/mail can *only* be
  336. Xused to deliver mail.  On many systems /bin/mail has several uses (also to
  337. Xread mail or check for mail).  So, it would definitely be preferred if you
  338. Xcould edit the invocation of /bin/mail from within your mail transport agent
  339. Xto invoke procmail instead (with appropriate flags, if needed).     Special
  340. Xdirections detailing this process for some of the more popular MTAs are
  341. Xincluded in subsections below.
  342. X
  343. XIn addition to needing root privileges upon startup, on some systems procmail
  344. Xneeds to be sgid to daemon or mail.  One way to check is by looking at the
  345. Xcurrent mail delivery agent (usually /bin/mail) and to mimic its permissions,
  346. Xowner and group.  If you're not quite sure, just type "make recommend" and some
  347. Xsuitable recommendations will be made for your particular environment.
  348. X
  349. XThe same might apply to the "lockfile" program, in order for it to be able to
  350. Xcreate and unlink lockfiles in the mail spool directory it might need to be
  351. Xsgid to daemon or mail, not to worry however, "lockfile" will not enable users
  352. Xto abuse the sgid/suid-ness.
  353. X
  354. X                ---
  355. X
  356. X2a.Special directions for sites with sendmail
  357. X   ------------------------------------------
  358. X
  359. XThe following lines should take the place of the standard Mlocal definition in
  360. Xyour sendmail.cf:
  361. X
  362. XMlocal, P=/usr/local/bin/procmail, F=lsSDFMhPfn, S=10, R=20,
  363. X    A=procmail -a $h -d $u
  364. X
  365. XAs for the fields "S=10, R=20": if your system uses others or none on the
  366. Xcurrent Mlocal definition, use those instead of "S=10, R=20".
  367. X
  368. XTo impose a 2MB limit on mails, you could add a `Maxsize=' field like in:
  369. X
  370. XMlocal, P=/usr/local/bin/procmail, F=lsSDFMhPfn, S=10, R=20, M=2000000
  371. X    A=procmail -a $h -d $u
  372. X
  373. XIn order to take advantage of the meta argument that can be passed to
  374. Xprocmail you'd have to change to $#local mailer rule to set the $@ host name
  375. X(which will be substituted for $h in the mailer definition).
  376. X
  377. XSince you are editing the sendmail.cf file now anyway, you might as well setup
  378. Xan extra `procmail' mailer.  This Mprocmail can then be used as a general mail
  379. Xfilter.     For more information, see EXAMPLES section the procmail(1) man page.
  380. X
  381. X                ---
  382. X
  383. X2b.Special directions for sites with ZMailer
  384. X   -----------------------------------------
  385. X
  386. XThe following line should be inserted into (or take the place of any previous
  387. Xlocal definition in) your sm.conf file for the Transport Agent:
  388. X
  389. Xlocal    sSPfn    /usr/local/bin/procmail        procmail -a $h -d $u
  390. X
  391. X                ---
  392. X
  393. X2c.Special directions for sites with smail
  394. X   ---------------------------------------
  395. X
  396. XFor smail 2.x users there are two options:
  397. X i. Move the current local-mail-delivery program (probably /bin/lmail) out of
  398. X    the way, make a symbolic or hard link from procmail to the name of that
  399. X    program (e.g. "ln /usr/local/bin/procmail /bin/lmail")
  400. X ii.Make sure the following macro is defined in src/defs.h:
  401. X    #define LMAIL(frm,sys) "/usr/local/bin/procmail -d"
  402. X
  403. XFor smail 3.x users there are also two options:
  404. X i. The same solution as for smail 2.x (however, method ii is preferred)
  405. X ii.Replace any existing "local"-entry in the /usr/lib/smail/transports file
  406. X    (create one, if need be) with the following two lines:
  407. X
  408. Xlocal: return_path, local, from, driver=pipe; user=root,
  409. X    cmd="/usr/local/bin/procmail -d $($user$)"
  410. X
  411. X                ---
  412. X
  413. X2d.Special directions for sites with SysV /etc/mail/mailsurr
  414. X   ---------------------------------------------------------
  415. X
  416. XSome systems use a SysV /bin/mail that supports mailsurr.  To interface
  417. Xprocmail with mailsurr the following two lines should be inserted in the
  418. X/etc/mail/mailsurr file (preferably at the bottom):
  419. X
  420. X'(.+)' '([^@!]+)' '<S=0;C=67,75;F=*;
  421. X    /usr/local/bin/procmail -f \\1 -d \\2'
  422. X
  423. X                ---
  424. X
  425. X3. Changing the mail spool directory to $HOME for all users
  426. X   --------------------------------------------------------
  427. X
  428. XThere are many different reasons why more and more sites decide not to
  429. Xstore mail in /usr/spool/mail or /usr/mail anymore.
  430. XSome of the obvious advantages when storing mail in the recipient's home
  431. Xdirectory are:
  432. X    - Mail is automatically subject to the user's quota limitations.
  433. X    - Often there is more room on the home partition(s) than on that
  434. X      one /usr/mail partition.
  435. X
  436. XThe quota limitations also apply to /usr/spool/mail or /usr/mail if procmail
  437. Xdoes the delivery.  These quota limitations often do not work with the
  438. Xregular /bin/mail since that usually writes the mailbox with root permissions
  439. X(eluding the quota restrictions).
  440. X
  441. XHowever, if you are going to install procmail as the integrated local
  442. Xdelivery agent, and you want mail to be delivered to, say, $HOME/.mail
  443. Xby default, this is what you have to do:
  444. X
  445. X    Edit the procmail*/config.h file.   Uncomment and possibly change
  446. X    the SYSTEM_MBOX define.     Procmail now delivers there by default.
  447. X
  448. X    In order to make sure that normal mailtools can find the new
  449. X    system mailboxes, you should make sure that every user has the
  450. X    MAIL environment variable set to be equal to whatever you
  451. X    defined SYSTEM_MBOX to be.  Some braindamaged mail programs
  452. X    do not pick up the MAIL environment variable, these either
  453. X    have to be patched/recompiled or you have to create symbolic
  454. X    links in /usr/mail to every person's new mailbox.
  455. X
  456. X                ---
  457. X
  458. X4. Security considerations (when installing procmail suid root)
  459. X   -------------------------------------------------------------
  460. X
  461. XIf in EXPLICIT DELIVERY mode (typically when called from within sendmail)
  462. Xprocmail will ALWAYS change UID and gid to the RECIPIENT's defaults as soon as
  463. Xit starts reading the recipient's $HOME/.procmailrc file.
  464. X
  465. XIf NOT in explicit delivery mode (typically when called from within the
  466. Xrecipient's $HOME/.forward file) procmail will ALWAYS change UID and gid to
  467. Xthe real uid and gid of the INVOKER (effectively losing any suid or sgid
  468. Xprivileges).
  469. X
  470. XThese two precautions should effectively eliminate any security holes because
  471. Xprocmail will always have the uid of the person whose commands it is executing.
  472. X
  473. XTo summarise, procmail will only behave better if made suid/sgid something, in
  474. Xfact, making procmail suid/sgid something will *improve* security on systems
  475. Xwhich have dynamically linked libraries.
  476. X
  477. X                ---
  478. END_OF_FILE
  479.   if test 9931 -ne `wc -c <'procmail-3.03/examples/advanced'`; then
  480.     echo shar: \"'procmail-3.03/examples/advanced'\" unpacked with wrong size!
  481.   fi
  482.   # end of 'procmail-3.03/examples/advanced'
  483. fi
  484. if test -f 'procmail-3.03/initmake' -a "${1}" != "-c" ; then 
  485.   echo shar: Will not clobber existing file \"'procmail-3.03/initmake'\"
  486. else
  487.   echo shar: Extracting \"'procmail-3.03/initmake'\" \(9335 characters\)
  488.   sed "s/^X//" >'procmail-3.03/initmake' <<'END_OF_FILE'
  489. X#! /bin/sh
  490. X:
  491. X# Copyright (c) 1992-1994, S.R. van den Berg, The Netherlands
  492. X#$Id: initmake,v 1.53 1994/05/26 14:10:48 berg Exp $
  493. X
  494. Xif test -z "$IFS"
  495. Xthen IFS=" \
  496. X    \
  497. X
  498. X"
  499. X  export IFS
  500. Xfi
  501. X
  502. XPATH=.:$PATH
  503. XBSHELL=$1
  504. X
  505. XO="cd ."
  506. Xif $O
  507. Xthen
  508. X:
  509. Xelse
  510. X  echo "Your BSHELL=$BSHELL seems to be severely handicapped."
  511. X  case "$BSHELL" in
  512. X     *zsh*) ;;
  513. X     *) echo "(If I wouldn't know better, I'd say you're trying to sell"
  514. X    echo "me a buggy zsh :-)" ;;
  515. X  esac
  516. X  echo "Please edit the Makefile and try setting BSHELL to a shell which"
  517. X  echo "is more backwards compatible with a Bourne, Korn or POSIX shell."
  518. X  exit 1
  519. Xfi
  520. X
  521. Xshift; MSHELL=$1
  522. Xshift; RM="$1"
  523. Xshift; MV="$1"
  524. Xshift; LN="$1"
  525. Xshift; SEARCHLIBS="$1"
  526. Xshift; LIBPATHS="$1"
  527. Xshift; DEVNULL=$1
  528. Xshift; MAKE="$1"
  529. Xshift; O=$1
  530. Xshift; CC="$1"
  531. Xshift; CFLAGS1="$1"
  532. Xshift; LDFLAGS1="$1"
  533. Xshift; BINSS="$1"
  534. Xshift; MANS1S="$1"
  535. Xshift; MANS5S="$1"
  536. Xshift; SUBDIRS="$1"
  537. Xshift; BINDIR="$1"
  538. X
  539. Xtest 1 != $# &&
  540. X echo "Don't start this script directly, use \`make init'" && exit 1
  541. X
  542. Xtest -z "$MSHELL" || SHELL=$MSHELL
  543. Xcase "$SHELL" in
  544. X  *sh*)
  545. X     case "$SHELL" in
  546. X    *csh*) echo "Warning: really perverted make detected"; SHELL="";;
  547. X    *zsh*) $RM src/_autotst
  548. X        $SHELL <<HERE
  549. X        O="echo test >src/_autotst"
  550. X        exec 2>$DEVNULL
  551. X        \$O
  552. XHERE
  553. X       if test ! -f src/_autotst
  554. X       then
  555. X          echo "Warning: your $SHELL is broken, avoiding it"; SHELL=""
  556. X       fi ;;
  557. X     esac
  558. X     if test ! -z "$SHELL"
  559. X     then
  560. X    $SHELL <<HERE
  561. X    exec 2>$DEVNULL
  562. X    echo test >src/_autotst
  563. X    echo test >src/_autotst
  564. XHERE
  565. X    if test $? = 1
  566. X    then
  567. X       echo "Warning: your $SHELL has noclobber turned on, avoiding it"
  568. X       SHELL=""
  569. X    fi
  570. X     fi
  571. X     $RM src/_autotst;;
  572. X  *) echo "Warning: perverted make detected"; SHELL="";;
  573. Xesac
  574. Xtest -z "$SHELL" && SHELL=$BSHELL
  575. X
  576. Xexport SHELL PATH
  577. X
  578. XFGREP="fgrep"        # POSIX, or not POSIX, that is the question...
  579. Xif test \^hello = "`echo '^hello' | grep -F '^hello' 2>&1`"
  580. Xthen FGREP="grep -F"                # and POSIX it is!
  581. Xfi
  582. X
  583. Xecho hi | $FGREP hi >$DEVNULL
  584. Xt=$?
  585. Xecho ho | $FGREP hi >$DEVNULL
  586. Xf=$?
  587. Xif test 0 != $t -o 0 = $f
  588. Xthen
  589. X  echo "Your \"$FGREP\" program seems to be incapable of returning a proper"
  590. X  echo "exitvalue depending on the success of the search.  This script can"
  591. X  echo "not work without it."
  592. X  exit 2
  593. Xfi
  594. X
  595. Xif test ! -z "$LD_LIBRARY_PATH"
  596. Xthen
  597. X  echo '***************************** WARNING *********************************'
  598. X  echo '* You seem to have set the LD_LIBRARY_PATH variable, this might cause *'
  599. X  echo '* some trouble during the execution of this autoconf script.  If the  *'
  600. X  echo '* the make does not finish by itself, do a: "make clean",          *'
  601. X  echo '* clear LD_LIBRARY_PATH from the environment, and start over.          *'
  602. X  echo '***************************** WARNING *********************************'
  603. Xfi
  604. X
  605. Xcd src                # diving into the source directory ######
  606. X
  607. Xnewln=""
  608. X$RM _autotst.rrr _autotst
  609. Xecho hi >_autotst.rrr
  610. Xif $LN _autotst.rrr _autotst
  611. Xthen
  612. X:
  613. Xelse
  614. X   $LN -s _autotst.rrr _autotst && LN="$LN -s" && newln=yes
  615. Xfi
  616. X
  617. Xcat >_autotst.c <<HERE
  618. Xmain()
  619. X{ return 0;
  620. X}
  621. XHERE
  622. X$RM _autotst.rrr _autotst.$O _autotst
  623. X
  624. Xcc=""
  625. X
  626. Xfor a in "$CC" cc gcc
  627. Xdo
  628. X  echo $a $CFLAGS1 _autotst.c -o _autotst $LDFLAGS1 >>_autotst.rrr
  629. X  test -z "$cc" -a ! -z "$a" &&
  630. X   (exec >>_autotst.rrr 2>&1; $a $CFLAGS1 _autotst.c -o _autotst $LDFLAGS1) &&
  631. X   cc="$a"
  632. X  echo "::::" >>_autotst.rrr
  633. Xdone
  634. Xif test -z "$cc"
  635. Xthen
  636. X  echo 2>&1 "Whoeaaa!  There's something fishy going on here."
  637. X  echo 2>&1 "You have a look and see if you detect anything uncanny:"
  638. X  echo 2>&1 "-------------------------------------------------------"
  639. X  cat 2>&1 _autotst.rrr
  640. X  echo 2>&1 "-------------------------------------------------------"
  641. X  echo 2>&1 "I suggest you take a look at the definition of CFLAGS* and CC"
  642. X  echo 2>&1 "in the Makefile before you try make again."
  643. X  exit 1
  644. Xfi
  645. X$RM _autotst.rrr _autotst.$O _autotst
  646. Xecho "$cc seems to work fine, using that as the C-compiler"
  647. X
  648. Xcat >_autotst.c <<HERE
  649. X#include <sys/types.h>
  650. X#include <stdio.h>
  651. X#include <sys/stat.h>
  652. Xmain()
  653. X{ struct stat buf;return!&buf;
  654. X}
  655. XHERE
  656. X
  657. XCFLAGS=""
  658. X
  659. Xcase "$CFLAGS1" in
  660. X  *-D_POSIX_SOURCE*);;
  661. X  *)
  662. X     if $cc -c $CFLAGS1 _autotst.c >$DEVNULL 2>&1
  663. X     then
  664. X     :
  665. X     else
  666. X    $RM _autotst.$O
  667. X    $cc -c $CFLAGS1 -D_POSIX_SOURCE _autotst.c >$DEVNULL 2>&1 &&
  668. X     CFLAGS=" -D_POSIX_SOURCE"
  669. X     fi;;
  670. Xesac
  671. X
  672. XLDFLAGSC=""
  673. X
  674. Xtest -f _autotst.$O || $cc -c $CFLAGS1 $CFLAGS _autotst.c >$DEVNULL 2>&1
  675. X$cc $CFLAGS1 $CFLAGS _autotst.$O -o _autotst $LDFLAGS1 -lc >_autotst.rrr 2>&1 \
  676. X && if grep "[\"']c['\"]" _autotst.rrr >$DEVNULL ||
  677. X   fgrep libc _autotst.rrr >$DEVNULL
  678. X  then
  679. X  :
  680. X  else
  681. X     LDFLAGSC=" -lc"
  682. X  fi
  683. X
  684. XLDFLAGS="$SEARCHLIBS"
  685. Xfirstrun=yes
  686. Xcheckpath=no
  687. X
  688. Xwhile $RM _autotst
  689. X $cc $CFLAGS1 $CFLAGS _autotst.$O -o _autotst $LDFLAGS1 $LDFLAGS \
  690. X  $LDFLAGSC >_autotst.rrr 2>&1
  691. X test $firstrun = yes -o ! -f _autotst
  692. Xdo
  693. X  set dummy $LDFLAGS
  694. X  shift
  695. X  echo 2>&1 "    ...scanning for $# libraries..."
  696. X  NEWLDFLAGS=""
  697. X  for lib in `echo _dummy_ $LDFLAGS | sed -e s/-l//g`
  698. X  do
  699. X     if test _dummy_ != $lib
  700. X     then
  701. X    a=-l$lib
  702. X     ( exec <_autotst.rrr
  703. X       while read b
  704. X       do
  705. X          case ":$b:" in
  706. X         *_autotst.$O*) ;;
  707. X         *lib$lib[!a-z_]*|*$a[!a-z_]*|*[!a-z]$lib[!a-z_]*) exit 1;;
  708. X          esac
  709. X       done
  710. X       exit 0
  711. X     )
  712. X    if test $? = 0
  713. X    then
  714. X       found=yes
  715. X       if test $checkpath = yes
  716. X       then
  717. X          OLDIFS="$IFS"; IFS=":$IFS"
  718. X          found=no
  719. X          for libpath in $LIBPATHS $LD_LIBRARY_PATH
  720. X          do
  721. X         set $libpath/*lib$lib[A-Z.]*
  722. X         test -f $1 && found=yes
  723. X          done
  724. X          IFS="$OLDIFS"
  725. X       fi
  726. X       test yes = $found && NEWLDFLAGS="$NEWLDFLAGS $a"
  727. X    fi
  728. X     fi
  729. X  done
  730. X  if test a"$LDFLAGS" = a"$NEWLDFLAGS"
  731. X  then
  732. X     if test $checkpath = yes
  733. X     then
  734. X    echo 2>&1 "Whoeaaa!  There's something fishy going on here."
  735. X    echo 2>&1 "You have a look and see if you detect anything uncanny:"
  736. X    echo 2>&1 "*******************************************************"
  737. X    cat 2>&1 _autotst.rrr
  738. X    echo 2>&1 "*******************************************************"
  739. X    echo 2>&1 \
  740. X       "I suggest you take a look at the definition of LDFLAGS* and SEARCHLIBS"
  741. X    echo 2>&1 "in the Makefile before you try make again."
  742. X    echo 2>&1 \
  743. X     "Also: write me a mail showing the errorlog you just generated."
  744. X    echo 2>&1 "The errorlog can still be found in src/_autotst.rrr"
  745. X    echo 2>&1 \
  746. X     "It would be helpful if you could mention what machine and OS"
  747. X    echo 2>&1 "you are trying to compile this on (uname -a).  Thanks."
  748. X    exit 1
  749. X     fi
  750. X     checkpath=yes
  751. X  else
  752. X     checkpath=no
  753. X  fi
  754. X  LDFLAGS="$NEWLDFLAGS"
  755. X  firstrun=no
  756. Xdone
  757. X
  758. X$RM _autotst.$O _autotst.c _autotst
  759. Xcd ..            # returning to the main procmail directory ######
  760. X
  761. XLDFLAGS="$LDFLAGS$LDFLAGSC"
  762. X
  763. Xtest -z "$CFLAGS" || echo "Added CFLAGS=$CFLAGS"
  764. Xtest -z "$LDFLAGS" || echo "Added LDFLAGS=$LDFLAGS"
  765. X
  766. Xfor a in $SUBDIRS
  767. Xdo
  768. X  if test ! -f $a/Makefile.init
  769. X  then
  770. X     case "$LN" in
  771. X    *-s*) cp $a/Makefile $a/Makefile.init ;;
  772. X    *) $LN $a/Makefile $a/Makefile.init
  773. X       $RM $a/Makefile
  774. X       $LN $a/Makefile.init $a/Makefile ;;
  775. X     esac
  776. X  fi
  777. Xdone
  778. X
  779. Xtest -f Makefile.0 || sed -e '/^# Makefile - mark/,$ !d' <Makefile >Makefile.0
  780. Xsed -e '/^# Makefile - mark/,$ d' <Makefile >_Makefile
  781. Xecho "# Makefile.1 - mark, don't (re)move this, a sed script needs it
  782. X" >>_Makefile
  783. X
  784. Xtest a$SHELL != a$MSHELL && echo  "SHELL    = $SHELL"    >>_Makefile
  785. Xecho "FGREP    = $FGREP"                >>_Makefile
  786. Xtest -z "$newln" || echo "LN    = $LN"            >>_Makefile
  787. Xtest -z "$MAKE" && echo "MAKE    = make"            >>_Makefile
  788. Xtest a"$cc" != a"$CC" && echo "CC    = $cc"        >>_Makefile
  789. X
  790. Xecho "CFLAGS    = \$(CFLAGS1)$CFLAGS"            >>_Makefile
  791. Xecho "LDFLAGS    = \$(LDFLAGS1)$LDFLAGS"            >>_Makefile
  792. Xecho                            >>_Makefile
  793. X
  794. XMANSS=""
  795. XMANS1=""
  796. XMANS5=""
  797. XMANS=""
  798. XNMANS=""
  799. XBINS=""
  800. XNBINS=""
  801. Xfor a in $MANS1S
  802. Xdo
  803. X  MANSS="$MANSS $a.1"
  804. X  MANS1="$MANS1 $a.\$(MAN1SUFFIX)"
  805. Xdone
  806. Xfor a in $MANS5S
  807. Xdo
  808. X  MANSS="$MANSS $a.5"
  809. X  MANS5="$MANS5 $a.\$(MAN5SUFFIX)"
  810. Xdone
  811. Xfor a in $MANSS
  812. Xdo
  813. X  MANS="$MANS new/$a"
  814. X  NMANS="$NMANS ../new/$a"
  815. Xdone
  816. Xfor a in $BINSS
  817. Xdo
  818. X  BINS="$BINS new/$a"
  819. X  NBINS="$NBINS ../new/$a"
  820. Xdone
  821. X
  822. Xecho "BINS=$BINS"                    >>_Makefile
  823. Xecho "MANS=$MANS"                    >>_Makefile
  824. Xecho "MANS1=$MANS1"                    >>_Makefile
  825. Xecho "MANS5=$MANS5"                    >>_Makefile
  826. Xecho "MANSS=$MANSS"                    >>_Makefile
  827. Xecho "NBINS=$NBINS"                    >>_Makefile
  828. Xecho "NMANS=$NMANS"                    >>_Makefile
  829. Xecho                            >>_Makefile
  830. X
  831. Xfor a in $SUBDIRS
  832. Xdo
  833. X  sed -e '1,/^# Makefile.0 - mark/ d' <_Makefile >$a/_Makefile
  834. X  cat $a/Makefile.0 >>$a/_Makefile
  835. Xdone
  836. X
  837. Xecho "BINDIR=$BINDIR"                    >>src/_Makefile
  838. X
  839. Xfor a in $BINSS
  840. Xdo
  841. X  echo                            >>src/_Makefile
  842. X  echo "../new/$a: $a ../config.check"            >>src/_Makefile
  843. X  echo "    @\$(RM) \$@"                >>src/_Makefile
  844. X  echo "    \$(LN) ../src/$a \$@"            >>src/_Makefile
  845. Xdone
  846. X
  847. Xfor a in $MANSS
  848. Xdo
  849. X  echo                            >>man/_Makefile
  850. X  echo "../new/$a: $a ../config.check"            >>man/_Makefile
  851. X  echo "    @\$(RM) \$@"                >>man/_Makefile
  852. X  echo "    \$(LN) ../man/$a \$@"            >>man/_Makefile
  853. Xdone
  854. X
  855. Xfor a in $MANS1S
  856. Xdo
  857. X  echo                            >>man/_Makefile
  858. X  echo "$a.1: $a.man man.sed mansed"            >>man/_Makefile
  859. X  echo \
  860. X   "    \$(SHELL) ./mansed \$(SHELL) $a.man \$@ \"\$(RM)\" \$(DEVNULL)" \
  861. X   >>man/_Makefile
  862. Xdone
  863. X
  864. Xfor a in $MANS5S
  865. Xdo
  866. X  echo                            >>man/_Makefile
  867. X  echo "$a.5: $a.man man.sed mansed"            >>man/_Makefile
  868. X  echo \
  869. X   "    \$(SHELL) ./mansed \$(SHELL) $a.man \$@ \"\$(RM)\" \$(DEVNULL)" \
  870. X   >>man/_Makefile
  871. Xdone
  872. X
  873. Xcat Makefile.1 >>_Makefile
  874. X$MV _Makefile Makefile
  875. X
  876. Xsleep 1            # Some machines are just too speedy, make gets confused
  877. X
  878. Xfor a in $SUBDIRS
  879. Xdo
  880. X  echo "#" >>$a/_Makefile
  881. X  $MV $a/_Makefile $a/Makefile
  882. Xdone
  883. END_OF_FILE
  884.   if test 9335 -ne `wc -c <'procmail-3.03/initmake'`; then
  885.     echo shar: \"'procmail-3.03/initmake'\" unpacked with wrong size!
  886.   fi
  887.   chmod +x 'procmail-3.03/initmake'
  888.   # end of 'procmail-3.03/initmake'
  889. fi
  890. if test -f 'procmail-3.03/src/includes.h' -a "${1}" != "-c" ; then 
  891.   echo shar: Will not clobber existing file \"'procmail-3.03/src/includes.h'\"
  892. else
  893.   echo shar: Extracting \"'procmail-3.03/src/includes.h'\" \(9973 characters\)
  894.   sed "s/^X//" >'procmail-3.03/src/includes.h' <<'END_OF_FILE'
  895. X/*$Id: includes.h,v 1.44 1994/06/24 10:44:57 berg Exp $*/
  896. X
  897. X#include "../autoconf.h"
  898. X#ifdef NO_const
  899. X#ifdef const
  900. X#undef const
  901. X#endif
  902. X#define const
  903. X#endif
  904. X#include "../config.h"
  905. X    /* not all the "library identifiers" specified here need to be
  906. X       available for all programs in this package; some have substitutes
  907. X       as well (see autoconf); this is just an informal list */
  908. X
  909. X#ifndef _HPUX_SOURCE
  910. X#define _HPUX_SOURCE          /* sad, but needed on HP-UX when compiling -Aa */
  911. X#endif
  912. X#ifndef NO_FIX_MALLOC
  913. X#define NO_FIX_MALLOC           /* we don't need a `fixed' malloc(0) call */
  914. X#endif                /* saves a few bytes in some implementations */
  915. X
  916. X#include <sys/types.h>        /* pid_t mode_t uid_t gid_t off_t */
  917. X#ifndef LIMITS_H_MISSING
  918. X#include <limits.h>        /* absolutely nothing, just for fun */
  919. X#undef LIMITS_H_MISSING
  920. X#endif
  921. X#ifndef UNISTD_H_MISSING
  922. X#include <unistd.h>        /* open() read() write() close() dup() pipe()
  923. X                /* fork() getuid() geteuid() getgid() getegid()
  924. X                   getpid() execve() execvp() sleep() setuid()
  925. X                   setgid() setruid() setrgid() setegid()
  926. X                   chown() nice() */
  927. X#else
  928. X#undef UNISTD_H_MISSING
  929. X#endif
  930. X#include <stdio.h>        /* setbuf() fclose() stdin stdout stderr
  931. X                /* fopen() fread() fwrite() fgetc() getc()
  932. X                   fdopen() putc() fputs() printf() sprintf()
  933. X                   fprintf() sscanf() FILE EOF */
  934. X#ifndef STDDEF_H_MISSING
  935. X#include <stddef.h>        /* ptrdiff_t size_t */
  936. X#else
  937. X#undef STDDEF_H_MISSING
  938. X#endif
  939. X#ifndef STDLIB_H_MISSING
  940. X#include <stdlib.h>        /* getenv() malloc() realloc() free()
  941. X                /* strtol() exit() */
  942. X#endif
  943. X#include <time.h>        /* time() ctime() time_t */
  944. X#include <fcntl.h>        /* fcntl() struct flock O_RDONLY O_WRONLY
  945. X                /* O_APPEND O_CREAT O_EXCL */
  946. X#include <grp.h>        /* getgrgid() struct group */
  947. X#include <pwd.h>        /* getpwuid() getpwnam() struct passwd */
  948. X#ifndef DIRENT_H_MISSING
  949. X#include <dirent.h>        /* opendir() readdir() closedir() DIR
  950. X                /* struct dirent */
  951. X#endif
  952. X#ifndef SYS_WAIT_H_MISSING
  953. X#include <sys/wait.h>        /* wait() waitpid() WIFEXITED() WIFSTOPPED()
  954. X                /* WEXITSTATUS() WTERMSIG() */
  955. X#else
  956. X#undef SYS_WAIT_H_MISSING
  957. X#endif
  958. X#ifndef SYS_UTSNAME_H_MISSING
  959. X#include <sys/utsname.h>    /* uname() utsname */
  960. X#endif
  961. X#include <sys/stat.h>        /* stat() S_ISDIR() S_ISREG() struct stat
  962. X                /* chmod() mkdir() */
  963. X#include <signal.h>        /* signal() kill() alarm() SIG_IGN SIGHUP
  964. X                /* SIGINT SIGQUIT SIGALRM SIGTERM */
  965. X#ifndef STRING_H_MISSING
  966. X#include <string.h>        /* strcpy() strncpy() strcat() strlen()
  967. X                /* strspn() strcspn() strchr() strcmp()
  968. X                   strncmp() strpbrk() strstr() memmove() */
  969. X#endif
  970. X#ifndef MATH_H_MISSING
  971. X#include <math.h>        /* pow() */
  972. X#endif
  973. X#ifndef SYSLOG_H_MISSING
  974. X#include <syslog.h>        /* openlog() syslog() closelog() LOG_EMERG
  975. X                /* LOG_ALERT LOG_ERR LOG_NOTICE LOG_PID
  976. X                   LOG_MAIL */
  977. X#endif
  978. X#include <errno.h>        /* EINTR EEXIST ENFILE EACCES EAGAIN EXDEV */
  979. X#ifndef SYSEXITS_H_MISSING
  980. X#include <sysexits.h>        /* EX_OK EX_USAGE EX_NOINPUT EX_NOUSER
  981. X                /* EX_UNAVAILABLE EX_OSERR EX_OSFILE
  982. X                   EX_CANTCREAT EX_IOERR EX_TEMPFAIL EX_NOPERM
  983. X                   */
  984. X#endif
  985. X
  986. X#ifdef STDLIB_H_MISSING
  987. X#undef STDLIB_H_MISSING
  988. Xvoid*malloc(),*realloc();
  989. Xconst char*getenv();
  990. X#endif
  991. X#ifdef DIRENT_H_MISSING
  992. X#undef DIRENT_H_MISSING
  993. X#ifndef NDIR_H_MISSING
  994. X#include <ndir.h>
  995. X#define dirent    direct
  996. X#else
  997. X#undef NDIR_H_MISSING
  998. X#ifndef SYS_NDIR_H_MISSING
  999. X#include <sys/ndir.h>
  1000. X#define dirent    direct
  1001. X#else
  1002. X#undef SYS_NDIR_H_MISSING
  1003. X#ifndef SYS_DIR_H_MISSING
  1004. X#include <sys/dir.h>
  1005. X#define dirent    direct
  1006. X#else              /* due to brain-damaged NeXT sys/dirent.h contents */
  1007. X#undef SYS_DIR_H_MISSING
  1008. X#ifndef SYS_DIRENT_H_MISSING         /* sys/dirent.h must be moved down here */
  1009. X#include <sys/dirent.h>
  1010. X#else
  1011. X/*#undef SYS_DIRENT_H_MISSING                   /* needed by autoconf */
  1012. X/* I give up, I can only hope that your system defines DIR and struct dirent */
  1013. X#endif
  1014. X#endif
  1015. X#endif
  1016. X#endif
  1017. X#endif /* DIRENT_H_MISSING */
  1018. X#ifdef STRING_H_MISSING
  1019. X#undef STRING_H_MISSING
  1020. X#include <strings.h>
  1021. X#ifndef strchr
  1022. Xchar*strchr();
  1023. X#endif
  1024. Xchar*strpbrk();
  1025. X#endif
  1026. X#ifdef SYS_UTSNAME_H_MISSING
  1027. X#undef SYS_UTSNAME_H_MISSING
  1028. X#define NOuname
  1029. X#endif
  1030. X#ifdef MATH_H_MISSING
  1031. X#undef MATH_H_MISSING
  1032. Xdouble pow();
  1033. X#endif
  1034. X#ifdef SYSEXITS_H_MISSING
  1035. X#undef SYSEXITS_H_MISSING
  1036. X        /* Standard exit codes, original list maintained
  1037. X           by Eric Allman (eric@berkeley.edu) */
  1038. X#define EX_OK        0
  1039. X#define EX_USAGE    64
  1040. X#define EX_NOINPUT    66
  1041. X#define EX_NOUSER    67
  1042. X#define EX_UNAVAILABLE    69
  1043. X#define EX_OSERR    71
  1044. X#define EX_OSFILE    72
  1045. X#define EX_CANTCREAT    73
  1046. X#define EX_IOERR    74
  1047. X#define EX_TEMPFAIL    75
  1048. X#define EX_NOPERM    77
  1049. X#endif
  1050. X
  1051. X#if O_SYNC
  1052. X#else
  1053. X#undef O_SYNC
  1054. X#define O_SYNC        0
  1055. X#endif
  1056. X#ifndef O_RDONLY
  1057. X#define O_RDONLY    0
  1058. X#define O_WRONLY    1
  1059. X#endif
  1060. X#ifndef SEEK_SET
  1061. X#define SEEK_SET    0
  1062. X#define SEEK_CUR    1
  1063. X#define SEEK_END    2
  1064. X#endif
  1065. X#ifndef tell
  1066. X#define tell(fd)    lseek(fd,(off_t)0,SEEK_CUR)
  1067. X#endif
  1068. X
  1069. X#ifndef EWOULDBLOCK
  1070. X#define EWOULDBLOCK    EACCES
  1071. X#endif
  1072. X#ifndef EAGAIN
  1073. X#define EAGAIN        EINTR
  1074. X#endif
  1075. X
  1076. X#ifndef EOF
  1077. X#define EOF    (-1)
  1078. X#endif
  1079. X
  1080. X#ifndef S_ISDIR
  1081. X#define S_ISDIR(mode)    (((mode)&S_IFMT)==S_IFDIR)
  1082. X#ifndef S_IFDIR
  1083. X#define S_IFDIR 0040000
  1084. X#endif
  1085. X#endif
  1086. X
  1087. X#ifndef S_ISREG
  1088. X#define S_ISREG(mode)    (((mode)&S_IFMT)==S_IFREG)
  1089. X#ifndef S_IFREG
  1090. X#define S_IFREG 0100000
  1091. X#endif
  1092. X#endif
  1093. X
  1094. X#ifndef S_ISLNK
  1095. X#ifndef S_IFLNK
  1096. X#define lstat(path,stbuf)    stat(path,stbuf)
  1097. X#define S_ISLNK(mode)    0
  1098. X#else
  1099. X#define S_ISLNK(mode)    (((mode)&S_IFMT)==S_IFLNK)
  1100. X#endif
  1101. X#endif
  1102. X
  1103. X#ifndef S_IFMT
  1104. X#define S_IFMT    0170000
  1105. X#endif
  1106. X
  1107. X#ifndef S_IRWXU
  1108. X#define S_IRWXU 00700
  1109. X#define S_IRWXG 00070
  1110. X#define S_IRWXO 00007
  1111. X#endif
  1112. X#ifndef S_IWUSR
  1113. X#ifdef S_IREAD
  1114. X#define S_IRUSR     S_IREAD
  1115. X#define S_IWUSR     S_IWRITE
  1116. X#define S_IXUSR     S_IEXEC
  1117. X#else
  1118. X#define S_IRUSR     0400
  1119. X#define S_IWUSR     0200
  1120. X#define S_IXUSR     0100
  1121. X#endif /* S_IREAD */
  1122. X#define S_IRGRP     0040
  1123. X#define S_IWGRP     0020
  1124. X#define S_IXGRP     0010
  1125. X#define S_IROTH     0004
  1126. X#define S_IWOTH     0002
  1127. X#define S_IXOTH     0001
  1128. X#endif /* S_IWUSR */
  1129. X#ifndef S_ISGID
  1130. X#define S_ISUID 04000
  1131. X#define S_ISGID 02000
  1132. X#endif
  1133. X#ifndef S_ISVTX
  1134. X#define S_ISVTX 01000
  1135. X#endif
  1136. X
  1137. X#ifdef WMACROS_NON_POSIX
  1138. X#undef WMACROS_NON_POSIX
  1139. X#ifdef WIFEXITED
  1140. X#undef WIFEXITED
  1141. X#endif
  1142. X#ifdef WIFSTOPPED
  1143. X#undef WIFSTOPPED
  1144. X#endif
  1145. X#ifdef WEXITSTATUS
  1146. X#undef WEXITSTATUS
  1147. X#endif
  1148. X#ifdef WTERMSIG
  1149. X#undef WTERMSIG
  1150. X#endif
  1151. X#endif /* WMACROS_NON_POSIX */
  1152. X
  1153. X#ifndef WIFEXITED
  1154. X#define WIFEXITED(waitval)    (!((waitval)&255))
  1155. X#endif
  1156. X#ifndef WIFSTOPPED
  1157. X#define WIFSTOPPED(waitval)    (((waitval)&255)==127)
  1158. X#endif
  1159. X#ifndef WEXITSTATUS
  1160. X#define WEXITSTATUS(waitval)    ((waitval)>>8&255)
  1161. X#endif
  1162. X#ifndef WTERMSIG
  1163. X#define WTERMSIG(waitval)    ((waitval)&255)
  1164. X#endif
  1165. X
  1166. Xextern /*const*/char**environ;
  1167. Xextern int errno;
  1168. X
  1169. X#ifndef STDIN_FILENO
  1170. X#define STDIN    0
  1171. X#define STDOUT    1
  1172. X#define STDERR    2
  1173. X#else
  1174. X#define STDIN    STDIN_FILENO
  1175. X#define STDOUT    STDOUT_FILENO
  1176. X#define STDERR    STDERR_FILENO
  1177. X#endif
  1178. X
  1179. X#ifdef NO_fcntl_LOCK
  1180. X#ifndef NOfcntl_lock
  1181. X#define NOfcntl_lock
  1182. X#endif
  1183. X#endif
  1184. X#ifdef NO_lockf_LOCK
  1185. X#ifdef USElockf
  1186. X#undef USElockf
  1187. X#endif
  1188. X#endif
  1189. X#ifdef NO_flock_LOCK
  1190. X#ifdef USEflock
  1191. X#undef USEflock
  1192. X#endif
  1193. X#endif
  1194. X
  1195. X#ifdef SYSLOG_H_MISSING
  1196. X#undef SYSLOG_H_MISSING
  1197. X#define openlog(ident,logopt,facility)    0
  1198. X#define syslog                (void)
  1199. X#define LOG_EMERG            0
  1200. X#define LOG_ALERT            0
  1201. X#define LOG_ERR                0
  1202. X#define LOG_NOTICE            0
  1203. X#endif
  1204. X
  1205. X#ifndef NOuname
  1206. X#ifndef P          /* SINIX V5.23 has the wrong prototype for uname() */
  1207. Xextern int uname();                     /* so we fix it :-) */
  1208. X#define Uname(name)        ((int(*)(struct utsname*))uname)(name)
  1209. X#else
  1210. X#define Uname(name)        uname(name)            /* no fix needed */
  1211. X#endif /* P */
  1212. X#endif /* NOuname */
  1213. X                 /* NEWS OS 5.X has the wrong prototype here */
  1214. X#define Fdopen(fd,type)        ((FILE*)fdopen(fd,type))
  1215. X
  1216. X#ifndef strchr           /* for very old K&R compatible include files with */
  1217. X#ifdef P                        /* new K&R libraries */
  1218. X#ifdef void
  1219. X#ifdef NO_const
  1220. Xextern char*strchr();
  1221. Xextern char*strpbrk();
  1222. Xextern char*strstr();
  1223. Xextern void*memmove();
  1224. X#endif
  1225. X#endif
  1226. X#endif
  1227. X#endif
  1228. X
  1229. X#define Const            /*const*/     /* Convex cc doesn't grok this */
  1230. X
  1231. X#ifndef P                      /* no prototypes without const */
  1232. X#ifdef NO_const
  1233. X#define P(args) ()
  1234. X#endif
  1235. X#endif
  1236. X
  1237. X#ifdef NOrename
  1238. X#undef NOrename
  1239. X#define rename(old,new) (-(link(old,new)||unlink(old)))
  1240. X#endif
  1241. X
  1242. X#ifndef NOsetregid
  1243. X#ifdef NOsetrgid
  1244. X#define setrgid(gid)    setregid(gid,-1)
  1245. X#define setruid(uid)    setreuid(uid,-1)
  1246. X#endif
  1247. X#ifdef NOsetegid
  1248. X#define setegid(gid)    setregid(-1,gid)
  1249. X#endif
  1250. X#else
  1251. X#ifndef NOsetresgid
  1252. X#ifdef NOsetrgid
  1253. X#define setrgid(gid)    setresgid(gid,-1,-1)
  1254. X#define setruid(uid)    setresuid(uid,-1,-1)
  1255. X#endif
  1256. X#ifdef NOsetegid
  1257. X#define setegid(gid)    setresgid(-1,gid,-1)
  1258. X#endif
  1259. X#else
  1260. X#ifdef NOsetrgid
  1261. X#define setrgid(gid)    (-1)
  1262. X#define setruid(uid)    (-1)
  1263. X#endif
  1264. X#ifdef NOsetegid
  1265. X#define setegid(gid)    setgid(gid)
  1266. X#endif
  1267. X#endif
  1268. X#endif
  1269. X
  1270. X#ifdef NOsetrgid
  1271. X#undef NOsetrgid
  1272. X#endif
  1273. X#ifdef NOsetegid
  1274. X#undef NOsetegid
  1275. X#endif
  1276. X#ifdef NOsetregid
  1277. X#undef NOsetregid
  1278. X#endif
  1279. X#ifdef NOsetresgid
  1280. X#undef NOsetresgid
  1281. X#endif
  1282. X
  1283. X#ifdef NOpow
  1284. X#define tpow(x,y)    (x)
  1285. X#else
  1286. X#define tpow(x,y)    pow(x,y)
  1287. X#endif
  1288. X
  1289. X#ifdef NOmkdir
  1290. X#undef NOmkdir
  1291. X#define mkdir(dir,mode) (-1)
  1292. X#endif
  1293. X
  1294. X#ifdef NOwaitpid
  1295. X#undef NOwaitpid
  1296. X#define waitpid(pid,stat_loc,options)    0
  1297. X#endif
  1298. X
  1299. X#ifdef NOmemmove
  1300. X#define memmove(to,from,count) smemmove(to,from,count)
  1301. X#endif
  1302. X
  1303. X#ifdef SLOWstrstr
  1304. X#ifdef strstr
  1305. X#undef strstr
  1306. X#endif
  1307. X#define strstr(haystack,needle) sstrstr(haystack,needle)
  1308. X#endif
  1309. X
  1310. X#ifndef P
  1311. X#define P(args)        args
  1312. X#endif
  1313. X#define Q(args)        () /* needed until function definitions are ANSI too */
  1314. X
  1315. X#ifdef oBRAIN_DAMAGE
  1316. X#undef oBRAIN_DAMAGE
  1317. X#undef offsetof
  1318. X#endif
  1319. X#ifndef offsetof
  1320. X#define offsetof(s,m) ((char*)&(((s*)sizeof(s))->m)-(char*)sizeof(s))
  1321. X#endif
  1322. X
  1323. X#define SETerrno(v)    (errno=(v))           /* multi-threading errno hook */
  1324. X
  1325. X#define PROGID        /*const*/char progid[]="Stephen R. van den Berg"
  1326. X#define maxindex(x)    (sizeof(x)/sizeof((x)[0])-1)
  1327. X#define STRLEN(x)    (sizeof(x)-1)
  1328. X#define ioffsetof(s,m)    ((int)offsetof(s,m))
  1329. X#define numeric(x)    ((unsigned)(x)-'0'<='9'-'0')
  1330. X#define charNUM(num,v)    char num[8*sizeof(v)*4/10+1+1]
  1331. X
  1332. X#define mx(a,b)        ((a)>(b)?(a):(b))
  1333. X
  1334. Xtypedef unsigned char uschar;         /* sometimes uchar is already typedef'd */
  1335. X#ifdef uchar
  1336. X#undef uchar
  1337. X#endif
  1338. X#define uchar uschar
  1339. X
  1340. X#ifdef NO_const
  1341. X#undef NO_const
  1342. X#endif
  1343. END_OF_FILE
  1344.   if test 9973 -ne `wc -c <'procmail-3.03/src/includes.h'`; then
  1345.     echo shar: \"'procmail-3.03/src/includes.h'\" unpacked with wrong size!
  1346.   fi
  1347.   # end of 'procmail-3.03/src/includes.h'
  1348. fi
  1349. if test -f 'procmail-3.03/src/lockfile.c' -a "${1}" != "-c" ; then 
  1350.   echo shar: Will not clobber existing file \"'procmail-3.03/src/lockfile.c'\"
  1351. else
  1352.   echo shar: Extracting \"'procmail-3.03/src/lockfile.c'\" \(9833 characters\)
  1353.   sed "s/^X//" >'procmail-3.03/src/lockfile.c' <<'END_OF_FILE'
  1354. X/************************************************************************
  1355. X *    lockfile - The conditional semaphore-file creator        *
  1356. X *                                    *
  1357. X *    It has been designed to be able to be run sgid mail or        *
  1358. X *    any gid you see fit (in case your mail spool area is *not*    *
  1359. X *    world writable, but group writable), without creating        *
  1360. X *    security holes.                            *
  1361. X *                                    *
  1362. X *    Seems to be relatively bug free.                *
  1363. X *                                    *
  1364. X *    Copyright (c) 1990-1994, S.R. van den Berg, The Netherlands    *
  1365. X *    #include "../README"                        *
  1366. X ************************************************************************/
  1367. X#ifdef RCS
  1368. Xstatic /*const*/char rcsid[]=
  1369. X "$Id: lockfile.c,v 1.28 1994/06/28 16:56:21 berg Exp $";
  1370. X#endif
  1371. Xstatic /*const*/char rcsdate[]="$Date: 1994/06/28 16:56:21 $";
  1372. X#include "includes.h"
  1373. X#include "sublib.h"
  1374. X#include "exopen.h"
  1375. X#include "mcommon.h"
  1376. X
  1377. X#ifndef SYSTEM_MBOX
  1378. X#define SYSTEM_MBOX    SYSTEM_MAILBOX
  1379. X#endif
  1380. X
  1381. Xstatic volatile exitflag;
  1382. Xpid_t thepid;
  1383. Xuid_t uid;
  1384. Xgid_t sgid;
  1385. Xstatic char systm_mbox[]=SYSTEM_MBOX;
  1386. Xstatic const char dirsep[]=DIRSEP,lockext[]=DEFlockext,
  1387. X nameprefix[]="lockfile: ",lgname[]="LOGNAME",home[]="HOME";
  1388. X
  1389. Xstatic void failure P((void))                      /* signal trap */
  1390. X{ exitflag=2;                           /* merely sets a flag */
  1391. X}
  1392. X                    /* see locking.c for comment on xcreat() */
  1393. Xstatic int xcreat(name,tim)const char*const name;time_t*const tim;
  1394. X{ char*p,*q;int j= -1;size_t i;struct stat stbuf;
  1395. X  for(q=(char*)name;p=strpbrk(q,dirsep);q=p+1);
  1396. X  i=q-name;
  1397. X  if(!(p=malloc(i+UNIQnamelen)))
  1398. X     return exitflag=1;
  1399. X  strncpy(p,name,i);
  1400. X  if(unique(p,p+i,LOCKperm,0,doCHECK|doLOCK))
  1401. X     stat(p,&stbuf),*tim=stbuf.st_mtime,j=myrename(p,name);
  1402. X  free(p);
  1403. X  return j;
  1404. X}
  1405. X
  1406. Xvoid elog(a)const char*const a;
  1407. X{ write(STDERR,a,strlen(a));
  1408. X}
  1409. X
  1410. Xvoid nlog(a)const char*const a;
  1411. X{ elog(nameprefix);elog(a);  /* decent error messages should start with this */
  1412. X}
  1413. X
  1414. Xstatic size_t parsecopy(dest,org,pass)char*const dest;const char*org;
  1415. X const struct passwd*const pass; /* try and digest the mailbox-lockfile name */
  1416. X{ size_t len;const char*chp;char*p;unsigned i;
  1417. X  for(p=dest,len=STRLEN(lockext)+1;;)
  1418. X   { switch(*org)
  1419. X      { case '$':                        /* we substitute */
  1420. X       if(!strncmp(++org,lgname,STRLEN(lgname)))
  1421. X          org+=STRLEN(lgname),chp=pass->pw_name;         /* $LOGNAME and */
  1422. X       else if(!strncmp(org,home,STRLEN(home)))
  1423. X          org+=STRLEN(home),chp=pass->pw_dir;            /* $HOME */
  1424. X       else
  1425. X          goto capac;                 /* no other fancy stuff */
  1426. X       if((i= *org)-'a'<='z'-'a'||i-'A'<='Z'-'A'||numeric(i)||i=='_')
  1427. X          goto capac;
  1428. X       if(p)
  1429. X          p+=strlen(strcpy(p,chp));                  /* paste it in */
  1430. X       len+=strlen(chp);
  1431. X       continue;
  1432. X    default:
  1433. X       if(p)
  1434. X          *p++= *org;              /* simply copy everything else */
  1435. X       len++;org++;
  1436. X       continue;             /* except suspicious looking characters */
  1437. X    case '\'':case '`':case '"':case '\\':case '{':
  1438. X       goto capac;
  1439. X    case '\0':;
  1440. X      }
  1441. X     if(p)
  1442. X      { if(p==dest||!strchr(dirsep,*dest))         /* absolute path wanted */
  1443. Xcapac:     { nlog("Sorry, but turning this mess into a useable mailbox \
  1444. Xexceeds my humble\ncapacities");
  1445. X       return 0;
  1446. X     }
  1447. X    strcpy(p,lockext);
  1448. X      }
  1449. X     return len;
  1450. X   }
  1451. X}
  1452. X
  1453. Xstatic PROGID;
  1454. X
  1455. Xmain(argc,argv)const char*const argv[];
  1456. X{ const char*const*p,*const*lastf;char*cp;uid_t uid;
  1457. X  int sleepsec,retries,invert,force,suspend,retval=EX_OK,virgin=1;
  1458. X  static const char usage[]="Usage: lockfile -nnn | -r nnn | -l nnn | -s nnn \
  1459. X| -! | -ml | -mu | file ...\n";
  1460. X  if(argc<=1)                   /* sanity check, any argument at all? */
  1461. X     goto usg;
  1462. X  sleepsec=DEFlocksleep;retries= -1;suspend=DEFsuspend;thepid=getpid();force=0;
  1463. X  uid=getuid();signal(SIGPIPE,SIG_IGN);
  1464. Xagain:
  1465. X  invert=(char*)progid-(char*)progid;qsignal(SIGHUP,failure);
  1466. X  qsignal(SIGINT,failure);qsignal(SIGQUIT,failure);qsignal(SIGTERM,failure);
  1467. X  for(lastf=p=argv;--argc;)
  1468. X     if(*(cp=(char*)*++p)=='-')
  1469. X    for(cp++;;)
  1470. X     { char*cp2=cp;int i;
  1471. X       switch(*cp++)
  1472. X        { case '!':invert^=1;              /* invert the exitcode */
  1473. X         continue;
  1474. X          case 'r':case 'l':case 's':
  1475. X         if(!*cp&&(cp=(char*)*++p,!--argc)) /* concatenated/seperate */
  1476. X            goto eusg;
  1477. X         i=strtol(cp,&cp,10);
  1478. X         switch(*cp2)
  1479. X          { case 'r':retries=i;
  1480. X               goto checkrdec;
  1481. X            case 'l':force=i;
  1482. X               goto checkrdec;
  1483. X            default:
  1484. X               if(i<0)                /* suspend should be >=0 */
  1485. X              goto eusg;
  1486. X               suspend=i;
  1487. X               goto checkrdec;
  1488. X          }
  1489. X          case HELPOPT1:case HELPOPT2:elog(usage);
  1490. X         elog(
  1491. X "\t-nnn\twait nnn seconds between locking attempts\
  1492. X\n\t-r nnn\tmake at most nnn retries before giving up on a lock\
  1493. X\n\t-l nnn\tset locktimeout to nnn seconds\
  1494. X\n\t-s nnn\tsuspend nnn seconds after a locktimeout occurred\
  1495. X\n\t-!\tinvert the exit code of lockfile\
  1496. X\n\t-ml\tlock your system mail-spool file\
  1497. X\n\t-mu\tunlock your system mail-spool file\n");
  1498. X         goto xusg;
  1499. X          default:
  1500. X         if(sleepsec>=0)        /* is this still the first pass? */
  1501. X          { if((sleepsec=strtol(cp2,&cp,10))<0)
  1502. X               goto eusg;
  1503. Xcheckrdec:        if(cp2==cp)
  1504. Xeusg:             { elog(usage);            /* regular usage message */
  1505. Xxusg:               retval=EX_USAGE;
  1506. X               goto nfailure;
  1507. X             }
  1508. X          }
  1509. X         else              /* no second pass, so leave sleepsec<0 */
  1510. X            strtol(cp2,&cp,10);           /* and discard the number */
  1511. X         continue;
  1512. X          case 'm':          /* take $LOGNAME as a hint, check if valid */
  1513. X           { struct passwd*pass;static char*ma;size_t alen;
  1514. X         if(*cp&&cp[1]||ma&&sleepsec>=0)         /* second pass? */
  1515. X            goto eusg;
  1516. X         if(!ma)            /* ma initialised last time? */
  1517. X          { if(!((ma=(char*)getenv(lgname))&&(pass=getpwnam(ma))&&
  1518. X             pass->pw_uid==uid||(pass=getpwuid(uid))))
  1519. X             { nlog("Can't determine your mailbox, who are you?\n");
  1520. X               goto nfailure;     /* panic, you're not in /etc/passwd */
  1521. X             }
  1522. X            if(!(alen=parsecopy((char*)0,systm_mbox,pass)))
  1523. X             { cp=systm_mbox;
  1524. X               goto lfailure;              /* couldn't digest */
  1525. X             }                          /* mailbox */
  1526. X            if(!(ma=malloc(alen)))           /* ok, make some room */
  1527. X               goto outofmem;
  1528. X            parsecopy(ma,systm_mbox,pass);      /* and fill her up */
  1529. X          }
  1530. X         switch(*cp)
  1531. X          { default:
  1532. X               goto eusg;            /* somebody goofed again */
  1533. X            case 'l':                 /* lock the mailbox */
  1534. X               if(sleepsec>=0)                  /* first pass? */
  1535. X            { cp=ma;
  1536. X              goto stilv;                /* yes, lock it! */
  1537. X            }
  1538. X            case 'u':                   /* unlock the mailbox */
  1539. X               if(unlink(ma))
  1540. X            { nlog("Can't unlock \"");elog(ma);elog("\"");
  1541. X              if(*cp=='l')     /* they messed up, give them a hint */
  1542. X                 elog(" again,\n already dropped my privileges");
  1543. X              elog("\n");
  1544. X            }
  1545. X               else
  1546. X              virgin=0;
  1547. X          }
  1548. X           }
  1549. X          case '\0':;
  1550. X        }
  1551. X       break;
  1552. X     }
  1553. X     else if(sleepsec<0)      /* second pass, release everything we acquired */
  1554. X    unlink(cp);
  1555. X     else
  1556. X      { time_t t;int permanent;
  1557. X    setgid(getgid());              /* just to be on the safe side */
  1558. Xstilv:    virgin=0;permanent=nfsTRY;
  1559. X    while(0>xcreat(cp,&t))                     /* try and lock */
  1560. X     { struct stat stbuf;
  1561. X       if(exitflag)                        /* time to stop? */
  1562. X        { if(exitflag==1)             /* was it failure() or malloc() */
  1563. Xoutofmem:     retval=EX_OSERR,nlog("Out of memory");
  1564. X          else
  1565. X         retval=EX_TEMPFAIL,nlog("Signal received");
  1566. X          goto lfailure;
  1567. X        }
  1568. X       switch(errno)            /* why did the lock not succeed? */
  1569. X        { case EEXIST:              /* hmmm..., by force then? */
  1570. X         if(force&&!lstat(cp,&stbuf)&&force<t-stbuf.st_mtime)
  1571. X          { nlog(unlink(cp)?"Forced unlock denied on \"":
  1572. X             "Forcing lock on \"");
  1573. X            elog(cp);elog("\"\n");sleep(suspend);    /* important */
  1574. X          }
  1575. X         else                       /* no forcing now */
  1576. X            switch(retries)    /* await your turn like everyone else */
  1577. X             { case 0:nlog("Sorry");retval=EX_CANTCREAT;
  1578. X              goto lfailure;      /* patience exhausted, give up */
  1579. X               default:retries--;              /* count sheep */
  1580. X               case -1:sleep(sleepsec);             /* wait and see */
  1581. X             }
  1582. X         break;
  1583. X          case ENOSPC:
  1584. X#ifdef EDQUOT
  1585. X          case EDQUOT:
  1586. X#endif
  1587. X          case ENOENT:case ENOTDIR:case EIO:case EACCES:
  1588. X         if(!--permanent)     /* NFS sporadically generates these */
  1589. X          { sleep(sleepsec);    /* unwarranted, so ignore them first */
  1590. X            continue;
  1591. X          }
  1592. X          default:             /* but, it seems to persist, so give up */
  1593. X         nlog("Try praying");retval=EX_UNAVAILABLE;
  1594. X#ifdef ENAMETOOLONG
  1595. X         goto lfailure;
  1596. X          case ENAMETOOLONG:
  1597. X         if(0<(permanent=strlen(cp)-1)&&      /* can we truncate it? */
  1598. X          !strchr(dirsep,cp[permanent-1]))
  1599. X          { nlog("Truncating \"");elog(cp);          /* then try it */
  1600. X            elog("\" and retrying lock\n");cp[permanent]='\0';
  1601. X            break;
  1602. X          }                     /* otherwise, forget it */
  1603. X         nlog("Filename too long");retval=EX_UNAVAILABLE;
  1604. X#endif
  1605. Xlfailure:     elog(", giving up on \"");elog(cp);elog("\"\n");
  1606. Xnfailure:     sleepsec= -1;argc=lastf-argv+1;        /* mark sleepsec */
  1607. X         goto again;
  1608. X        }  /* for second pass, and adjust argc to the no. of args parsed */
  1609. X       permanent=nfsTRY;           /* refresh the NFS-error-ignore count */
  1610. X     }
  1611. X    lastf=p;                      /* last valid file */
  1612. X      }
  1613. X  if(retval==EX_OK&&virgin)         /* any errors?     did we do anything? */
  1614. Xusg:
  1615. X   { elog(usage);
  1616. X     return EX_USAGE;
  1617. X   }
  1618. X  if(invert)
  1619. X     switch(retval)             /* we only invert the regular cases */
  1620. X      { case EX_OK:
  1621. X       return EX_CANTCREAT;
  1622. X    case EX_CANTCREAT:
  1623. X       return EX_OK;
  1624. X      }
  1625. X  return retval;                   /* all other exitcodes remain */
  1626. X}
  1627. X
  1628. Xvoid*tmalloc(len)const size_t len;                     /* stub */
  1629. X{ void*p;
  1630. X  if(!(p=malloc(len)))
  1631. X     exitflag=1;                     /* signal out of memory */
  1632. X  return p;
  1633. X}
  1634. X
  1635. Xvoid tfree(p)void*const p;                         /* stub */
  1636. X{ free(p);
  1637. X}
  1638. X
  1639. Xint ropen(name,mode,mask)const char*const name;const int mode;
  1640. X const mode_t mask;
  1641. X{ return open(name,mode,mask);                         /* stub */
  1642. X}
  1643. X
  1644. Xint rwrite(fd,a,len)const int fd;const void*const a;const int len;   /* stub */
  1645. X{ return write(fd,a,len);
  1646. X}
  1647. X
  1648. Xint rclose(fd)const int fd;                         /* stub */
  1649. X{ return close(fd);
  1650. X}
  1651. X
  1652. Xvoid writeerr(a)const char*const a;                     /* stub */
  1653. X{
  1654. X}
  1655. END_OF_FILE
  1656.   if test 9833 -ne `wc -c <'procmail-3.03/src/lockfile.c'`; then
  1657.     echo shar: \"'procmail-3.03/src/lockfile.c'\" unpacked with wrong size!
  1658.   fi
  1659.   # end of 'procmail-3.03/src/lockfile.c'
  1660. fi
  1661. if test -f 'procmail-3.03/src/setid.c' -a "${1}" != "-c" ; then 
  1662.   echo shar: Will not clobber existing file \"'procmail-3.03/src/setid.c'\"
  1663. else
  1664.   echo shar: Extracting \"'procmail-3.03/src/setid.c'\" \(1181 characters\)
  1665.   sed "s/^X//" >'procmail-3.03/src/setid.c' <<'END_OF_FILE'
  1666. X/************************************************************************
  1667. X *    setid        executes commands under a different        *
  1668. X *            uid/gid (can only be executed by root)        *
  1669. X *    This program is used by the SmartList installation script only. *
  1670. X ************************************************************************/
  1671. X/*$Id: setid.c,v 1.7 1994/06/28 16:56:47 berg Exp $*/
  1672. X#include "includes.h"
  1673. X
  1674. X#define CHECK_FILE    "install.sh"
  1675. X
  1676. Xmain(argc,argv)const int argc;const char*const argv[];
  1677. X{ struct passwd*p;char*nargv[2];
  1678. X  if(argc!=2&&argc!=3||geteuid()||!(p=getpwnam(argv[1])))
  1679. X   { fprintf(stderr,"Usage: setid user [directory]\n");
  1680. X     return EX_USAGE;
  1681. X   }
  1682. X  endpwent();initgroups(argv[1],p->pw_gid);setgid(p->pw_gid);setuid(p->pw_uid);
  1683. X  if(fopen(CHECK_FILE,"r"))
  1684. X   { struct stat stbuf;
  1685. X     if(argc==2||!stat(argv[2],&stbuf)&&
  1686. X    stbuf.st_uid==p->pw_uid&&
  1687. X    stbuf.st_gid==p->pw_gid)
  1688. X    nargv[0]=getenv("SHELL"),nargv[1]=0,execve(nargv[0],nargv,environ);
  1689. X     else
  1690. X    fprintf(stderr,
  1691. X     "Please create %s with the correct owner and group first\n",argv[2]);
  1692. X   }
  1693. X  else
  1694. X     fprintf(stderr,
  1695. X      "Please make sure %s can read & access the source tree\n",argv[1]);
  1696. X  return EX_UNAVAILABLE;
  1697. X}
  1698. END_OF_FILE
  1699.   if test 1181 -ne `wc -c <'procmail-3.03/src/setid.c'`; then
  1700.     echo shar: \"'procmail-3.03/src/setid.c'\" unpacked with wrong size!
  1701.   fi
  1702.   # end of 'procmail-3.03/src/setid.c'
  1703. fi
  1704. echo shar: End of archive 7 \(of 10\).
  1705. cp /dev/null ark7isdone
  1706. MISSING=""
  1707. for I in 1 2 3 4 5 6 7 8 9 10 ; do
  1708.     if test ! -f ark${I}isdone ; then
  1709.     MISSING="${MISSING} ${I}"
  1710.     fi
  1711. done
  1712. if test "${MISSING}" = "" ; then
  1713.     echo You have unpacked all 10 archives.
  1714.     rm -f ark[1-9]isdone ark[1-9][0-9]isdone
  1715. else
  1716.     echo You still must unpack the following archives:
  1717.     echo "        " ${MISSING}
  1718. fi
  1719. exit 0
  1720. exit 0 # Just in case...
  1721.