home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1994 October / usenetsourcesnewsgroupsinfomagicoctober1994disk2.iso / misc / volume31 / procmail / part04 < prev    next >
Text File  |  1992-07-16  |  58KB  |  1,757 lines

  1. Newsgroups: comp.sources.misc
  2. From: berg@pool.informatik.rwth-aachen.de (Stephen R. van den Berg)
  3. Subject:  v31i043:  procmail - mail processing program v2.71, Part04/05
  4. Message-ID: <1992Jul16.204846.20976@sparky.imd.sterling.com>
  5. X-Md4-Signature: acc6ce8d82c525fa8b729ab10109d6bc
  6. Date: Thu, 16 Jul 1992 20:48:46 GMT
  7. Approved: kent@sparky.imd.sterling.com
  8.  
  9. Submitted-by: berg@pool.informatik.rwth-aachen.de (Stephen R. van den Berg)
  10. Posting-number: Volume 31, Issue 43
  11. Archive-name: procmail/part04
  12. Environment: UNIX, sendmail, smail, MMDF
  13. Supersedes: procmail: Volume 29, Issue 90-94
  14.  
  15. #! /bin/sh
  16. # This is a shell archive.  Remove anything before this line, then unpack
  17. # it by saving it into a file and typing "sh file".  To overwrite existing
  18. # files, type "sh file -c".  You can also feed this as standard input via
  19. # unshar, or by typing "sh <file", e.g..  If this archive is complete, you
  20. # will see the following message at the end:
  21. #        "End of archive 4 (of 5)."
  22. # Contents:  procmail/examples/advanced procmail/man/procmail.man
  23. #   procmail/man/procmailrc.man procmail/retint.c
  24. # Wrapped by berg@minipicc on Thu Jul 16 14:34:21 1992
  25. PATH=/bin:/usr/bin:/usr/ucb ; export PATH
  26. if test -f 'procmail/examples/advanced' -a "${1}" != "-c" ; then 
  27.   echo shar: Will not clobber existing file \"'procmail/examples/advanced'\"
  28. else
  29. echo shar: Extracting \"'procmail/examples/advanced'\" \(11463 characters\)
  30. sed "s/^X//" >'procmail/examples/advanced' <<'END_OF_FILE'
  31. XDiscusses:
  32. X        1. One home directory, several machine architectures
  33. X        2. Procmail as an integrated local mail delivery agent
  34. X        2a.Special directions for sites with sendmail
  35. X        2b.Special directions for sites with smail
  36. X        3. Security considerations (when installing procmail suid root)
  37. X        4. How to generate autoreplies
  38. X        4a.`Vacation' functionality
  39. X        5. Some exorbitant examples of rcfile formats
  40. X        6. Some advanced examples of the use of the 'A' flag
  41. X
  42. X                ---
  43. X
  44. X1. One home directory, several machine architectures
  45. X   -------------------------------------------------
  46. X
  47. XFor users that have the very same home directory on machines with differing
  48. Xarchitectures (i.e. you need different executables), and they
  49. Xhave to explicitly use (i.e. the system administrator did not arrange,
  50. Xfor example, /usr/local/bin/procmail to have exactly the right contents
  51. Xdepending on from which machine it is called) two executables of procmail,
  52. XI have the following suggestion to use as a .forward file (examples are for
  53. Xsparc and sun3 architectures):
  54. X
  55. X"|IFS=' ';if /usr/bin/sparc;then exec /home/berg/bin.sun4/procmail;else exec /home/berg/bin.sun3/procmail;fi #YOUR_LOGIN_NAME"
  56. X
  57. Xor alternatively:
  58. X
  59. X"|IFS=' ';exec /home/berg/bin.`/usr/bin/arch`/procmail #YOUR_LOGIN_NAME"
  60. X
  61. XPlease note, in the .forward file there can NOT be any newlines between
  62. Xthe doublequotes, i.e. the former example *has* to be typed in as one long
  63. Xline.
  64. X
  65. XIf, on the other hand, you have to log in to every machine to read mail
  66. Xarrived for you on that machine, a different solution might be more
  67. Xappropriate; in that case put something like the following two lines in your
  68. X.forward file:
  69. X
  70. XYOUR_LOGIN_NAME@your.favourite.machine
  71. X"|IFS=' ';if test .`/bin/uname -n` = .your.favourite.machine; then /exec /home/berg/bin/procmail; else exit 0; fi #YOUR_LOGIN_NAME"
  72. X
  73. XThe leading dots are important.     Check what `/bin/uname -n` returns on
  74. Xyour.favourite.machine, and substitute that for your.favourite.machine in the
  75. Xsample .forward file.  If your system does not have /bin/uname, /bin/hostname
  76. Xwill do too.
  77. X
  78. X                ---
  79. X
  80. X2. Procmail as an integrated local mail delivery agent
  81. X   ---------------------------------------------------
  82. X
  83. XCompletely integrating procmail in the mail delivery means that mail is
  84. Xdelivered as normal, unless a .procmailrc file is present in the home
  85. Xdirectory of the recipient.  This will be completely independent of the
  86. Xfact if a .forward file is present.  This will not break anything, it
  87. Xjust makes the use of procmail easier because people are not required to
  88. Xstart up procmail from within their .forward files.  Creation of a .procmailrc
  89. Xfile will suffice.
  90. X
  91. XThe generic way to accomplish this (works with sendmail, smail and any other
  92. Xmail system that uses a local mail delivery program that takes the mail-
  93. Xto-be-delivered on stdin and the recipient(s) on the command line, with or
  94. Xwithout the "-d" option) is this:
  95. X
  96. XMove your current local mail delivery agent (e.g. /bin/mail, /bin/lmail,
  97. X/usr/lib/mail/mail.local, etc.) out of the way, and create a (symbolic or hard)
  98. Xlink from there to procmail, as in "ln /usr/local/bin/procmail /bin/lmail".
  99. X
  100. XIn addition to needing root priviliges upon startup, on some systems procmail
  101. Xneeds to be sgid to daemon or mail.  One way to check is by looking at the
  102. Xcurrent mail delivery agent (usually /bin/mail) and to mimic its permissions,
  103. Xowner and group.  If you're not quite sure, just type "make recommend" and some
  104. Xsuitable recommendations will be made for your particular environment.
  105. X
  106. XThe same might apply to the "lockfile" program, in order for it to be able to
  107. Xcreate and unlink lockfiles in the mail spool directory it might need to be
  108. Xsgid to daemon or mail, not to worry however, "lockfile" will not enable users
  109. Xto abuse the sgid/suid-ness.
  110. X
  111. X                ---
  112. X
  113. X2a.Special directions for sites with sendmail
  114. X   ------------------------------------------
  115. X
  116. XHere you have two options:
  117. X i. Procmail *not* being suid root
  118. X ii.Procmail suid root (actually preferred and recommended)
  119. X
  120. X)Ad i.
  121. XThe following line should take the place of the standard
  122. XMlocal rule in your sendmail.cf (this way sendmail will start up procmail with
  123. Xroot priv, procmail will immediately setuid itself to the recipient's uid):
  124. X
  125. XMlocal, P=/usr/local/bin/procmail, F=lsSDFMuhP, S=10, R=20, A=procmail -d $u
  126. X
  127. X)Ad ii.
  128. XIf your sendmail does not allow starting programs with root privs (the
  129. X'S' flag), you can instead make procmail suid root (this is actually the
  130. Xpreferred way to go, it closes a security hole which actually sendmail should
  131. Xhave closed).  This will not create a security hole, procmail will normally
  132. Xsetuid immediately to the real uid (effectively losing root privs), or will
  133. Ximmediately setuid to the recipient's uid (and be completely loyal to the
  134. Xrecipient's absent or present .procmailrc file).  Actually installing procmail
  135. Xsuid root is a slightly more flexible approach (not at all more dangerous).
  136. X
  137. XIf using the suid root version of procmail, you only need to insert the
  138. Xfollowing line in your sendmail.cf:
  139. X
  140. XMlocal, P=/usr/local/bin/procmail, F=lsDFMuhP, S=10, R=20, A=procmail -d $u
  141. X
  142. XSo, to summarise, if you install procmail not-suid-root you should use the
  143. Xfirst rule (with the 'S' flag), and if you install it suid-root you should
  144. Xuse the second rule (without the 'S' flag).  If you install procmail
  145. Xnot-suid-root you cannot use the second rule, since procmail will not be
  146. Xable to change uid to the recipient, and therefore it cannot read/write
  147. Xthe recipient's files (including any .procmailrc).  The alternative would
  148. Xbe that procmail already has the recipient's uid upon startup, this is not
  149. Xpossible in sendmail without changing some configuration options.
  150. X
  151. XAs for the remaining flags "S=10, R=20", if your system uses others or
  152. Xnone on the current Mlocal rule, use those instead of "S=10, R=20".
  153. X
  154. X                ---
  155. X
  156. X2b.Special directions for sites with smail
  157. X   ---------------------------------------
  158. X
  159. XFor smail 2.x users there are two options:
  160. X i. Move the current local-mail-delivery program (probably /bin/lmail) out of
  161. X    the way, make a symbolic or hard link from procmail to the name of that
  162. X    program (e.g. "ln /usr/local/bin/procmail /bin/lmail")
  163. X ii.Make sure the following macro is defined in src/defs.h:
  164. X    #define LMAIL(frm,sys) "/usr/local/bin/procmail -d"
  165. X
  166. XFor smail 3.x users there are also two options:
  167. X i. The same solution as for smail 2.x (however, method ii is preferred)
  168. X ii.Replace any existing "local"-entry in the /usr/lib/smail/transports file
  169. X    (create one, if need be) with the following two lines:
  170. X
  171. Xlocal: return_path, local, from, driver=pipe;
  172. X    cmd="/usr/local/bin/procmail -d $($user$)"
  173. X
  174. XFor any ideas on suid/sgid modes which *might* be needed, see the previous
  175. Xparagraph (2).
  176. X
  177. X                ---
  178. X
  179. X3. Security considerations (when installing procmail suid root)
  180. X   -------------------------------------------------------------
  181. X
  182. XIf in EXPLICIT DELIVERY mode (typically when called from within sendmail)
  183. Xprocmail will ALWAYS change UID and gid to the RECIPIENT's defaults as soon as
  184. Xit starts reading the recipient's $HOME/.procmailrc file.
  185. X
  186. XIf NOT in explicit delivery mode (typically when called from within the
  187. Xrecipient's $HOME/.forward file) procmail will ALWAYS change UID and gid to
  188. Xthe real uid and gid of the INVOKER (effectively losing any suid or sgid
  189. Xpriviliges).
  190. X
  191. XThese two precautions should effectively eliminate any security holes because
  192. Xprocmail will always have the uid of the person whose commands it is executing.
  193. X
  194. XTo summarise, procmail will only behave better if made suid/sgid something, in
  195. Xfact, making procmail suid/sgid something will *improve* security on systems
  196. Xwhich have dynamically linked libraries.
  197. X
  198. X                ---
  199. X
  200. X4. How to generate autoreplies
  201. X   ---------------------------
  202. X
  203. XUsing a recipe like the following, you can generate autoreplies to mail
  204. Xreceived by you:
  205. X
  206. X: 2 h c
  207. X!^From +[^ ]*(postmaster|Mailer)
  208. X!^From +YOUR_LOGIN_NAME
  209. X| (formail -r ; echo "Mail received.") | $SENDMAIL -t
  210. X
  211. XAs you can see, I made sure that neither bouncing mail (from postmaster or the
  212. Xmailer-daemon), nor mail coming from yourself will be autoreplied.  If this
  213. Xprecaution would not be taken, disaster could result ("ringing" mail).
  214. XThe abovementioned recipe should be inserted before all other recipes in
  215. Xyour rcfile, however, it is advisable to put it *after* any recipes that
  216. Xprocess mailinglist subscriptions;  it generally is not a good idea to
  217. Xgenerate autoreplies to mailinglists.
  218. X
  219. X                ---
  220. X
  221. X4a.`Vacation' functionality
  222. X   ------------------------
  223. X
  224. XSHELL=/bin/sh            # for other shells, this might need adjustment
  225. XALREADYSENT=$MAILDIR/vacation            # the vacation database
  226. X
  227. X: 2 hWc:                # the lockfile is important
  228. X!^From +[^ ]*(postmaster|Mailer)
  229. X!^From +YOUR_LOGIN_NAME
  230. X| FROM="`formail -rx To:`" ;\
  231. X  if fgrep -e "$FROM" <$ALREADYSENT ;\
  232. X  then exit 1 ;\
  233. X  else echo "$FROM" >>$ALREADYSENT ;\
  234. X  fi
  235. X
  236. X    :ahc
  237. X    | (formail -r ; echo "Mail received.") | $SENDMAIL -t
  238. X
  239. XThis example is based on the same principles as before (sort out bounced mail
  240. Xand mail coming from oneself).    In addition to that however, it maintains a
  241. Xvacation database by extracting the name of the sender and appending it
  242. Xto $ALREADYSENT if the name is *not* already in there.    If the name was new,
  243. Xan autoreply will be sent (using the "a" flag functionality, see the man
  244. Xpage of procmail for more info).  To reliably extract the name of the sender,
  245. XI let formail generate an autoreply header (thereby making it figure out the
  246. Xmost appropriate sender address), and then telling it to extract the value
  247. Xof the "To:" field.
  248. X
  249. X                ---
  250. X
  251. X5. Some exorbitant examples of rcfile formats
  252. X   ------------------------------------------
  253. X
  254. X# Now follows an example of what you can do in a procmailrc file
  255. XHELLO=oneword
  256. XHELLO="two words"
  257. XHELLO='two words'    HELLO  =    one\
  258. Xword
  259. XHELLO=two\ words
  260. XHELLO=two\ `echo words`
  261. XHELLO=            # empty
  262. XHELLO            # This will wipe "HELLO" from the environment
  263. XHELLO     =    "three words"\ yes
  264. XHELLO    =    "$HELLO `cat somefile`    "    # Trailing blanks
  265. XHELLO = "wheeee`date`${HELLO} this works too"     HELLO = 'But so does this!'
  266. X
  267. X# As you can see, every trick in the book of /bin/sh programming can be used
  268. X# (and more).
  269. X
  270. XLOCALLOCKFILE = llf
  271. X
  272. X  ::$LOCALLOCKFILE
  273. Xgrep for this
  274. X |$HELLO        # calls up a program named "But" with 3 arguments
  275. X
  276. X:: "test ing"        # lockfilename with a space in it
  277. Xgrep for this
  278. X  |$HELLO
  279. X
  280. X:
  281. Xor for this
  282. X|"$HELLO"        # tries to call up a program named "But so does this!"
  283. X
  284. X:
  285. Xand this
  286. X|$HELLO \
  287. Xthere        # action lines can be continued
  288. X
  289. X                ---
  290. X
  291. X6. Some advanced examples of the use of the 'A' flag
  292. X   -------------------------------------------------
  293. X
  294. X:c        # Specify the 'c' otherwise we never arrive at the next recipe
  295. X^From Myfriend
  296. Xevery_message_from_my_friend        # Mailbox for everything he/she writes
  297. X
  298. X:Ac            # Note the 'c' again
  299. X! my_other_friend      # Forward everything Myfriend writes to my_other_friend
  300. X
  301. X:1Ac
  302. X^Subject:.*jokes
  303. X! my_third_friend    # Forward everything Myfriend writes about jokes
  304. X            # to my_third_friend
  305. X
  306. X:2A
  307. X^Subject:.*parties
  308. X!beach
  309. X! my_third_friend    # Forward everything Myfriend writes about parties,
  310. X            # except beach parties, to my_third_friend
  311. X
  312. X:A            # Provide a mail sink, in order to fake procmail into
  313. X/dev/null        # believing that the mail was absorbed/delivered,
  314. X            # even if the mail was about beach parties :-).
  315. X        # This is not the best solution though, better would be to
  316. X        # rearrange these last five recipes so that the current
  317. X        # number one or two is last, the current number five can be
  318. X        # omitted then.
  319. X
  320. X                ---
  321. END_OF_FILE
  322. if test 11463 -ne `wc -c <'procmail/examples/advanced'`; then
  323.     echo shar: \"'procmail/examples/advanced'\" unpacked with wrong size!
  324. fi
  325. # end of 'procmail/examples/advanced'
  326. fi
  327. if test -f 'procmail/man/procmail.man' -a "${1}" != "-c" ; then 
  328.   echo shar: Will not clobber existing file \"'procmail/man/procmail.man'\"
  329. else
  330. echo shar: Extracting \"'procmail/man/procmail.man'\" \(12373 characters\)
  331. sed "s/^X//" >'procmail/man/procmail.man' <<'END_OF_FILE'
  332. X.de Id
  333. X.ds Rv \\$3
  334. X.ds Dt \\$4
  335. X..
  336. X.Id $Id: procmail.man,v 2.27 1992/06/03 14:40:24 berg Rel $
  337. X.de Sh
  338. X.br
  339. X.ne 11
  340. X.SH "\\$1"
  341. X..
  342. X.de Ss
  343. X.br
  344. X.ne 10
  345. X.SS "\\$1"
  346. X..
  347. X.de Tp
  348. X.br
  349. X.ne 9
  350. X.TP \\$1
  351. X..
  352. X.de Rs
  353. X.na
  354. X.nf
  355. X.RS
  356. X..
  357. X.de Re
  358. X.RE
  359. X.fi
  360. X.ad
  361. X..
  362. X.TH PROCMAIL 1 \*(Dt BuGless
  363. X.SH NAME
  364. X.na
  365. Xprocmail \- autonomous mail processor
  366. X.SH SYNOPSIS
  367. X.B procmail
  368. X.RB [ \-+PRESERVOPT++TEMPFAILOPT+ ]
  369. X.RB [ "\-+FROMWHOPT+ \fIfromwhom\fP" ]
  370. X.RI [ "parameter\fB=\fPvalue " | " rcfile" ]
  371. X\&.\|.\|.
  372. X.br
  373. X.B procmail
  374. X.RB [ \-+PRESERVOPT++TEMPFAILOPT+ ]
  375. X.RB [ "\-+FROMWHOPT+ \fIfromwhom\fP" ]
  376. X.B \-+DELIVEROPT+
  377. X.I recipient
  378. X\&.\|.\|.
  379. X.br
  380. X.B procmail
  381. X.B \-+VERSIONOPT+
  382. X.ad
  383. X.Sh DESCRIPTION
  384. XFor a quick start, see
  385. X.B NOTES
  386. Xat the end.
  387. X.PP
  388. X.B Procmail
  389. Xshould be invoked automatically over the
  390. X.B +DOT_FORWARD+
  391. Xfile mechanism as soon as mail arrives.  Alternatively, when installed by
  392. Xa system administrator, it can be invoked from within the mailer immediately.
  393. XWhen invoked, it first sets some environment variables to default values,
  394. Xreads the mail message from stdin until an EOF, separates the body from the
  395. Xheader, and then, if no command line arguments are present, it starts to look
  396. Xfor a file named
  397. X.B +PROCMAILRC+
  398. Xin your home directory.  According to the processing recipes in this file,
  399. Xthe mail message that just arrived gets distributed into the right folder
  400. X(and more).
  401. X.PP
  402. XIf running suid root or with root priviliges, procmail will be able to
  403. Xperform as a functionally enhanced, backwards compatible mail delivery agent.
  404. X.PP
  405. XThe rcfile format is described in detail in the
  406. X.BR procmailrc (5)
  407. Xman page.
  408. X.PP
  409. XExamples for rcfile recipes can be looked up in the
  410. X.BR procmailex (5)
  411. Xman page.
  412. X.Ss Signals
  413. X.Tp 1.2i
  414. X.B TERMINATE
  415. XTerminate prematurely and requeue the mail.
  416. X.Tp
  417. X.B HANGUP
  418. XTerminate prematurely and bounce the mail.
  419. X.Tp
  420. X.B INTERRUPT
  421. XTerminate prematurely and bounce the mail.
  422. X.Tp
  423. X.B QUIT
  424. XTerminate prematurely and silently lose the mail.
  425. X.Tp
  426. X.B ALARM
  427. XForce a timeout (see
  428. X.BR TIMEOUT).
  429. X.Sh OPTIONS
  430. X.Tp 0.5i
  431. X.B \-+VERSIONOPT+
  432. XProcmail will print its version number and exit.
  433. X.Tp
  434. X.B \-+PRESERVOPT+
  435. XPreserve any old environment.  Normally procmail clears the environment
  436. Xupon startup+KEEPENV+.  However, in any case: any default values will override
  437. Xany preexisting environment variables, i.e. procmail will not pay any attention
  438. Xto any predefined environment variables, it will happily overwrite them
  439. Xwith its own defaults.
  440. X.Tp
  441. X.B \-+TEMPFAILOPT+
  442. XMake procmail fail softly, i.e. if procmail cannot deliver the mail to
  443. Xany of the destinations you gave, the mail will not bounce, but will return
  444. Xto the mailqueue.  Another delivery-attempt will be made at some time in
  445. Xthe future.
  446. X.Tp
  447. X.I "\fB\-+FROMWHOPT+\fP fromwhom"
  448. XCauses procmail to regenerate the leading `+FROM+' line with
  449. X.I fromwhom
  450. Xas the sender (instead of \-+FROMWHOPT+ one could use the alternate and
  451. Xobsolete \-+ALTFROMWHOPT+).
  452. X.Tp
  453. X.I "\fB\-+DELIVEROPT+\fP recipient .\|.\|."
  454. XThis turns on explicit delivery mode, delivery will be to the local user
  455. X.IR recipient .
  456. XThis, of course, only is possible if procmail has root priviliges.
  457. XProcmail will setuid to the intended recipients and shall
  458. X.I only
  459. Xread the recipient's +PROCMAILRC+ file (if present, if not, delivery is like
  460. Xordinary mail).
  461. X.Sh ARGUMENTS
  462. XAny arguments containing an '=' are considered to be environment variable
  463. Xassignments, they will
  464. X.I all
  465. Xbe evaluated after the default values have been
  466. Xassigned and before the first rcfile is opened.
  467. X.PP
  468. XAny other arguments are presumed to be rcfile paths (absolute or relative to
  469. X$HOME); procmail will start with the first one it finds on the command line.
  470. XThe following ones will only be parsed if the preceding ones have a not
  471. Xmatching HOST-directive entry, or in case they should not exist.
  472. X.PP
  473. XIf no rcfiles are specified, it looks for
  474. X.BR $HOME/+PROCMAILRC+ .
  475. XIf not even that can be found, processing will continue according to
  476. Xthe default settings of the environment variables and the ones specified
  477. Xon the command line.
  478. X.Sh CAVEATS
  479. XAny default values that procmail has for some environment variables will
  480. X.B always
  481. Xoverride the ones that were already defined.  If you really want to
  482. Xoverride the defaults, you either have to put them in the
  483. X.B rcfile
  484. Xor in the command line as arguments.
  485. X.Sh FILES
  486. X.Tp 2.3i
  487. X.B /etc/passwd
  488. Xto get the recipient's USER, HOME and SHELL variable defaults
  489. X.Tp
  490. X.B +SYSTEM_MBOX+
  491. Xsystem mailbox
  492. X.Tp
  493. X.B $HOME/+PROCMAILRC+
  494. Xdefault rcfile
  495. X.Tp
  496. X.B +SYSTEM_MBOX++DEFlockext+
  497. Xlockfile for the system mailbox (not used by procmail automatically, unless
  498. X$DEFAULT equals +SYSTEM_MBOX+ and procmail is delivering to $DEFAULT)
  499. X.Tp
  500. X.B +DEFsendmail+
  501. Xdefault mail forwarder
  502. X.Tp
  503. X.B +UNIQ_PREFIX+????`hostname`
  504. Xtemporary `unique' zero-length files created by procmail
  505. X.Sh "SEE ALSO"
  506. X.na
  507. X.BR procmailrc (5),
  508. X.BR procmailex (5),
  509. X.BR sh (1),
  510. X.BR csh (1),
  511. X.BR mail (1),
  512. X.BR binmail (1),
  513. X.BR uucp (1C),
  514. X.BR aliases (5),
  515. X.BR sendmail (8),
  516. X.BR egrep (1V),
  517. X.BR lockfile (1),
  518. X.BR formail (1)
  519. X.ad
  520. X.Sh DIAGNOSTICS
  521. X.Tp 2.3i
  522. XBad substitution of "x"
  523. XNot a valid environment variable name specified.
  524. X.Tp
  525. XCouldn't unlock "x"
  526. XLockfile was already gone, or write permission to the directory were the
  527. Xlockfile is has been denied.
  528. X.Tp
  529. XError while writing to "x"
  530. XNonexistent subdirectory, no write permission, pipe died or disk full.
  531. X.Tp
  532. XExceeded LINEBUF
  533. XBuffer overflow detected, LINEBUF was too small, memory might be corrupted.
  534. X.Tp
  535. XFailed forking "x"
  536. XProcess table is full (and NORESRETRY has been exhausted).
  537. X.Tp
  538. XFailed to execute "x"
  539. XProgram not in path, or not executable.
  540. X.Tp
  541. XForced unlock denied on "x"
  542. XNo write permission in the directory where
  543. X.B lockfile
  544. Xresides, or more than one procmail trying to force a lock at exactly the same
  545. Xtime.
  546. X.Tp
  547. XForcing lock on "x"
  548. XSpecified
  549. X.B lockfile
  550. Xis going to be removed by force because of a timeout (see also:
  551. X.BR LOCKTIMEOUT ).
  552. X.Tp
  553. XLock failure on "x"
  554. XCan only occur if you specify some real weird (and illegal) lockfilenames
  555. Xor if the
  556. X.B lockfile
  557. Xcould not be created because of insufficient permissions or noexistent
  558. Xsubdirectories.
  559. X.Tp
  560. XMissing name
  561. XThe \-+FROMWHOPT+ option needs an extra argument
  562. X.Tp
  563. XMissing recipient
  564. XYou specified the \-+DELIVEROPT+ option or called procmail under a different
  565. Xname, it expects one or more recipients as arguments
  566. X.Tp
  567. XOut of memory
  568. XThe system is out of swap space (and NORESRETRY has been exhausted).
  569. X.Tp
  570. XProcessing continued
  571. XThe unrecognised options on the command line are ignored, proceeding as
  572. Xusual.
  573. X.Tp
  574. XProgram failure of "x"
  575. XProgram that was started by procmail didn't return EX_OK (=+EX_OK+).
  576. X.Tp
  577. XSkipped: "x"
  578. XCouldn't do anything with "x" in the rcfile (syntax error), ignoring it.
  579. X.Tp
  580. XSuspicious rcfile
  581. XThe owner of the rcfile was not the recipient, or the directory that contained
  582. Xit was world writeable (the rcfile was not used)
  583. X.Tp
  584. XTerminating prematurely whilst waiting for .\|.\|.
  585. XProcmail received a signal while it was waiting for .\|.\|.
  586. X.Tp
  587. XTimeout, terminating "x"
  588. XTimeout has occurred on program/filter "x".
  589. X.Tp
  590. XTruncating "x" and retrying lock
  591. X"x" does not seem to be a valid filename or the file is not empty.
  592. X.Tp
  593. XRescue of unfiltered data succeeded/failed
  594. XA filter returned unsuccessfully, procmail tried to get back the original text.
  595. X.Tp
  596. XUnexpected EOL
  597. XMissing closing quote, or trying to escape EOF.
  598. X.Sh "EXTENDED DIAGNOSTICS"
  599. X.Tp 2.3i
  600. XAssigning "x"
  601. XEnvironment variable assignment
  602. X.Tp
  603. XExecuting "x"
  604. XStarting program "x"
  605. X.Tp
  606. XHOST mismatched "x"
  607. XThis host was called "x", HOST contained something else
  608. X.Tp
  609. XLocking "x"
  610. XCreating lockfile "x"
  611. X.Tp
  612. XMatch on "x"
  613. XCondition matched
  614. X.Tp
  615. XNo match on "x"
  616. XCondition didn't match, recipe skipped
  617. X.Tp
  618. XOpening "x"
  619. XOpening file "x" for appending
  620. X.Tp
  621. XOpening directory "x"
  622. XOpening a directory for finding the highest file number
  623. X.Tp
  624. XRcfile: "x"
  625. XRcfile changed to "x"
  626. X.Tp
  627. XUnlocking "x"
  628. XRemoving lockfile "x" again
  629. X.Sh WARNINGS
  630. XYou should create a shell script that uses
  631. X.BR lockfile (1)
  632. Xbefore invoking your mail shell on any mailbox file other than the system
  633. Xmailbox (unless of course, your mail shell uses the same lockfiles (local
  634. Xor global) you specified in your rcfile).
  635. X.PP
  636. XIn the unlikely event that you absolutely need to kill procmail before it has
  637. Xfinished, first try and use the regular kill command (i.e.
  638. X.I not
  639. Xkill -9, see the subsection
  640. X.I Signals
  641. Xfor suggestions), otherwise some
  642. X.I lockfiles
  643. Xmight not get removed.
  644. X.PP
  645. XBeware when using the
  646. X.B \-+TEMPFAILOPT+
  647. Xoption, if procmail repeatedly is unable to deliver the mail (e.g. due to
  648. Xan incorrect rcfile), the system mailqueue could fill up.  This could
  649. Xaggravate both the local postmaster and other users.
  650. X.Sh BUGS
  651. XAfter a lockfile is removed by force, a suspension of $SUSPEND seconds
  652. Xis taken into account, in order to prevent the inadvertent immediate removal
  653. Xof any newly created lockfile by another program.
  654. X.PP
  655. XProcmail uses the regular TERMINATE signal to terminate any runaway filter,
  656. Xbut it does not check if the filter responds to that signal and it only sends
  657. Xit to the filter itself, not to any of the filter's children.
  658. X.Sh MISCELLANEOUS
  659. XAny lines in the body of the message that look like postmarks are prepended
  660. Xwith `+ESCAP+' (disarms bogus mailheaders).  The regular expression that is
  661. Xused to search for these postmarks is:
  662. X.Rs
  663. X"+FROM_EXPR+"
  664. X.Re
  665. X.PP
  666. XIf the destination name used in explicit delivery mode is not in /etc/passwd,
  667. Xprocmail will proceed as if explicit delivery mode was not in effect.
  668. XIf not in explicit delivery mode and
  669. Xshould the uid procmail is running under, have no corresponding /etc/passwd
  670. Xentry, then HOME will default to +Tmp+, USER will default to #uid.
  671. X.PP
  672. XWhen in explicit delivery mode, procmail will generate a leading `+FROM+'
  673. Xline if none is present.  If one is already present+TRUSTED_IDS+ procmail will
  674. Xleave it intact.
  675. X.PP
  676. XFor security reasons procmail will only use an rcfile if it is owned by the
  677. Xrecipient or if the directory it is contained in, is not world writeable.
  678. X.PP
  679. XIf +SYSTEM_MBOX+ is a bogus mailbox (i.e. does not belong to the recipient,
  680. Xis unwritable, is a symbolic link or is a hard link), procmail will upon
  681. Xstartup try to rename it into a file starting with `+BOGUSprefix+' and
  682. Xending in an inode-sequence-code.  If this turns out to be impossible,
  683. X.B ORGMAIL
  684. Xwill have
  685. X.I no
  686. Xinitial value.
  687. X.PP
  688. XWhen delivering to directories (or to MH folders) you
  689. X.B don't
  690. Xneed to use lockfiles to prevent several concurrently running procmail
  691. Xprograms from messing up.
  692. X.PP
  693. XDelivering to MH folders is slightly more time consuming than delivering
  694. Xto normal directories or mailboxes, because procmail has to search for
  695. Xthe next available number (instead of having the filename immediately
  696. Xavailable).
  697. X.PP
  698. XOn general failure procmail will return EX_CANTCREAT, unless option
  699. X.B \-+TEMPFAILOPT+
  700. Xis specified, in which case it will return EX_TEMPFAIL.
  701. X.PP
  702. XTo make `egrepping' of headers more consistent, procmail concatenates all
  703. Xcontinued header fields.
  704. X.PP
  705. XIf procmail is called under a different name than `procmail' (i.e. if it
  706. Xis linked to another name and invoked as such), it comes up in explicit
  707. Xdelivery mode, and expects the recipients' names as command line arguments
  708. X(as if \-+DELIVEROPT+ had been specified).
  709. X.PP
  710. XProcmail performs the locking in an NFS-secure way.
  711. X.br
  712. X.ne 11
  713. X.Sh NOTES
  714. XCalling up procmail with the \-+HELPOPT1+ or \-+HELPOPT2+ options will cause
  715. Xit to display a command-line help and flags quick-reference page.
  716. X.PP
  717. XIf procmail is
  718. X.I not
  719. Xinstalled globally as the default mail delivery agent (ask your system
  720. Xadministrator), you have to make sure it is invoked when your mail arrives.
  721. XIn this case your $HOME/+DOT_FORWARD+ (beware, it
  722. X.B has
  723. Xto be world readable) file should contain the line below.  Be sure to include
  724. Xthe single and double quotes, and it
  725. X.I must
  726. Xbe an
  727. X.I absolute
  728. Xpath.  The `#YOUR_LOGIN_NAME' is not actually a parameter that is required by
  729. Xprocmail, actually, it will be discarded by /bin/sh before procmail ever
  730. Xsees it; it is however a necessary bug fix against overoptimising sendmail
  731. Xprograms:
  732. X.PP
  733. X.na
  734. X.nf
  735. X+FW_content+
  736. X.fi
  737. X.ad
  738. X.br
  739. X.ne 14
  740. X.Ss "A sample small +PROCMAILRC+:"
  741. X.na
  742. X.nf
  743. XPATH=/bin:/usr/bin:/usr/local/bin
  744. XMAILDIR=$HOME/Mail      #you'd better make sure it exists
  745. XDEFAULT=$MAILDIR/mbox
  746. XLOGFILE=$MAILDIR/from
  747. X::
  748. X^From.*berg
  749. Xfrom_me
  750. X:
  751. X^Subject:.*Flame
  752. X/dev/null
  753. X.fi
  754. X.ad
  755. X.Sh AUTHOR
  756. XStephen R. van den Berg at RWTH-Aachen, Germany
  757. X.Rs
  758. Xberg@pool.informatik.rwth-aachen.de
  759. Xberg@physik.tu-muenchen.de
  760. X.Re
  761. END_OF_FILE
  762. if test 12373 -ne `wc -c <'procmail/man/procmail.man'`; then
  763.     echo shar: \"'procmail/man/procmail.man'\" unpacked with wrong size!
  764. fi
  765. # end of 'procmail/man/procmail.man'
  766. fi
  767. if test -f 'procmail/man/procmailrc.man' -a "${1}" != "-c" ; then 
  768.   echo shar: Will not clobber existing file \"'procmail/man/procmailrc.man'\"
  769. else
  770. echo shar: Extracting \"'procmail/man/procmailrc.man'\" \(15197 characters\)
  771. sed "s/^X//" >'procmail/man/procmailrc.man' <<'END_OF_FILE'
  772. X.de Id
  773. X.ds Rv \\$3
  774. X.ds Dt \\$4
  775. X..
  776. X.Id $Id: procmailrc.man,v 2.6 1992/06/03 12:58:50 berg Rel $
  777. X.de Sh
  778. X.br
  779. X.ne 11
  780. X.SH "\\$1"
  781. X..
  782. X.de Ss
  783. X.br
  784. X.ne 10
  785. X.SS "\\$1"
  786. X..
  787. X.de Tp
  788. X.br
  789. X.ne 9
  790. X.TP \\$1
  791. X..
  792. X.de Rs
  793. X.na
  794. X.nf
  795. X.RS
  796. X..
  797. X.de Re
  798. X.RE
  799. X.fi
  800. X.ad
  801. X..
  802. X.TH PROCMAILRC 5 \*(Dt BuGless
  803. X.SH NAME
  804. X.na
  805. Xprocmailrc \- procmail rcfile
  806. X.SH SYNOPSIS
  807. X.B $HOME/+PROCMAILRC+
  808. X.ad
  809. X.Sh DESCRIPTION
  810. XFor a quick start, see
  811. X.B NOTES
  812. Xat the end of the
  813. X.BR procmail (1)
  814. Xman page.
  815. X.PP
  816. XThe rcfile can contain a mixture of environment variable assignments (some
  817. Xof which have special meanings to procmail), and recipes.  In their most
  818. Xsimple appearance, the recipes are simply one line regular expressions
  819. Xthat are searched for in the header of the arriving mail, the first recipe
  820. Xthat matches is used to determine where the mail has to go (usually a file).
  821. X.PP
  822. XIf a matching recipe does not specify any special flags (like `+FILTER+' or
  823. X`+CONTINUE+') and the recipe is successful (i.e. no write failures or other
  824. Xcalamities), then processing of the rcfile will cease at this point, and
  825. Xprocmail will consider the mail to have been delivered.
  826. X.PP
  827. XThis enables you to presort your mail extremely straightforward into several
  828. Xmailfolders.  Bear in mind though that the mail can arrive concurrently in
  829. Xthese mailfolders (if several procmail programs happen to run at the same time,
  830. Xnot unlikely if a lot of mail arrives), to make sure this does not result in a
  831. Xmess, proper use of lockfiles is highly recommended.
  832. X.PP
  833. XThe environment variable
  834. X.B assignments
  835. Xand
  836. X.B recipes
  837. Xcan be freely intermixed in the rcfile. If any environment variable has
  838. Xa special meaning to procmail, it will be used appropiately the moment
  839. Xit is parsed. (i.e. you can change the current directory whenever you
  840. Xwant by specifying a new
  841. X.BR MAILDIR ,
  842. Xswitch lockfiles by specifying a new
  843. X.BR LOCKFILE ,
  844. Xchange the umask at any time, etc., the possibilities are endless :-).
  845. X.PP
  846. XThe assignments and substitutions of these environment variables are handled
  847. Xexactly like in
  848. X.BR sh (1)
  849. X(that includes all possible quotes and escapes),
  850. Xwith the added bonus that blanks around the '=' sign are ignored and that,
  851. Xif an environment variable appears without a trailing '=', it will be
  852. Xremoved from the environment.
  853. X.PP
  854. X.Ss Comments
  855. XA word beginning with # and all the following characters up to a NEWLINE
  856. Xare ignored.
  857. X.Ss Recipes
  858. X.PP
  859. XA line starting with ':' marks the beginning of a recipe.  It has the
  860. Xfollowing format:
  861. X.PP
  862. X.Rs
  863. X: [\fInumber\fP] [\fIflags\fP] [ : [\fIlocallockfile\fP] ]
  864. X<zero or more conditions (one per line)>
  865. X<exactly one action line>
  866. X.Re
  867. X.PP
  868. XThe
  869. X.I number
  870. Xis optional (defaults to 1) and specifies the number of conditions that
  871. Xfollow the first line of the recipe.  Conditions are complete lines that are
  872. Xpassed on to the internal egrep
  873. X.BR literally ,
  874. Xexcept for leading blanks.
  875. XIf a condition starts with an '!', the condition is inverted.  If you really
  876. Xwant the condition to start with an '!', precede the '!' by a '\\'.
  877. XThese conditions are
  878. X.B completely
  879. Xcompatible to the normal
  880. X.BR egrep (1)
  881. Xregular expressions.
  882. X.PP
  883. XA special case condition is one starting with either '<' or '>', this
  884. Xcondition is true only if the total length of the mail is shorter,
  885. Xrespectively longer than the specified (in decimal) number of bytes.
  886. X.PP
  887. XAnother special case condition is one starting with a '$'.  This condition
  888. Xwill be evaluated according to
  889. X.BR sh (1)
  890. Xsubtitution rules inside double quotes, i.e. environment variable
  891. Xsubstitutions take place here, prior to being interpreted as a condition.
  892. X.PP
  893. XConditions are anded; if
  894. X.I number
  895. Xis zero, then the condition is always true and no conditions are expected
  896. Xnext.
  897. X.PP
  898. X.I Flags
  899. Xcan be any of the following:
  900. X.Tp 0.5i
  901. X.B +HEAD_GREP+
  902. XEgrep the header (default).
  903. X.Tp
  904. X.B +BODY_GREP+
  905. XEgrep the body.
  906. X.Tp
  907. X.B +DISTINGUISH_CASE+
  908. XTell the internal egrep to distinguish between upper and lower case (defaults
  909. Xto ignoring case).
  910. X.Tp
  911. X.B +ALSO_NEXT_RECIPE+
  912. XThis recipe will depend on the last preceding recipe without the
  913. X`+ALSO_NEXT_RECIPE+' or `+ALSO_N_IF_SUCC+' flag.  This allows you to chain
  914. Xactions that depend on a common condition.  The number of conditions that
  915. Xare expected to follow default to none.
  916. X.Tp
  917. X.B +ALSO_N_IF_SUCC+
  918. XHas the same meaning as the `+ALSO_NEXT_RECIPE+' flag, but will depend on the
  919. X.I successful
  920. Xcompletion of the immediately preceding recipe as well.
  921. X.Tp
  922. X.B +PASS_HEAD+
  923. XFeed the header to the pipe (default).
  924. X.Tp
  925. X.B +PASS_BODY+
  926. XFeed the body to the pipe (default).
  927. X.Tp
  928. X.B +FILTER+
  929. XConsider the pipe as a filter (ignored if a file).
  930. X.Tp
  931. X.B +CONTINUE+
  932. XContinue processing rcfile even if this recipe matches (not needed when 'f'
  933. Xspecified).
  934. X.Tp
  935. X.B +WAIT_EXIT+
  936. XWait for the filter or program to finish and check its exitcode (normally
  937. Xignored); if the filter is unsuccessful, then the text will
  938. Xnot have been filtered.  This flag is also recommended if you specified any
  939. X.I locallockfile
  940. Xon this recipe.
  941. X.Tp
  942. X.B +WAIT_EXIT_QUIET+
  943. XHas the same meaning as the `+WAIT_EXIT+' flag, but will suppress any
  944. X`Program failure' message.
  945. X.Tp
  946. X.B +IGNORE_WRITERR+
  947. XIgnore any write errors on this recipe (i.e. usually due to an early closed
  948. Xpipe).
  949. X.Ss "Local lockfile"
  950. X.PP
  951. XIf you put a second ':' on the first recipe line, then procmail will use a
  952. X.I locallockfile
  953. X(for this recipe only).  You can optionally specify the locallockfile
  954. Xto use; if you don't however, procmail will use the destination filename
  955. X(or the filename following the first '>>') and will append $LOCKEXT to it.
  956. X.Ss "Recipe action line"
  957. X.PP
  958. XThe action line can start with the following characters:
  959. X.Tp
  960. X.B !
  961. XForwards to all the specified mail addresses.
  962. X.Tp
  963. X.B |
  964. XStarts the specified program, possibly in $SHELL if any
  965. Xof the characters $SHELLMETAS are found.
  966. X.PP
  967. XAnything else will be taken as a mailbox name (either a filename or a
  968. Xdirectory, absolute or relative to the current directory (see MAILDIR)).
  969. XIf it is a filename (or nonexistent), the mail will be appended to it.
  970. X.PP
  971. XIf it is a directory, the mail will be delivered to a newly created, guaranteed
  972. Xto be unique file named $MSGPREFIX* in the specified directory.  If the
  973. Xdirectory name ends in "/.", then this directory is presumed to be an MH
  974. Xfolder; i.e. procmail will use the next number it finds available.
  975. X.Ss "Environment variable defaults"
  976. X.Tp 2.2i
  977. X.B "USER, HOME and SHELL"
  978. XYour (the recipient's) defaults
  979. X.Tp
  980. X.B SHELLMETAS
  981. X\&+DEFshellmetas+
  982. X.Tp
  983. X.B SHELLFLAGS
  984. X\&+DEFshellflags+
  985. X.Tp
  986. X.BR ORGMAIL
  987. X\&+SYSTEM_MBOX+
  988. X.Tp
  989. X.B MAILDIR
  990. X\&+DEFmaildir+
  991. X.Tp
  992. X.B DEFAULT
  993. X\&+DEFdefault+
  994. X.Tp
  995. X.B MSGPREFIX
  996. X\&+DEFmsgprefix+
  997. X.Tp
  998. X.B SENDMAIL
  999. X\&+DEFsendmail+
  1000. X.Tp
  1001. X.B LOCKEXT
  1002. X\&+DEFlockext+
  1003. X.Tp
  1004. X.B LOCKFILE
  1005. X\&+DEFdefaultlock+
  1006. X.br
  1007. X(after procmail closed the last rcfile)+PRESTENV++LD_ENV_FIX+
  1008. X.Ss Environment
  1009. X.PP
  1010. XBefore you get lost in the multitude of environment variables, keep in mind
  1011. Xthat all of them have reasonable defaults.
  1012. X.Tp 1.2i
  1013. X.B MAILDIR
  1014. XCurrent directory while procmail is executing (that means that all paths
  1015. Xare relative to $MAILDIR).
  1016. X.Tp
  1017. X.B DEFAULT
  1018. XDefault
  1019. X.B mailbox
  1020. Xfile (if not told otherwise, procmail will dump mail in this mailbox).
  1021. XProcmail will automatically use LOCKFILE=$DEFAULT$LOCKEXT prior to writing
  1022. Xto this mailbox.
  1023. X.Tp
  1024. X.B MSGPREFIX
  1025. XFilename prefix that is used when delivering to a directory (not used when
  1026. Xdelivering to an MH directory).
  1027. X.Tp
  1028. X.B LOGFILE
  1029. XAll incoming messages will be logged here with their `+FROM+' and `Subject:'
  1030. Xlines in the header, and an additional line specifying what folder it
  1031. Xfinally went to and how long (in bytes) the message was.  This file will
  1032. Xalso contain any error or diagnostic messages from procmail
  1033. X(normally none :-) or any other programs started by procmail.  If this file
  1034. Xis not specified it defaults to
  1035. X.BR +console+ .
  1036. XYou can turn on
  1037. X.I extended diagnostics
  1038. Xby prepending a `+DEBUGPREFIX+' to the desired pathname.
  1039. X.Tp
  1040. X.B LOG
  1041. XAnything assigned to this variable will be echoed in $LOGFILE.
  1042. X.Tp
  1043. X.B ORGMAIL
  1044. XUsually the system mailbox (\fBOR\fPi\fBG\fPinal \fBMAIL\fPbox).  If, for
  1045. Xsome obscure reason (like `\fBfilesystem full\fP') the mail could not be
  1046. Xdelivered, then this mailbox will be the last resort.  If procmail
  1047. Xfails to save the mail in here (deep, deep trouble :-), then the mail
  1048. Xwill bounce back to the sender.
  1049. X.Tp
  1050. X.B LOCKFILE
  1051. XGlobal semaphore file.  If this file already exists, procmail
  1052. Xwill wait until it has gone before proceeding, and will create it itself
  1053. X(cleaning it up when ready, of course).  If more than one
  1054. X.I lockfile
  1055. Xare specified, then the previous one will be removed before trying to create
  1056. Xthe new one.  The use of a global lockfile is discouraged, use locallockfiles
  1057. X(on a per recipe basis) instead.
  1058. X.Tp
  1059. X.B LOCKEXT
  1060. XDefault extension that is appended to a destination file to determine
  1061. Xwhat local
  1062. X.I lockfile
  1063. Xto use (only if turned on, on a per-recipe basis).
  1064. X.Tp
  1065. X.B LOCKSLEEP
  1066. XNumber of seconds procmail will sleep before retrying on a
  1067. X.I lockfile
  1068. X(if it already existed); if not specified, it defaults to +DEFlocksleep+
  1069. Xseconds.
  1070. X.Tp
  1071. X.B LOCKTIMEOUT
  1072. XNumber of seconds that have to have passed since a
  1073. X.I lockfile
  1074. Xwas last modified/created before procmail decides that this must be an
  1075. Xerroneously leftover lockfile that can be removed by force now.  If zero,
  1076. Xthen no timeout will be used and procmail will wait forever until the
  1077. Xlockfile is removed; if not specified, it defaults to +DEFlocktimeout+ seconds.
  1078. XThis variable is useful to prevent indefinite hangups of
  1079. X.BR sendmail /procmail.
  1080. XProcmail is immune to clock skews.
  1081. X.Tp
  1082. X.B TIMEOUT
  1083. XNumber of seconds that have to have passed before procmail decides that
  1084. Xsome child it started must be hanging.  The offending program will receive
  1085. Xa TERMINATE signal from procmail, and processing of the rcfile will continue.
  1086. XIf zero, then no timeout will be used and procmail will wait forever until the
  1087. Xchild has terminated; if not specified, it defaults to +DEFtimeout+ seconds.
  1088. X.Tp
  1089. X.B HOST
  1090. XIf this is not the
  1091. X.I hostname
  1092. Xof the machine, processing of the current
  1093. X.I rcfile
  1094. Xwill immediately cease. If other rcfiles were specified on the
  1095. Xcommand line, processing will continue with the next one.  If all rcfiles
  1096. Xare exhausted, the program will terminate, but will not generate an error
  1097. X(i.e. to the mailer it will seem that the mail has been delivered).  Only the
  1098. Xfirst +HOSTNAMElen+ characters of the HOST are significant.
  1099. X.Tp
  1100. X.B UMASK
  1101. XThe name says it all (if it doesn't, then forget about this one :-).  It
  1102. Xis taken as an
  1103. X.B octal
  1104. Xnumber.  If not specified, it defaults to +INIT_UMASK+.
  1105. X.Tp
  1106. X.B SHELLMETAS
  1107. XIf any of the characters in SHELLMETAS appears in the line specifying
  1108. Xa filter or program, the line will be fed to $SHELL
  1109. Xinstead of being executed directly.
  1110. X.Tp
  1111. X.B SHELLFLAGS
  1112. XAny invocation of $SHELL will be like:
  1113. X.br
  1114. X"$SHELL" "$SHELLFLAGS" "$*";
  1115. X.Tp
  1116. X.B SENDMAIL
  1117. XIf you're not using the
  1118. X.I forwarding
  1119. Xfacility don't worry about this one.  It specifies the program being
  1120. Xcalled to forward any mail.
  1121. X.br
  1122. XIt gets invoked as: "$SENDMAIL" "$@";
  1123. X.Tp
  1124. X.B NORESRETRY
  1125. XNumber of retries that are to be made if any `\fBprocess table full\fP',
  1126. X`\fBfile table full\fP', `\fBout of memory\fP' or
  1127. X`\fBout of swap space\fP' error should occur.  If this number is negative,
  1128. Xthen procmail will retry indefinitely; if not specified, it defaults to two
  1129. Xtimes.  The retries occur with a $SUSPEND second interval.  The idea behind
  1130. Xthis is, that if the
  1131. X.I swap
  1132. X.I space
  1133. Xhas been exhausted or the
  1134. X.I process
  1135. X.I table
  1136. Xis full, usually several other programs will either detect this
  1137. Xand abort or crash 8-), and thereby freeing valuable
  1138. X.I resources
  1139. Xfor procmail.
  1140. X.Tp
  1141. X.B SUSPEND
  1142. XNumber of seconds that procmail will pause if it has to wait for something
  1143. Xthat is currently unavailable (memory, fork, etc.); if not specified, it will
  1144. Xdefault to +DEFsuspend+ seconds.  See also:
  1145. X.BR LOCKSLEEP .
  1146. X.Tp
  1147. X.B LINEBUF
  1148. XLength of the internal line buffers, cannot be set smaller than +MINlinebuf+.
  1149. XAll lines read from the rcfile
  1150. X.RI ( not
  1151. Xthe mail itself, which can have arbitrary line lengths, or could be a binary
  1152. Xfile for that matter) should not exceed $LINEBUF characters before and after
  1153. Xexpansion.  If not specified, it defaults to +DEFlinebuf+.
  1154. X.Tp
  1155. X.B DELIVERED
  1156. XIf set (to a dummy value) procmail will pretend (to the mail agent) the mail
  1157. Xhas been delivered.  If mail cannot be delivered after meeting this
  1158. Xassignment, the mail will be lost (i.e. it will not bounce).
  1159. X.Sh EXAMPLES
  1160. XLook in the
  1161. X.BR procmailex (5)
  1162. Xman page.
  1163. X.Sh CAVEATS
  1164. XIf you don't explicitly tell procmail to wait (recipe flag `+WAIT_EXIT+' or
  1165. X`+WAIT_EXIT_QUIET+') for a program to finish, it won't wait and will terminate
  1166. Xearly (not knowing if the program returns success).  That also means that any
  1167. Xlocallockfile on this recipe might get removed
  1168. X.I before
  1169. Xthe program has terminated.
  1170. X.PP
  1171. XContinued lines in a recipe that are to be executed are concatenated
  1172. X.I before
  1173. Xbeing parsed, hence
  1174. X.I any
  1175. Xbackslash-newline combinations in them are removed regardless.
  1176. X.PP
  1177. XDon't put comments on the condition lines (the regular expressions) in a recipe,
  1178. Xthese lines are fed to the internal egrep
  1179. X.IR literally .
  1180. X(Except for any
  1181. X.I leading
  1182. Xwhitespace, `!' or `\\', it will be stripped.
  1183. XPrecede it by a `\\' if you want it to be taken literally too.)
  1184. X.PP
  1185. XOn a related note, watch out for trailing whitespace on condition lines, you
  1186. Xdon't see it, but procmail will try to match it; enabling extended diagnostics
  1187. X(see LOGFILE) will reveal this.
  1188. X.PP
  1189. XWatch out for deadlocks when doing unhealthy things like forwarding mail
  1190. Xto your own account.  Deadlocks can be broken by proper use of
  1191. X.BR LOCKTIMEOUT .
  1192. X.PP
  1193. XAny default values that procmail has for some environment variables will
  1194. X.B always
  1195. Xoverride the ones that were already defined.  If you really want to
  1196. Xoverride the defaults, you either have to put them in the
  1197. X.B rcfile
  1198. Xor on the command line as arguments.
  1199. X.Sh "SEE ALSO"
  1200. X.na
  1201. X.BR procmail (1),
  1202. X.BR procmailex (5),
  1203. X.BR sh (1),
  1204. X.BR csh (1),
  1205. X.BR mail (1),
  1206. X.BR binmail (1),
  1207. X.BR uucp (1C),
  1208. X.BR aliases (5),
  1209. X.BR sendmail (8),
  1210. X.BR egrep (1V),
  1211. X.BR lockfile (1),
  1212. X.BR formail (1)
  1213. X.ad
  1214. X.Sh BUGS
  1215. XThe only substitutions of environment variables that can be handled by
  1216. Xprocmail itself are of the type $name, ${name}, $$ and $\-; whereas $\- will
  1217. Xbe substituted by the name of the last folder delivered to.+UPPERCASE_USERNAMES+
  1218. X.PP
  1219. XA line buffer of length $LINEBUF is used when processing the
  1220. X.IR rcfile ,
  1221. Xany expansions
  1222. X.B have
  1223. Xto fit within this limit; if they don't, behaviour is undefined.
  1224. X.PP
  1225. XIf the global lockfile has a
  1226. X.I relative
  1227. Xpath, and the current directory
  1228. Xis not the same as when the global lockfile was created, then the global
  1229. Xlockfile will not be removed if procmail exits at that point (remedy:
  1230. Xuse
  1231. X.I absolute
  1232. Xpaths to specify global lockfiles).
  1233. X.Sh MISCELLANEOUS
  1234. XWhitespace is ignored in the rcfile, except on the
  1235. Xlines that are fed to the internal egrep where only leading whitespace is
  1236. Xignored; i.e. you can indent everything.
  1237. X.PP
  1238. XIf the regular expression starts with `\fB+TOkey+\fP' it will be substituted by
  1239. X`\fB+TOsubstitute+\fP', which should catch all destination
  1240. Xspecifications.
  1241. X.Sh NOTES
  1242. XFor
  1243. X.I really
  1244. Xcomplicated processing you can even consider calling
  1245. X.B procmail
  1246. Xrecursively.
  1247. X.Sh AUTHOR
  1248. XStephen R. van den Berg at RWTH-Aachen, Germany
  1249. X.Rs
  1250. Xberg@pool.informatik.rwth-aachen.de
  1251. Xberg@physik.tu-muenchen.de
  1252. X.Re
  1253. END_OF_FILE
  1254. if test 15197 -ne `wc -c <'procmail/man/procmailrc.man'`; then
  1255.     echo shar: \"'procmail/man/procmailrc.man'\" unpacked with wrong size!
  1256. fi
  1257. # end of 'procmail/man/procmailrc.man'
  1258. fi
  1259. if test -f 'procmail/retint.c' -a "${1}" != "-c" ; then 
  1260.   echo shar: Will not clobber existing file \"'procmail/retint.c'\"
  1261. else
  1262. echo shar: Extracting \"'procmail/retint.c'\" \(13188 characters\)
  1263. sed "s/^X//" >'procmail/retint.c' <<'END_OF_FILE'
  1264. X/************************************************************************
  1265. X *    Collection of routines that return an int (sort of anyway :-)    *
  1266. X *                                    *
  1267. X *    Copyright (c) 1990-1992, S.R. van den Berg, The Netherlands    *
  1268. X *    The sources can be freely copied for non-commercial use.    *
  1269. X *    #include "README"                        *
  1270. X *                                    *
  1271. X ************************************************************************/
  1272. X#ifdef RCS
  1273. Xstatic char rcsid[]="$Id: retint.c,v 2.27 1992/06/30 16:42:26 berg Rel $";
  1274. X#endif
  1275. X#include "config.h"
  1276. X#include "procmail.h"
  1277. X#include "shell.h"
  1278. X
  1279. Xsetdef(name,contents)const char*const name,*const contents;
  1280. X{ strcat(strcat(strcpy((char*)(sgetcp=buf2),name),"="),contents);
  1281. X  readparse(buf,sgetc,2);sputenv(buf);
  1282. X}
  1283. X
  1284. Xchar*lastexec,*backblock;
  1285. Xlong backlen;               /* length of backblock, filter recovery block */
  1286. Xpid_t pidfilt;
  1287. Xint pbackfd[2];                       /* the emergency backpipe :-) */
  1288. X
  1289. Xpipthrough(line,source,len)char*line,*source;const long len;
  1290. X{ int pinfd[2],poutfd[2];
  1291. X  rpipe(pbackfd);rpipe(pinfd);                 /* main pipes setup */
  1292. X  if(!(pidchild=sfork()))            /* create a sending procmail */
  1293. X   { backblock=source;backlen=len;signal(SIGTERM,stermchild);
  1294. X     signal(SIGINT,stermchild);signal(SIGHUP,stermchild);
  1295. X     signal(SIGQUIT,stermchild);rclose(rc);rclose(PRDI);rclose(PRDB);
  1296. X     rpipe(poutfd);rclose(STDOUT);
  1297. X     if(!(pidfilt=sfork()))                /* create the filter */
  1298. X      { rclose(PWRO);rclose(PWRB);rdup(PWRI);rclose(PWRI);getstdin(PRDO);
  1299. X    callnewprog(line);
  1300. X      }
  1301. X     rclose(PWRI);rclose(PRDO);
  1302. X     if(forkerr(pidfilt,line))
  1303. X    rclose(PWRO),stermchild();
  1304. X     if(dump(PWRO,source,len))          /* send in the text to be filtered */
  1305. X    writeerr(line),stermchild();
  1306. X     if(pwait&&waitfor(pidfilt)!=EX_OK)     /* check the exitcode of the filter */
  1307. X      { if(!(pwait&2))                  /* do we put it on report? */
  1308. X       progerr(line);
  1309. X    stermchild();
  1310. X      }
  1311. X     rclose(PWRB);exit(EX_OK);              /* allow parent to proceed */
  1312. X   }
  1313. X  rclose(PWRI);rclose(PWRB);getstdin(PRDI);
  1314. X  if(forkerr(pidchild,procmailn))
  1315. X     return 1;
  1316. X  return 0;            /* we stay behind to read back the filtered text */
  1317. X}
  1318. X
  1319. Xwaitfor(pid)const pid_t pid;              /* wait for a specific process */
  1320. X{ int i;pid_t j;
  1321. X  while(pid!=(j=wait(&i))||WIFSTOPPED(i))
  1322. X     if(-1==j)
  1323. X    return -1;
  1324. X  return WIFEXITED(i)?WEXITSTATUS(i):-1;
  1325. X}
  1326. X
  1327. Xgetstdin(pip)const int pip;
  1328. X{ rclose(STDIN);rdup(pip);rclose(pip);
  1329. X}
  1330. X
  1331. Xcallnewprog(newname)const char*const newname;
  1332. X{ if(sh)                     /* should we start a shell? */
  1333. X   { const char*newargv[4];
  1334. X     yell(executing,newname);newargv[3]=0;newargv[2]=newname;
  1335. X     newargv[1]=tgetenv(shellflags);*newargv=tgetenv(shell);shexec(newargv);
  1336. X   }
  1337. X {register const char*p;int argc;const char**newargv;
  1338. X  argc=1;p=newname;         /* If no shell, chop up the arguments ourselves */
  1339. X  if(verbose)
  1340. X   { log(executing);log(oquote);goto no_1st_comma;
  1341. X   }
  1342. X  do                         /* show chopped up command line */
  1343. X   { if(verbose)
  1344. X      { log(",");
  1345. Xno_1st_comma:
  1346. X    log(p);
  1347. X      }
  1348. X     while(*p++);
  1349. X   }
  1350. X  while(argc++,*p!=TMNATE);
  1351. X  if(verbose)
  1352. X     log(cquote);
  1353. X  newargv=malloc(argc*sizeof*newargv);p=newname;argc=0;     /* alloc argv array */
  1354. X  do
  1355. X   { newargv[argc++]=p;
  1356. X     while(*p++);
  1357. X   }
  1358. X  while(*p!=TMNATE);
  1359. X  newargv[argc]=0;shexec(newargv);
  1360. X }
  1361. X}
  1362. X
  1363. Xwriteerr(line)const char*const line;
  1364. X{ log("Error while writing to");logqnl(line);
  1365. X}
  1366. X
  1367. Xforkerr(pid,a)const pid_t pid;const char*const a;
  1368. X{ if(pid==-1)
  1369. X   { log("Failed forking");logqnl(a);return 1;
  1370. X   }
  1371. X  return 0;
  1372. X}
  1373. X
  1374. Xprogerr(line)const char*const line;
  1375. X{ log("Program failure of");logqnl(line);
  1376. X}
  1377. X
  1378. Xopena(a)const char*const a;
  1379. X{ lastfolder=cstr(lastfolder,a);yell("Opening",a);
  1380. X#ifdef O_CREAT
  1381. X  return ropen(a,O_WRONLY|O_APPEND|O_CREAT,NORMperm);
  1382. X#else
  1383. X {int fd;
  1384. X  return(fd=ropen(a,O_WRONLY,0))<0?creat(a,NORMperm):fd;
  1385. X }
  1386. X#endif
  1387. X}
  1388. X
  1389. Xyell(a,b)const char*const a,*const b;             /* log if -d option set */
  1390. X{ if(verbose)
  1391. X     log(a),logqnl(b);
  1392. X}
  1393. X
  1394. Xunlock(lockp)char**const lockp;
  1395. X{ lcking|=lck_LOCKFILE;
  1396. X  if(*lockp)
  1397. X   { yell("Unlocking",*lockp);
  1398. X     if(unlink(*lockp))
  1399. X    log("Couldn't unlock"),logqnl(*lockp);
  1400. X     if(!nextexit)               /* if not inside a signal handler */
  1401. X    free(*lockp);
  1402. X     *lockp=0;
  1403. X   }
  1404. X  lcking&=~lck_LOCKFILE;
  1405. X  if(nextexit==1)        /* make sure we are not inside terminate already */
  1406. X     log(newline),terminate();
  1407. X}
  1408. X
  1409. Xnomemerr()          /* set nextexit to prevent log from using malloc() */
  1410. X{ nextexit=2;log("Out of memory\n");
  1411. X  if(buf2)
  1412. X   { buf[linebuf-1]=buf2[linebuf-1]='\0';log("buffer 0:");logqnl(buf);
  1413. X     log("buffer 1:");logqnl(buf2);
  1414. X   }
  1415. X  if(retval!=EX_TEMPFAIL)
  1416. X     retval=EX_OSERR;
  1417. X  terminate();
  1418. X}
  1419. X
  1420. Xlogqnl(a)const char*const a;
  1421. X{ log(oquote);log(a);log(cquote);
  1422. X}
  1423. X
  1424. Xnextrcfile()            /* next rcfile specified on the command line */
  1425. X{ const char*p;
  1426. X  while(p= *gargv)
  1427. X   { gargv++;
  1428. X     if(!strchr(p,'='))
  1429. X      { rcfile=p;return 1;
  1430. X      }
  1431. X   }
  1432. X  return 0;
  1433. X}
  1434. X
  1435. Xrclose(fd)const int fd;              /* a SysV secure close (signal immune) */
  1436. X{ int i;
  1437. X  while((i=close(fd))&&errno==EINTR);
  1438. X  return i;
  1439. X}
  1440. X
  1441. Xrwrite(fd,a,len)const int fd,len;void*const a;          /* a SysV secure write */
  1442. X{ int i;
  1443. X  while(0>(i=write(fd,a,(size_t)len))&&errno==EINTR);
  1444. X  return i;
  1445. X}
  1446. X
  1447. Xrread(fd,a,len)const int fd,len;void*const a;           /* a SysV secure read */
  1448. X{ int i;
  1449. X  while(0>(i=read(fd,a,(size_t)len))&&errno==EINTR);
  1450. X  return i;
  1451. X}
  1452. X
  1453. Xropen(name,mode,mask)const char*const name;const int mode;const mode_t mask;
  1454. X{ int i,r;                           /* a SysV secure open */
  1455. X  for(r=noresretry,lcking|=lck_FILDES;0>(i=open(name,mode,mask));)
  1456. X     if(errno!=EINTR&&!((errno==EMFILE||errno==ENFILE)&&(r<0||r--)))
  1457. X    break;         /* survives a temporary "file table full" condition */
  1458. X  lcking&=~lck_FILDES;return i;
  1459. X}
  1460. X
  1461. Xrdup(p)const int p;
  1462. X{ int i,r;                      /* catch "file table full" */
  1463. X  for(r=noresretry,lcking|=lck_FILDES;0>(i=dup(p));)
  1464. X     if(!((errno==EMFILE||errno==ENFILE)&&(r<0||r--)))
  1465. X    break;
  1466. X  lcking&=~lck_FILDES;return i;
  1467. X}
  1468. X
  1469. Xrpipe(fd)int fd[2];
  1470. X{ int i,r;                      /* catch "file table full" */
  1471. X  for(r=noresretry,lcking|=lck_FILDES;0>(i=pipe(fd));)
  1472. X     if(!((errno==EMFILE||errno==ENFILE)&&(r<0||r--)))
  1473. X      { *fd=fd[1]= -1;break;
  1474. X      }
  1475. X  lcking&=~lck_FILDES;return i;
  1476. X}
  1477. X
  1478. Xlockit(name,lockp)char*name;const char**const lockp;
  1479. X{ int i,permanent=2,triedforce=0;struct stat stbuf;time_t t;
  1480. X  if(*lockp)
  1481. X   { if(!strcmp(name,*lockp))    /* compare the previous lockfile to this one */
  1482. X    return;             /* they're equal, save yourself some effort */
  1483. X     unlock(lockp);               /* unlock any previous lockfile FIRST */
  1484. X   }                  /* to prevent deadlocks (I hate deadlocks) */
  1485. X  if(!*name)
  1486. X     return;
  1487. X  name=tstrdup(name); /* allocate now, so we won't hang on memory *and* lock */
  1488. X  for(lcking|=lck_LOCKFILE;;)
  1489. X   { yell("Locking",name);        /* in order to cater for clock skew: */
  1490. X     if(!NFSxopen(name,LOCKperm,&t))           /* get time t from filesystem */
  1491. X      { *lockp=name;break;               /* lock acquired, hurray! */
  1492. X      }
  1493. X     switch(errno)
  1494. X      { case EEXIST:           /* check if it's time for a lock override */
  1495. X       if(!lstat(name,&stbuf)&&stbuf.st_size<=MAX_LOCK_SIZE&&locktimeout
  1496. X        &&!lstat(name,&stbuf)&&locktimeout<t-stbuf.st_mtime)
  1497. X         /*
  1498. X          * stat() till unlink() should be atomic, but can't guarantee that
  1499. X          */
  1500. X        { if(triedforce)            /* already tried, not trying */
  1501. X         goto faillock;                        /* again */
  1502. X          if(S_ISDIR(stbuf.st_mode)||unlink(name))
  1503. X         triedforce=1,log("Forced unlock denied on"),logqnl(name);
  1504. X          else
  1505. X           { log("Forcing lock on");logqnl(name);suspend();goto ce;
  1506. X           }
  1507. X        }
  1508. X       else
  1509. X          triedforce=0;         /* legitimate iteration, clear flag */
  1510. X       break;
  1511. X#ifdef ENAMETOOLONG
  1512. X    case ENAMETOOLONG:     /* maybe filename too long, shorten and retry */
  1513. X       if(0<(i=strlen(name)-1)&&!strchr(dirsep,name[i-1]))
  1514. X        { log("Truncating");logqnl(name);log(" and retrying lock\n");
  1515. X          name[i]='\0';continue;
  1516. X        }
  1517. X#endif
  1518. X    default:
  1519. Xfaillock:  log("Lock failure on");logqnl(name);goto term;
  1520. X    case ENOENT:case ENOTDIR:case EIO:case EACCES:
  1521. X       if(!--permanent)
  1522. X          goto faillock;
  1523. X    case ENOSPC:;
  1524. X#ifdef EDQUOT
  1525. X    case EDQUOT:;
  1526. X#endif
  1527. X      }
  1528. X     sleep((unsigned)locksleep);
  1529. Xce:  if(nextexit)
  1530. Xterm: { free(name);break;             /* drop the preallocated buffer */
  1531. X      }
  1532. X   }
  1533. X  lcking&=~lck_LOCKFILE;
  1534. X  if(nextexit)
  1535. X   { log(whilstwfor);log("lockfile");logqnl(name);terminate();
  1536. X   }
  1537. X}
  1538. X
  1539. Xlcllock()                   /* lock a local file (if need be) */
  1540. X{ if(locknext)
  1541. X     if(tolock)
  1542. X    lockit(tolock,&loclock);
  1543. X     else
  1544. X    lockit(strcat(buf2,tgetenv(lockext)),&loclock);
  1545. X}
  1546. X
  1547. Xsterminate()
  1548. X{ static const char*const msg[]={"memory","fork",      /* crosscheck with */
  1549. X   "a file descriptor","a kernel lock"};      /* lck_ defs in procmail.h */
  1550. X  ignoreterm();
  1551. X  if(pidchild>0)        /* don't kill what is not ours, we might be root */
  1552. X     kill(pidchild,SIGTERM);
  1553. X  if(!nextexit)
  1554. X   { nextexit=1;log("Terminating prematurely");
  1555. X     if(!(lcking&lck_LOCKFILE))
  1556. X      { register unsigned i,j;
  1557. X    if(i=(lcking&~(lck_ALLOCLIB|lck_LOCKFILE))>>1)
  1558. X     { log(whilstwfor);
  1559. X       for(j=0;(i>>=1)&1;++j);
  1560. X       log(msg[j]);
  1561. X     }
  1562. X    log(newline);terminate();
  1563. X      }
  1564. X   }
  1565. X}
  1566. X
  1567. Xterminate()
  1568. X{ ignoreterm();
  1569. X  if(retvl2!=EX_OK)
  1570. X     fakedelivery=0,retval=retvl2;
  1571. X  if(getpid()==thepid)
  1572. X   { if(retval!=EX_OK)
  1573. X      { lastfolder=fakedelivery?"**Lost**":        /* don't free() here */
  1574. X     retval==EX_TEMPFAIL?"**Requeued**":"**Bounced**";
  1575. X      }
  1576. X     logabstract();nextexit=2;unlock(&loclock);unlock(&globlock);fdunlock();
  1577. X   }
  1578. X  exit(fakedelivery==2?EX_OK:retval);
  1579. X}
  1580. X
  1581. Xignoreterm()
  1582. X{ signal(SIGTERM,SIG_IGN);signal(SIGHUP,SIG_IGN);signal(SIGINT,SIG_IGN);
  1583. X  signal(SIGQUIT,SIG_IGN);
  1584. X}
  1585. X
  1586. Xsuspend()
  1587. X{ long t;
  1588. X  sleep((unsigned)suspendv);
  1589. X  if(alrmtime)
  1590. X     if((t=alrmtime-time((time_t*)0))<=1)      /* if less than 1s timeout */
  1591. X    ftimeout();                  /* activate it by hand now */
  1592. X     else            /* set it manually again, to avoid problems with */
  1593. X    alarm((unsigned)t);    /* badly implemented sleep library functions */
  1594. X}
  1595. X
  1596. Xinittmout(progname)const char*const progname;
  1597. X{ lastexec=cstr(lastexec,progname);
  1598. X  alrmtime=timeoutv?time((time_t*)0)+(unsigned)timeoutv:0;
  1599. X  alarm((unsigned)timeoutv);
  1600. X}
  1601. X
  1602. Xskipspace()
  1603. X{ while(testb(' ')||testb('\t'));
  1604. X}
  1605. X
  1606. Xsgetc()                        /* a fake fgetc for a string */
  1607. X{ return *sgetcp?*(uchar*)sgetcp++:EOF;
  1608. X}
  1609. X
  1610. Xskipped(x)const char*const x;
  1611. X{ log("Skipped");logqnl(x);
  1612. X}
  1613. X
  1614. Xconcatenate(old)char*const old;
  1615. X{ register char*p=old;
  1616. X  while(*p!=TMNATE)              /* concatenate all other arguments */
  1617. X   { while(*p++);
  1618. X     p[-1]=' ';
  1619. X   }
  1620. X  *p=p[-1]='\0';return*old;
  1621. X}
  1622. X
  1623. Xdetab(p)char*p;
  1624. X{ while(p=strchr(p,'\t'))
  1625. X     *p=' ';                        /* take out all tabs */
  1626. X}
  1627. X
  1628. Xstatic uchar rcbuf[STDBUF],*rcbufp,*rcbufend;     /* buffers for custom stdio */
  1629. Xstatic ungetb;                         /* pushed back char */
  1630. X
  1631. Xbopen(name)const char*const name;                 /* my fopen */
  1632. X{ rcbufp=rcbufend=0;ungetb= -1;yell("Rcfile:",name);
  1633. X  return rc=ropen(name,O_RDONLY,0);
  1634. X}
  1635. X
  1636. Xgetbl(p)char*p;                              /* my gets */
  1637. X{ int i;char*q;
  1638. X  for(q=p;;)
  1639. X   { switch(i=getb())
  1640. X      { case '\n':case EOF:
  1641. X       *p='\0';return p!=q;             /* did we read anything at all? */
  1642. X      }
  1643. X     *p++=i;
  1644. X   }
  1645. X}
  1646. X
  1647. Xgetb()                                 /* my fgetc */
  1648. X{ if(ungetb>=0)                        /* anything pushed back? */
  1649. X   { int i;
  1650. X     i=ungetb;ungetb= -1;return i;
  1651. X   }
  1652. X  if(rcbufp==rcbufend)
  1653. X     rcbufend=rcbuf+rread(rc,rcbufp=rcbuf,STDBUF);           /* refill */
  1654. X  return rcbufp<rcbufend?*rcbufp++:EOF;
  1655. X}
  1656. X
  1657. Xtestb(x)const int x;           /* fgetc that only succeeds if it matches */
  1658. X{ int i;
  1659. X  if((i=getb())==x)
  1660. X     return 1;
  1661. X  ungetb=i;return 0;
  1662. X}
  1663. X
  1664. Xalphanum(c)const int c;
  1665. X{ return c>='0'&&c<='9'||c>='a'&&c<='z'||c>='A'&&c<='Z'||c=='_';
  1666. X}
  1667. X                       /* open file or new file in directory */
  1668. Xdeliver(boxname)char*const boxname;
  1669. X{ struct stat stbuf;
  1670. X  strcpy(buf,boxname);             /* boxname can be found back in buf */
  1671. X  return stat(buf,&stbuf)||!S_ISDIR(stbuf.st_mode)?
  1672. X   (tofolder=1,opena(buf)):dirmail();
  1673. X}
  1674. X
  1675. X#ifdef KERNEL_LOCKS
  1676. Xstatic oldfdlock;                    /* the fd we locked last */
  1677. X#ifdef F_SETLKW
  1678. Xstatic struct flock flck;        /* why can't it be a local variable? */
  1679. X
  1680. Xfdlock(fd)                       /* the POSIX-fcntl() lock */
  1681. X{ flck.l_type=F_WRLCK;flck.l_whence=SEEK_SET;flck.l_len=0;
  1682. X  flck.l_start=tell(fd);lcking|=lck_KERNELL;
  1683. X  fd=fcntl(oldfdlock=fd,F_SETLKW,&flck);lcking&=~lck_KERNELL;return fd;
  1684. X}
  1685. X
  1686. Xfdunlock()
  1687. X{ flck.l_type=F_UNLCK;return fcntl(oldfdlock,F_SETLK,&flck);
  1688. X}
  1689. X#else /* F_SETLKW */
  1690. X#ifdef F_LOCK
  1691. Xstatic long oldlockoffset;
  1692. X
  1693. Xfdlock(fd)                         /* the SysV-lockf() */
  1694. X{ oldlockoffset=tell(fd);lcking|=lck_KERNELL;fd=lockf(oldfdlock=fd,F_LOCK,0L);
  1695. X  lcking&=~lck_KERNELL;return fd;
  1696. X}
  1697. X
  1698. Xfdunlock()
  1699. X{ lseek(oldfdlock,oldlockoffset,SEEK_SET);return lockf(oldfdlock,F_ULOCK,0L);
  1700. X}
  1701. X#else /* F_LOCK */
  1702. X#ifdef LOCK_EX
  1703. Xfdlock(fd)                          /* the BSD-flock() */
  1704. X{ lcking|=lck_KERNELL;fd=flock(oldfdlock=fd,LOCK_EX);lcking&=~lck_KERNELL;
  1705. X  return fd;
  1706. X}
  1707. X
  1708. Xfdunlock()
  1709. X{ return flock(oldfdlock,LOCK_UN);
  1710. X}
  1711. X#endif /* LOCK_EX */
  1712. X#endif /* F_LOCK */
  1713. X#endif /* F_SETLKW */
  1714. X#endif /* KERNEL_LOCKS */
  1715. X                    /* an NFS secure exclusive file open */
  1716. XNFSxopen(name,mode,tim)char*name;const mode_t mode;time_t*const tim;
  1717. X{ char*p;int j= -2,i;struct stat stbuf;
  1718. X  i=lastdirsep(name)-name;strncpy(p=malloc(i+UNIQnamelen),name,i);
  1719. X  if(unique(p,p+i,mode))           /* try and rename the unique filename */
  1720. X   { stat(p,&stbuf);
  1721. X     if(tim)
  1722. X    *tim=stbuf.st_mtime;     /* return the filesystem time to the caller */
  1723. X     j=myrename(p,name);
  1724. X   }
  1725. X  free(p);return j;
  1726. X}
  1727. END_OF_FILE
  1728. if test 13188 -ne `wc -c <'procmail/retint.c'`; then
  1729.     echo shar: \"'procmail/retint.c'\" unpacked with wrong size!
  1730. fi
  1731. # end of 'procmail/retint.c'
  1732. fi
  1733. echo shar: End of archive 4 \(of 5\).
  1734. cp /dev/null ark4isdone
  1735. MISSING=""
  1736. for I in 1 2 3 4 5 ; do
  1737.     if test ! -f ark${I}isdone ; then
  1738.     MISSING="${MISSING} ${I}"
  1739.     fi
  1740. done
  1741. if test "${MISSING}" = "" ; then
  1742.     echo You have unpacked all 5 archives.
  1743.     rm -f ark[1-9]isdone
  1744. else
  1745.     echo You still need to unpack the following archives:
  1746.     echo "        " ${MISSING}
  1747. fi
  1748. ##  End of shell archive.
  1749. exit 0
  1750. -- 
  1751. Sincerely,                                  berg@pool.informatik.rwth-aachen.de
  1752.            Stephen R. van den Berg (AKA BuGless).    berg@physik.tu-muenchen.de
  1753.  
  1754. He did a quarter of the work in *half* the time!
  1755.  
  1756. exit 0 # Just in case...
  1757.