home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1994 October / usenetsourcesnewsgroupsinfomagicoctober1994disk2.iso / misc / volume29 / procmail / part01 next >
Text File  |  1992-05-13  |  50KB  |  1,347 lines

  1. Newsgroups: comp.sources.misc
  2. From: berg@pool.informatik.rwth-aachen.de (Stephen R. van den Berg)
  3. Subject:  v29i090:  procmail - mail processing program v2.70, Part01/05
  4. Message-ID: <csm-v29i090=procmail.101301@sparky.IMD.Sterling.COM>
  5. X-Md4-Signature: 8396d7abbb6283263df334082ede2af1
  6. Date: Mon, 11 May 1992 15:13:47 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 29, Issue 90
  11. Archive-name: procmail/part01
  12. Environment: UNIX, sendmail, smail, MMDF
  13. Supersedes: procmail: Volume 28, Issue 01-05
  14.  
  15. The procmail mail processing program. (v2.70 1992/04/30)
  16.  
  17. Can be used to create mail-servers, mailing lists, sort your incoming mail
  18. into separate folders/files (real convenient when subscribing to one or more
  19. mailing lists or for prioritising your mail), preprocess your mail, start
  20. any programs upon mail arrival (e.g. to generate different chimes on your
  21. workstation for different types of mail) or selectively forward certain
  22. incoming mail automatically to someone.
  23.  
  24. The accompanying formail program enables you to generate autoreplies, split up
  25. digests/mailboxes into the original messages, do some very simple
  26. header-munging/extraction, or force mail into mail-format (with leading From
  27. line).
  28.  
  29. Sincerely,                                  berg@pool.informatik.rwth-aachen.de
  30.            Stephen R. van den Berg (AKA BuGless).    berg@physik.tu-muenchen.de
  31.  ----------------------
  32. A recent version can be picked up at various comp.sources.misc archives.
  33. The latest version can be obtained directly from the ftp-archive at:
  34.  
  35.     ftp.informatik.rwth-aachen.de (137.226.112.31)
  36.  
  37.     as compressed tar file:        pub/unix/procmail.tar.Z        <128KB
  38.     or in compressed shar format:    pub/unix/procmail.0?.Z
  39.  ----------------------
  40. Feature summary for procmail:
  41.     + It's small
  42.     + Very easy to install (rated PG6 :-)
  43.     + Simple to maintain and configure because
  44.       all you need is actually only ONE executable (procmail)
  45.       and ONE configuration file (.procmailrc)
  46.     + Is event driven (i.e. gets invoked automagically when mail arrives)
  47.     + Does not use *any* temporary files
  48.     + Uses standard egrep regular expressions
  49.     + Allows for very-easy-to-use yes-no decisions on where the mail
  50.       should go (can take the size of the mail into consideration)
  51.     + Filters, delivers and forwards mail *reliably*
  52.     + Provides a reliable hook (you might even say anchor :-) for any
  53.       programs or shell scripts you may wish to start upon mail arrival
  54.     + Performs heroically under even the worst conditions
  55.       (file system full, out of swap space, process table full,
  56.       file table full, missing support files, unavailable executables,
  57.       denied permissions) and tries to deliver the mail somehow anyway
  58.     + Absolutely undeliverable mail (after trying every trick in the book)
  59.       will bounce back to the sender (or not, your choice)
  60.     + Is one of the few mailers to perform reliable mailbox locking across
  61.       NFS as well (DON'T use NFS mounted mailboxes WITHOUT installing
  62.       procmail, you may use valuable mail one day)
  63.     + Supports four mailfolder standards: single file folders (standard
  64.       and nonstandard VNIX format), directory folders that contain one file
  65.       per message, or the similar MH directory folders (numbered files)
  66.     + Variable assignment and substitution is an extremely complete subset
  67.       of the standard /bin/sh syntax
  68.     + Provides a mail log file, which logs all mail arrival, shows
  69.       in summary whence it came from, what it was about, where it went
  70.       (what folder) and how long (in bytes) it was
  71.     + Uses this log file to display a wide range of diagnostic and error
  72.       messages (if something went wrong)
  73.     + Processed mail can contain arbitrary 8-bit characters (including
  74.       '\0'); i.e. binary mailings can be processed if the rest of the
  75.       mailing system knew how to handle them too
  76.     + It has a man page (boy, does *it* have a man page)
  77.     + Procmail can be used as a local delivery agent (a completely
  78.       integrated substitute for /bin/mail), in which case it can heal
  79.       your system mailbox, if something messes up the permissions
  80.     + It runs on virtually all (old and future) operating systems which
  81.       names start with a 'U' or end in an 'X' :-) (i.e. extremely portable
  82.       code; POSIX, ANSI C and K&R conforming)
  83.     + Is clock skew immune (e.g. in the case of NFS mounted mailboxes)
  84.     + Works with (among others?) sendmail, smail and MMDF
  85.  
  86. Feature summary for formail:
  87.     + Can generate auto-reply headers
  88.     + Can convert mail into standard mailbox format (so that you can
  89.       process it with standard mail programs)
  90.     + Can split up mailboxes into the individual messages
  91.     + Can split up digests into the individual messages
  92.     + Can split up saved articles into the individual articles
  93.     + Can do simple header munging/extraction
  94.  
  95. Feature summary for lockfile:
  96.     + Provides NFS-secure lockfiles to shell script programmers
  97.     + Gives normal users the ability to lock their system mailbox,
  98.       regardless of permissions on the mail-spool directory
  99. ----------------------cut here-----------------
  100. #! /bin/sh
  101. # This is a shell archive.  Remove anything before this line, then unpack
  102. # it by saving it into a file and typing "sh file".  To overwrite existing
  103. # files, type "sh file -c".  You can also feed this as standard input via
  104. # unshar, or by typing "sh <file", e.g..  If this archive is complete, you
  105. # will see the following message at the end:
  106. #        "End of archive 1 (of 5)."
  107. # Contents:  procmail procmail/FEATURES procmail/HISTORY
  108. #   procmail/README procmail/common.c procmail/examples
  109. #   procmail/examples/1procmailrc procmail/examples/2procmailrc
  110. #   procmail/examples/2rmail procmail/examples/3procmailrc
  111. #   procmail/examples/3rmail procmail/examples/forward
  112. #   procmail/examples/listrc procmail/exopen.c procmail/exopen.h
  113. #   procmail/lockfile.c procmail/man procmail/patchlevel.h
  114. #   procmail/procmail.h procmail/recommend.c procmail/strpbrk.c
  115. # Wrapped by berg@drunol on Thu Apr 30 13:42:55 1992
  116. PATH=/bin:/usr/bin:/usr/ucb ; export PATH
  117. if test ! -d 'procmail' ; then
  118.     echo shar: Creating directory \"'procmail'\"
  119.     mkdir 'procmail'
  120. fi
  121. if test -f 'procmail/FEATURES' -a "${1}" != "-c" ; then 
  122.   echo shar: Will not clobber existing file \"'procmail/FEATURES'\"
  123. else
  124. echo shar: Extracting \"'procmail/FEATURES'\" \(3204 characters\)
  125. sed "s/^X//" >'procmail/FEATURES' <<'END_OF_FILE'
  126. XFeature summary for procmail:
  127. X    + It's small
  128. X    + Very easy to install (rated PG6 :-)
  129. X    + Simple to maintain and configure because
  130. X      all you need is actually only ONE executable (procmail)
  131. X      and ONE configuration file (.procmailrc)
  132. X    + Is event driven (i.e. gets invoked automagically when mail arrives)
  133. X    + Does not use *any* temporary files
  134. X    + Uses standard egrep regular expressions
  135. X    + Allows for very-easy-to-use yes-no decisions on where the mail
  136. X      should go (can take the size of the mail into consideration)
  137. X    + Filters, delivers and forwards mail *reliably*
  138. X    + Provides a reliable hook (you might even say anchor :-) for any
  139. X      programs or shell scripts you may wish to start upon mail arrival
  140. X    + Performs heroically under even the worst conditions
  141. X      (file system full, out of swap space, process table full,
  142. X      file table full, missing support files, unavailable executables,
  143. X      denied permissions) and tries to deliver the mail somehow anyway
  144. X    + Absolutely undeliverable mail (after trying every trick in the book)
  145. X      will bounce back to the sender (or not, your choice)
  146. X    + Is one of the few mailers to perform reliable mailbox locking across
  147. X      NFS as well (DON'T use NFS mounted mailboxes WITHOUT installing
  148. X      procmail, you may use valuable mail one day)
  149. X    + Supports four mailfolder standards: single file folders (standard
  150. X      and nonstandard VNIX format), directory folders that contain one file
  151. X      per message, or the similar MH directory folders (numbered files)
  152. X    + Variable assignment and substitution is an extremely complete subset
  153. X      of the standard /bin/sh syntax
  154. X    + Provides a mail log file, which logs all mail arrival, shows
  155. X      in summary whence it came from, what it was about, where it went
  156. X      (what folder) and how long (in bytes) it was
  157. X    + Uses this log file to display a wide range of diagnostic and error
  158. X      messages (if something went wrong)
  159. X    + Processed mail can contain arbitrary 8-bit characters (including
  160. X      '\0'); i.e. binary mailings can be processed if the rest of the
  161. X      mailing system knew how to handle them too
  162. X    + It has a man page (boy, does *it* have a man page)
  163. X    + Procmail can be used as a local delivery agent (a completely
  164. X      integrated substitute for /bin/mail), in which case it can heal
  165. X      your system mailbox, if something messes up the permissions
  166. X    + It runs on virtually all (old and future) operating systems which
  167. X      names start with a 'U' or end in an 'X' :-) (i.e. extremely portable
  168. X      code; POSIX, ANSI C and K&R conforming)
  169. X    + Is clock skew immune (e.g. in the case of NFS mounted mailboxes)
  170. X    + Works with (among others?) sendmail, smail and MMDF
  171. X
  172. XFeature summary for formail:
  173. X    + Can generate auto-reply headers
  174. X    + Can convert mail into standard mailbox format (so that you can
  175. X      process it with standard mail programs)
  176. X    + Can split up mailboxes into the individual messages
  177. X    + Can split up digests into the individual messages
  178. X    + Can split up saved articles into the individual articles
  179. X    + Can do simple header munging/extraction
  180. X
  181. XFeature summary for lockfile:
  182. X    + Provides NFS-secure lockfiles to shell script programmers
  183. X    + Gives normal users the ability to lock their system mailbox,
  184. X      regardless of permissions on the mail-spool directory
  185. END_OF_FILE
  186. if test 3204 -ne `wc -c <'procmail/FEATURES'`; then
  187.     echo shar: \"'procmail/FEATURES'\" unpacked with wrong size!
  188. fi
  189. # end of 'procmail/FEATURES'
  190. fi
  191. if test -f 'procmail/HISTORY' -a "${1}" != "-c" ; then 
  192.   echo shar: Will not clobber existing file \"'procmail/HISTORY'\"
  193. else
  194. echo shar: Extracting \"'procmail/HISTORY'\" \(5045 characters\)
  195. sed "s/^X//" >'procmail/HISTORY' <<'END_OF_FILE'
  196. X    Only the last entry is complete, the others might have been condensed.
  197. X
  198. X1990/12/07: v1.00
  199. X1990/12/12: v1.01
  200. X1991/02/04: v1.02
  201. X1991/02/13: v1.10
  202. X1991/02/21: v1.20
  203. X1991/02/22: v1.21
  204. X1991/03/01: v1.30
  205. X1991/03/15: v1.35
  206. X        Started using RCS to manage the source
  207. X1991/06/04: v1.99
  208. X1991/06/10: v2.00
  209. X1991/06/11: v2.01
  210. X1991/06/12: v2.02
  211. X1991/06/20: v2.03
  212. X1991/07/04: v2.10
  213. X1991/07/12: v2.11
  214. X1991/10/02: v2.20 (never released)
  215. X1991/10/18: v2.30
  216. X        Implemented a custom regular expression library (fully egrep
  217. X           compatible), should eliminate the annoyances with incompatible
  218. X           egreps
  219. X        Accomplished the doubtful milestone of having a source file
  220. X           (regexp.c) which provokes a compiler error on an old compiler
  221. X           (if using the optimiser)
  222. X        Ignoring leading spaces on condition lines now (means that
  223. X           everything can be indented in the rcfile)
  224. X1991/10/22: v2.31
  225. X1991/12/05: v2.40
  226. X        Made a clear debugging-aid entry in the INSTALL file
  227. X        Made procmail capable of healing the recipient's mail spool file
  228. X        Tricked NFS into supplying an access_time<modification_time for the
  229. X           folders written
  230. X1991/12/13: v2.50
  231. X1992/01/22: v2.60
  232. X        Enhanced the response to signals (SIGTERM and SIGQUIT now have
  233. X           different meanings)
  234. X1992/01/31: v2.61
  235. X        Updated the directions for .forward file contents
  236. X        Fixed the EDQUOT define (some machines didn't define it)
  237. X        Eliminated a rare (no report of it occuring yet) inconvenience,
  238. X           a temporary file could be left lying around if procmail would
  239. X           be killed in a very small window after an open()
  240. X        Kludge the username into lowercase after the -d option
  241. X        Added specific directions for sites running smail (see
  242. X           examples/advanced)
  243. X        Added a search for sendmail in autoconf
  244. X        Fixed a problem in the implicit-lockfile-searching code
  245. X        Added the ARCHITECTURE variable to the Makefile (for convenience)
  246. X1992/04/30: v2.70
  247. X        Added NO_USER_TO_LOWERCASE_HACK and NO_NFS_ATIME_HACK defines to
  248. X           config.h
  249. X        Added LD_LIBRARY_PATH protection (would have been a security hole
  250. X           on some machines)
  251. X        Fixed mistakenly default usage of KERNEL_LOCKS (was enabled
  252. X           regardless of the definition of KERNEL_LOCKS in config.h), if
  253. X           your system is running buggy lockd's, problems could have
  254. X           occurred
  255. X        Inserted some casts to shut up systems with ANSI compilers and
  256. X           prototyped include files
  257. X        Made sure logfile is flushed before forking
  258. X        Made sure no library calls are made in signal handlers
  259. X        Added a `vacation'-autoreply sample in examples/advanced
  260. X        Worked around a `PATH' bug in some Bourne shells
  261. X        Sped up sputenv, the smart environment handler routine
  262. X        Made sure procmail checks the return value from close()
  263. X        Made the man pages yet more portable (.LP->.PP)
  264. X        Made it possible for lockfile to be setuid or setgid, so that
  265. X           it is able to create and unlink lockfiles in the mail
  266. X           spool directory, even if normal users cannot
  267. X        Created the targets 'recommend' and 'suid' in Makefile, in
  268. X           order to make suid/sgid recommendations even more obvious,
  269. X           not easily overlooked and automatic
  270. X        Worked around bugs in some compilers not accepting:
  271. X           - struct eps const*const something;
  272. X           - char a[2]; &a;
  273. X        Worked around a bug in the SINIX include files (wrong protype for
  274. X           uname)
  275. X        Made procmail & lockfile clock skew independent (during LOCKTIMEOUT)
  276. X        By popular demand: added possibility to select mails on size
  277. X        Made procmail accept multiple recipients (this was not as trivial
  278. X           as it sounds!), in order for complete compatibility with mailers
  279. X           like smail 2.x
  280. X        Expanded the mail-delivery-agent instructions in examples/advanced,
  281. X           this includes specific intstructions for smail 2.x
  282. X        Made special entries in config.h for semi-permanent environment-
  283. X           variable overrides
  284. X        Made formail more intelligent, it can now parse full-fledged
  285. X           RFC822 addresses (quoting et al)
  286. X        Let formail look at the Date: field when reconstructing the date
  287. X        Changed stdin handling in forks in formail, to circumvent a bug in
  288. X           HP/UX
  289. X        A complete rewrite of formail, the code got bigger, the runtime
  290. X           requirement got bigger, it got slower, but, it's more structured
  291. X           (so much for structured programming :-)
  292. X        Provide a separate strpbrk.c file, since I use it in several
  293. X           programs now
  294. X        Made procmail check the permissions of its invoker, generate
  295. X           an overriding From_ line if necessary, and consequently made it
  296. X           accept the -f option (fromwhom), and also the alternate obsolete
  297. X           -r option of course
  298. X        Wiped out the ./include tree, made autoconf check it instead (the
  299. X           compile line looks so terribly clean now :-)
  300. X        Procmail makes an additional security check on the rcfiles before
  301. X           accepting them (owner and permissions, see man page)
  302. X        Fixed the `spurious' 0660 permissions on system-mailboxes
  303. END_OF_FILE
  304. if test 5045 -ne `wc -c <'procmail/HISTORY'`; then
  305.     echo shar: \"'procmail/HISTORY'\" unpacked with wrong size!
  306. fi
  307. # end of 'procmail/HISTORY'
  308. fi
  309. if test -f 'procmail/README' -a "${1}" != "-c" ; then 
  310.   echo shar: Will not clobber existing file \"'procmail/README'\"
  311. else
  312. echo shar: Extracting \"'procmail/README'\" \(4205 characters\)
  313. sed "s/^X//" >'procmail/README' <<'END_OF_FILE'
  314. XFor installation instructions see the INSTALL file.
  315. X----------------------
  316. XProcmail & formail mail processing package.
  317. XCopyright (c) 1990-1992, S.R. van den Berg, The Netherlands.
  318. X
  319. XSome legal stuff:
  320. X
  321. XUse this software package at your own risk.  The programmer cannot
  322. Xbe held liable for any incurred damages, directly or indirectly due to
  323. Xthe use or inability to use this software.
  324. X
  325. XYou are encouraged to distribute this package freely.  This package is
  326. Xhowever not to be sold (minor transfer costs excepted) or included in
  327. Xany commercially sold software package (if you want to do this anyway,
  328. Xcontact me (address below), and we'll work something out).
  329. X
  330. XIf you distribute it, please leave the package intact.    You are allowed to
  331. Xtake parts from this distribution and distribute these separately as long
  332. Xas you retain the copyright messages.  If you redistribute any part of this
  333. Xpackage in a modified form, be sure to mark the parts you changed.
  334. XIf you have some important changes that might be useful to the rest of the
  335. Xworld, contact me instead.
  336. X
  337. X-------------------------- SYSTEM REQUIREMENTS -------------------------------
  338. X
  339. XAny *NIX-alike system.
  340. X
  341. XSendmail, smail, MMDF or compatible mailers (in effect any mailer that can
  342. Xprocess RFC-822 compliant mails).
  343. X
  344. XThe most important system calls that need to be supported (among others):
  345. Xdup(),wait(),getpwnam(),fork(),pipe()
  346. X
  347. XFor a more complete list of all library references see "includes.h"
  348. X
  349. X------------------------------ DESCRIPTION -----------------------------------
  350. X
  351. XThe procmail mail processing program. (v2.70 1992/04/30)
  352. X
  353. XCan be used to create mail-servers, mailing lists, sort your incoming mail
  354. Xinto separate folders/files (real convenient when subscribing to one or more
  355. Xmailing lists or for prioritising your mail), preprocess your mail, start
  356. Xany programs upon mail arrival (e.g. to generate different chimes on your
  357. Xworkstation for different types of mail) or selectively forward certain
  358. Xincoming mail automatically to someone.
  359. X
  360. XThe accompanying formail program enables you to generate autoreplies, split up
  361. Xdigests/mailboxes into the original messages, do some very simple
  362. Xheader-munging/extraction, or force mail into mail-format (with leading From
  363. Xline).
  364. X
  365. X----------------------
  366. X
  367. XI made the utmost effort to make procmail as robust as any program can be
  368. X(every conceivable system error is caught *and* handled).
  369. X
  370. XProcmail was designed to deliver the mail under the worst conditions
  371. X(file system full, out of swap space, process table full, file table full,
  372. Xmissing support files, unavailable executables; it all doesn't matter).
  373. XShould (in the unlikely event) procmail be unable to deliver your mail
  374. Xsomewhere, the mail will bounce back to the sender or reenter the mailqueue
  375. X(your choice).
  376. X
  377. XFor a more extensive list of features see the FEATURES file.
  378. X
  379. X----------------------
  380. X
  381. XHowever, as with any program, bugs cannot be completely ruled out.
  382. XI tested the program extensively, and believe it should be relatively
  383. Xbug free (no known bug at the time).  Should, however, anyone find any
  384. Xbugs (highly unlikely :-), I would be pleased (well, sort of :-) to hear
  385. Xabout it.  Please send me the patches or bug report.
  386. XI'll look at them and will try to fix it in a future release.
  387. X(BTW, if you should find any spelling or grammar errors in these files,
  388. Xdon't hesitate to point them out to me; I like correct English just as much
  389. Xas you do).
  390. X
  391. XPlease note that this program essentially is supposed to be static, that
  392. Xmeans no extra features (honouring the VNIX spirit) are supposed to be
  393. Xadded (though any useful suggestions will be appreciated and evaluated if
  394. Xtime permits).
  395. X
  396. XCheers,
  397. X       Stephen R. van den Berg    at RWTH-Aachen, Germany.
  398. X
  399. XInternet E-mail:        berg@pool.informatik.rwth-aachen.de
  400. X                berg@physik.tu-muenchen.de
  401. X
  402. XSnail-Mail:    P.O.Box 21074
  403. X        6369 ZG Simpelveld
  404. X        The Netherlands
  405. X
  406. X----------------------
  407. XA recent version can be picked up at various comp.sources.misc archives.
  408. XThe latest version can be obtained directly from the ftp-archive at:
  409. X
  410. X    ftp.informatik.rwth-aachen.de (137.226.112.31)
  411. X
  412. X    as compressed tar file:        pub/unix/procmail.tar.Z        <128KB
  413. X    or in compressed shar format:    pub/unix/procmail.0?.Z
  414. X----------------------
  415. END_OF_FILE
  416. if test 4205 -ne `wc -c <'procmail/README'`; then
  417.     echo shar: \"'procmail/README'\" unpacked with wrong size!
  418. fi
  419. # end of 'procmail/README'
  420. fi
  421. if test -f 'procmail/common.c' -a "${1}" != "-c" ; then 
  422.   echo shar: Will not clobber existing file \"'procmail/common.c'\"
  423. else
  424. echo shar: Extracting \"'procmail/common.c'\" \(2031 characters\)
  425. sed "s/^X//" >'procmail/common.c' <<'END_OF_FILE'
  426. X/************************************************************************
  427. X *    A some common routines for procmail and formail            *
  428. X *                                    *
  429. X *    Copyright (c) 1990-1992, S.R. van den Berg, The Netherlands    *
  430. X *    The sources can be freely copied for non-commercial use.    *
  431. X *    #include "README"                        *
  432. X *                                    *
  433. X ************************************************************************/
  434. X#ifdef RCS
  435. Xstatic char rcsid[]="$Id: common.c,v 2.11 1992/03/19 14:00:28 berg Rel $";
  436. X#endif
  437. X#include "includes.h"
  438. X
  439. Xvoid*tmalloc();
  440. Xextern const char binsh[];
  441. X
  442. X#ifdef NOmemmove
  443. Xvoid*smemmove(To,From,count)void*To,*From;register size_t count;
  444. X#ifdef NObcopy
  445. X{ register char*to=To,*from=From;/*void*old;*/      /* silly compromise, throw */
  446. X  /*old=to;*/count++;--to;--from;  /* away space to be syntactically correct */
  447. X  if(to<=from)
  448. X   { goto jiasc;
  449. X     do
  450. X      { *++to= *++from;                      /* copy from above */
  451. Xjiasc:;
  452. X      }
  453. X     while(--count);
  454. X   }
  455. X  else
  456. X   { to+=count;from+=count;goto jidesc;
  457. X     do
  458. X      { *--to= *--from;                      /* copy from below */
  459. Xjidesc:;
  460. X      }
  461. X     while(--count);
  462. X   }
  463. X  return To/*old*/;
  464. X#else
  465. X{ bcopy(From,To,count);return To;
  466. X#endif /* NObcopy */
  467. X}
  468. X#endif /* NOmemmove */
  469. X
  470. X#include "shell.h"
  471. X
  472. Xshexec(argv)char*const*argv;
  473. X{ int i;char**newargv;const char**p;
  474. X#ifdef SIGXCPU
  475. X  signal(SIGXCPU,SIG_DFL);signal(SIGXFSZ,SIG_DFL);
  476. X#endif
  477. X  signal(SIGPIPE,SIG_DFL);execvp(*argv,argv);    /* or is it a shell script ? */
  478. X  for(p=(const char**)argv,i=1;i++,*p++;);          /* count the arguments */
  479. X  newargv=malloc(i*sizeof*p);
  480. X  for(*(p=(const char**)newargv)=binsh;*++p= *argv++;);
  481. X  execve(*newargv,newargv,environ);          /* no shell script? -> trouble */
  482. X  log("Failed to execute");logqnl(*argv);exit(EX_UNAVAILABLE);
  483. X}
  484. X
  485. Xchar*pstrspn(whole,sub)const char*whole,*const sub;
  486. X{ while(*whole&&strchr(sub,*whole))
  487. X     whole++;
  488. X  return(char*)whole;
  489. X}
  490. X
  491. X#ifdef NOstrcspn
  492. Xstrcspn(whole,sub)const char*const whole,*const sub;
  493. X{ const register char*p;
  494. X  p=whole;
  495. X  while(*p&&!strchr(sub,*p))
  496. X     p++;
  497. X  return p-whole;
  498. X}
  499. X#endif
  500. END_OF_FILE
  501. if test 2031 -ne `wc -c <'procmail/common.c'`; then
  502.     echo shar: \"'procmail/common.c'\" unpacked with wrong size!
  503. fi
  504. # end of 'procmail/common.c'
  505. fi
  506. if test ! -d 'procmail/examples' ; then
  507.     echo shar: Creating directory \"'procmail/examples'\"
  508.     mkdir 'procmail/examples'
  509. fi
  510. if test -f 'procmail/examples/1procmailrc' -a "${1}" != "-c" ; then 
  511.   echo shar: Will not clobber existing file \"'procmail/examples/1procmailrc'\"
  512. else
  513. echo shar: Extracting \"'procmail/examples/1procmailrc'\" \(634 characters\)
  514. sed "s/^X//" >'procmail/examples/1procmailrc' <<'END_OF_FILE'
  515. X# Please check if all the paths in PATH are reachable, remove the ones that
  516. X# are not.
  517. X
  518. XPATH=$HOME/bin:/usr/bin:/usr/ucb:/bin:/usr/local/bin:
  519. XMAILDIR=$HOME/Mail    # You'd better make sure it exists
  520. XDEFAULT=$MAILDIR/mbox
  521. XLOGFILE=$MAILDIR/from
  522. XLOCKFILE=$HOME/.lockmail
  523. X
  524. X:                # Anything from thf
  525. X^From.*thf@somewhere.someplace
  526. Xtodd                # will go to $MAILDIR/todd
  527. X
  528. X:                # Anything from people at uunet
  529. X^From.*@uunet
  530. Xuunetbox            # will go to $MAILDIR/uunetbox
  531. X
  532. X:                # Anything from Henry
  533. X^From.*henry
  534. Xhenries                # will go to $MAILDIR/henries
  535. X
  536. X# Anything that has not been delivered by now will go to $DEFAULT
  537. X# using LOCKFILE=$DEFAULT$LOCKEXT
  538. END_OF_FILE
  539. if test 634 -ne `wc -c <'procmail/examples/1procmailrc'`; then
  540.     echo shar: \"'procmail/examples/1procmailrc'\" unpacked with wrong size!
  541. fi
  542. # end of 'procmail/examples/1procmailrc'
  543. fi
  544. if test -f 'procmail/examples/2procmailrc' -a "${1}" != "-c" ; then 
  545.   echo shar: Will not clobber existing file \"'procmail/examples/2procmailrc'\"
  546. else
  547. echo shar: Extracting \"'procmail/examples/2procmailrc'\" \(1970 characters\)
  548. sed "s/^X//" >'procmail/examples/2procmailrc' <<'END_OF_FILE'
  549. X# Please check if all the paths in PATH are reachable, remove the ones that
  550. X# are not.
  551. X
  552. XPATH=$HOME/bin:/usr/bin:/usr/ucb:/bin:/usr/local/bin:
  553. XMAILDIR=$HOME/Mail    # You'd better make sure it exists
  554. XDEFAULT=$MAILDIR/mbox
  555. X            # We don't use a global lockfile here now.
  556. X            # Instead we use local lockfiles everywhere.
  557. X            # This allows mail to arrive in all mailboxes
  558. X            # concurrently, or allows you to read one mailbox
  559. X            # while mail arrives in another.
  560. X
  561. X# The next recipe will split up Digests into their individual messages.
  562. X# Don't do this if you use a global lockfile before this recipe (deadlock)
  563. X
  564. X:
  565. X^Subject:.*Digest
  566. X|formail +1 -d -s procmail
  567. X
  568. XLOGFILE=$MAILDIR/from        # Put it here, in order to avoid logging
  569. X                # the arrival of the digest.
  570. X
  571. X# An alternative and probably more efficient solution to splitting up a digest
  572. X# would be (only works for standard format mailbox files though):
  573. X
  574. X::
  575. X^Subject:.*Other Digest
  576. X|formail +1 -ds cat >>this_lists_mailbox
  577. X
  578. X# Notice the double : in the next recipe, this will cause a lockfile
  579. X# named "$MAILDIR/todd.lock" to be used if and only if this mail is going
  580. X# into the file "todd".
  581. X
  582. X::                # Anything from thf
  583. X^From.*thf@somewhere.someplace
  584. Xtodd                # will go to $MAILDIR/todd
  585. X
  586. X
  587. X# The next recipe will likewise use $MAILDIR/uunetbox.lock as a lock file.
  588. X
  589. X::                # Anything from people at uunet
  590. X^From.*@uunet
  591. Xuunetbox            # will go to $MAILDIR/uunetbox
  592. X
  593. X
  594. X# And here the lockfile will be $MAILDIR/henries.lock of course.
  595. X
  596. X::                # Anything from Henry
  597. X^From.*henry
  598. Xhenries                # will go to $MAILDIR/henries
  599. X
  600. X
  601. X# But you can specify any lockfile you want, like "myfile".  The following
  602. X# recipe will use "$MAILDIR/myfile" as the lock file.
  603. X
  604. X::myfile            # All 'questions' will go to
  605. X^Subject:.*questions
  606. Xtoread                # $MAILDIR/toread
  607. X
  608. X# Anything that has not been delivered by now will go to $DEFAULT
  609. X
  610. X# After procmail sees the end of the rcfile, it pretends that it sees a
  611. X# LOCKFILE=$DEFAULT$LOCKEXT
  612. X# Therefore $DEFAULT is always locked.
  613. END_OF_FILE
  614. if test 1970 -ne `wc -c <'procmail/examples/2procmailrc'`; then
  615.     echo shar: \"'procmail/examples/2procmailrc'\" unpacked with wrong size!
  616. fi
  617. # end of 'procmail/examples/2procmailrc'
  618. fi
  619. if test -f 'procmail/examples/2rmail' -a "${1}" != "-c" ; then 
  620.   echo shar: Will not clobber existing file \"'procmail/examples/2rmail'\"
  621. else
  622. echo shar: Extracting \"'procmail/examples/2rmail'\" \(392 characters\)
  623. sed "s/^X//" >'procmail/examples/2rmail' <<'END_OF_FILE'
  624. X#!/bin/sh
  625. X#
  626. X# specify the mailbox file you want to read on the command line
  627. X#
  628. XMAILDIR=$HOME/Mail
  629. Xcd $MAILDIR
  630. XLOCKFILE=$1.lock
  631. Xif lockfile -! -r1 $LOCKFILE
  632. Xthen
  633. X echo Mail is currently arriving, please wait...
  634. X while
  635. X   lockfile -! -4 -r2 $LOCKFILE
  636. X do
  637. X echo Mail is still arriving...
  638. X done
  639. Xfi
  640. Xtrap "rm -f $LOCKFILE;exit 0" 0 1 2 3 15
  641. X#
  642. X# Call you favourite mailer here.
  643. X#
  644. X/usr/ucb/mail -f $*
  645. END_OF_FILE
  646. if test 392 -ne `wc -c <'procmail/examples/2rmail'`; then
  647.     echo shar: \"'procmail/examples/2rmail'\" unpacked with wrong size!
  648. fi
  649. # end of 'procmail/examples/2rmail'
  650. fi
  651. if test -f 'procmail/examples/3procmailrc' -a "${1}" != "-c" ; then 
  652.   echo shar: Will not clobber existing file \"'procmail/examples/3procmailrc'\"
  653. else
  654. echo shar: Extracting \"'procmail/examples/3procmailrc'\" \(1517 characters\)
  655. sed "s/^X//" >'procmail/examples/3procmailrc' <<'END_OF_FILE'
  656. X# Please check if all the paths in PATH are reachable, remove the ones that
  657. X# are not.
  658. X
  659. XPATH=$HOME/bin:/usr/bin:/global/bin:/usr/ucb:/bin:/usr/local/bin:
  660. XMAILDIR =    $HOME/Mail    # You'd better make sure it exists
  661. XDEFAULT =    $MAILDIR/mbox
  662. XLOGFILE =    $MAILDIR/from
  663. XLOCKFILE=    $HOME/.lockmail
  664. X
  665. X            # This will create a local lockfile named todd.lock
  666. X::            # *if* the condition matches
  667. X^From.*thf
  668. Xtodd
  669. X
  670. XLOCKFILE=$MAILDIR/whatever    # This will remove the global lockfile
  671. X                # $HOME/.lockmail and the new lockfile
  672. X                # will be $MAILDIR/whatever
  673. X
  674. X
  675. X                # The next recipe will
  676. X                # filter out all messages from "at"
  677. X                # jobs and will put them in a terse format
  678. X                # (only the date and the body) in
  679. X                # a file called $MAILDIR/atjunk
  680. X: 2 fh
  681. X^From root
  682. X^Subject: Output from "at" job
  683. X|egrep "^Date:"
  684. X                # The next recipe will only be used if
  685. X                # the previous one matched
  686. X:A
  687. Xatjunk
  688. X
  689. X
  690. X
  691. XMAILDIR=$HOME/News    # This will change the current directory
  692. X
  693. X
  694. X            # The next recipe will create a local lockfile
  695. X            # named $HOME/News/dustbin.lock (*if* the condition
  696. X            # matches), and will feed the body of the message
  697. X            # through `sort` (sorry, couldn't come up with anything
  698. X            # better :-), after which the result will be
  699. X            # appended to $HOME/News/dustbin
  700. X:b:
  701. X^Subject:.*rubbish
  702. X|sort >>dustbin
  703. X
  704. X            # The next recipe will use the play directory as a MH
  705. X            # folder (of course you need MH to read the mail then)
  706. X:
  707. X^Subject:.*games
  708. Xgames/.
  709. X
  710. X# Anything not delivered by now will go to $HOME/Mail/mbox
  711. X# Using LOCKFILE=$HOME/Mail/mbox.lock
  712. END_OF_FILE
  713. if test 1517 -ne `wc -c <'procmail/examples/3procmailrc'`; then
  714.     echo shar: \"'procmail/examples/3procmailrc'\" unpacked with wrong size!
  715. fi
  716. # end of 'procmail/examples/3procmailrc'
  717. fi
  718. if test -f 'procmail/examples/3rmail' -a "${1}" != "-c" ; then 
  719.   echo shar: Will not clobber existing file \"'procmail/examples/3rmail'\"
  720. else
  721. echo shar: Extracting \"'procmail/examples/3rmail'\" \(757 characters\)
  722. sed "s/^X//" >'procmail/examples/3rmail' <<'END_OF_FILE'
  723. X#!/bin/sh
  724. X#
  725. X# specify the mailbox file you want to read on the command line
  726. X# Use a relative path from your $HOME directory
  727. X#
  728. X# For this kind of chaotic procmailrc there is no uniform neat solution
  729. X# to determine which lockfiles to use.    I'll give just one (suboptimal)
  730. X# solution here.  Use your imagination to extend it :-).
  731. X#
  732. XMAILDIR=$HOME/Mail
  733. Xcd $HOME            # this means all paths are relative to $HOME
  734. XLOCKFILE=$HOME/.lockmail
  735. XLOCKFILE2=$HOME/Mail/whatever
  736. Xif lockfile -! -r1 $LOCKFILE $LOCKFILE2
  737. Xthen
  738. X echo Mail is currently arriving, please wait...
  739. X while
  740. X   lockfile -! -4 -r2 $LOCKFILE $LOCKFILE2
  741. X do
  742. X echo Mail is still arriving...
  743. X done
  744. Xfi
  745. Xtrap "rm -f $LOCKFILE $LOCKFILE2;exit 0" 0 1 2 3 15
  746. X#
  747. X# Call you favourite mailer here.
  748. X#
  749. X/usr/ucb/mail -f $*
  750. END_OF_FILE
  751. if test 757 -ne `wc -c <'procmail/examples/3rmail'`; then
  752.     echo shar: \"'procmail/examples/3rmail'\" unpacked with wrong size!
  753. fi
  754. # end of 'procmail/examples/3rmail'
  755. fi
  756. if test -f 'procmail/examples/forward' -a "${1}" != "-c" ; then 
  757.   echo shar: Will not clobber existing file \"'procmail/examples/forward'\"
  758. else
  759. echo shar: Extracting \"'procmail/examples/forward'\" \(57 characters\)
  760. sed "s/^X//" >'procmail/examples/forward' <<'END_OF_FILE'
  761. X"|IFS=' ';exec /usr/local/bin/procmail #YOUR_LOGIN_NAME"
  762. END_OF_FILE
  763. if test 57 -ne `wc -c <'procmail/examples/forward'`; then
  764.     echo shar: \"'procmail/examples/forward'\" unpacked with wrong size!
  765. fi
  766. # end of 'procmail/examples/forward'
  767. fi
  768. if test -f 'procmail/examples/listrc' -a "${1}" != "-c" ; then 
  769.   echo shar: Will not clobber existing file \"'procmail/examples/listrc'\"
  770. else
  771. echo shar: Extracting \"'procmail/examples/listrc'\" \(1856 characters\)
  772. sed "s/^X//" >'procmail/examples/listrc' <<'END_OF_FILE'
  773. XPATH=/bin:/usr/bin:/usr/local/bin    # add more if appropriate
  774. XSHELL=/bin/sh
  775. X
  776. X# list        should contain the submitting address of the list
  777. X# listreq    should contain the request address of the list
  778. X# subscribers    should name the file which contains the list of subscribers
  779. X#        separated by whitespace
  780. X
  781. X:3wfh
  782. X!^Subject:.*((add|remove).*list|subscribe)
  783. X!^From +(postmaster|Mailer)
  784. X!^X-Loop: loop
  785. X| formail -b -IReturn-Receipt-To: -I"Errors-To: $listreq" \
  786. X  -I "Sender: $listreq" -I"Precedence: bulk" -IReceived: -I"X-Loop: loop"\
  787. X# -i "Reply-To: $list"            # uncomment if you want, many people
  788. X                    # consider this a bad idea.
  789. X
  790. X# If memberlist is longer than 2048 bytes, you will have to insert a
  791. X# LINEBUF=some_big_number here because procmail uses a buffer of size
  792. X# $LINEBUF to expand the inline 'cat'
  793. X
  794. X:Aw
  795. X! -f$listreq `cat $subscribers`        # the -f and -oi are sendmail options
  796. X                    # omit if not applicable
  797. X    # the -f flag will only take effect if the sender is not local
  798. X
  799. X# Alternatively you could have put the burden on the shell for expanding the
  800. X# 'cat' by providing the following action line instead:
  801. X# | $SENDMAIL -oi `cat $subscribers`;    # the ; forces the procmail to pass
  802. X                    # on the line to the shell unparsed
  803. X
  804. X# Anything not delivered yet (either because it was from the postmaster
  805. X# or mailer-daemon, or because it might be a request-message) will be forwarded
  806. X# to the list maintainer:
  807. X:0w
  808. X! -oi $listreq
  809. X
  810. X# In case not even this works, the mail will be appended to the
  811. X# following last-resort files
  812. X
  813. XUMASK=666    # this is probably inevitable since procmail (in this case)
  814. X        # could be running under the local-sender's uid or the
  815. X        # daemon or mailer-uid (in the remote-sender's case)
  816. X
  817. XDEFAULT=/usr/tmp/${listreq}s        # first-choice
  818. XORGMAIL=/tmp/${listreq}s        # a last-last-resort-file in case the
  819. X            # filesystem for /usr/tmp/mylist-request should be full
  820. END_OF_FILE
  821. if test 1856 -ne `wc -c <'procmail/examples/listrc'`; then
  822.     echo shar: \"'procmail/examples/listrc'\" unpacked with wrong size!
  823. fi
  824. # end of 'procmail/examples/listrc'
  825. fi
  826. if test -f 'procmail/exopen.c' -a "${1}" != "-c" ; then 
  827.   echo shar: Will not clobber existing file \"'procmail/exopen.c'\"
  828. else
  829. echo shar: Extracting \"'procmail/exopen.c'\" \(2227 characters\)
  830. sed "s/^X//" >'procmail/exopen.c' <<'END_OF_FILE'
  831. X/************************************************************************
  832. X *    Collection of NFS secure exclusive open routines        *
  833. X *                                    *
  834. X *    Copyright (c) 1990-1992, S.R. van den Berg, The Netherlands    *
  835. X *    The sources can be freely copied for non-commercial use.    *
  836. X *    #include "README"                        *
  837. X *                                    *
  838. X ************************************************************************/
  839. X#ifdef RCS
  840. Xstatic char rcsid[]="$Id: exopen.c,v 2.11 1992/04/21 15:27:50 berg Rel $";
  841. X#endif
  842. X#include "config.h"
  843. X#include "includes.h"
  844. X#include "exopen.h"
  845. X#include "strpbrk.h"
  846. X
  847. Xconst char*hostname();
  848. Xextern pid_t thepid;
  849. Xextern const char dirsep[];
  850. X
  851. Xconst char*hostname()
  852. X{ static char name[HOSTNAMElen+1];
  853. X#ifdef    NOuname
  854. X  gethostname(name,HOSTNAMElen+1);
  855. X#else
  856. X  struct utsname names;
  857. X  uname_(&names);strncpy(name,names.nodename,HOSTNAMElen);
  858. X#endif
  859. X  name[HOSTNAMElen]='\0';return name;
  860. X}
  861. X
  862. Xultoan(val,dest)unsigned long val;char*dest;          /* convert to a number */
  863. X{ register i;                     /* within the set [0-9A-Za-z-_] */
  864. X  do
  865. X   { i=val&0x3f;
  866. X     *dest++=i+(i<10?'0':i<10+26?'A'-10:i<10+26+26?'a'-10-26:
  867. X      i==10+26+26?'-'-10-26-26:'_'-10-26-27);
  868. X   }
  869. X  while(val>>=6);
  870. X  *dest='\0';
  871. X}
  872. X
  873. Xunique(full,p,mode)const char*const full;char*const p;const mode_t mode;
  874. X{ unsigned long retry=mrotbSERIAL;int i;      /* create unique file name */
  875. X  do
  876. X   { ultoan(maskSERIAL&(retry<<bitsSERIAL-mrotbSERIAL)+
  877. X      (unsigned long)thepid,p+1);
  878. X     *p=UNIQ_PREFIX;strcat(p,hostname());
  879. X   }
  880. X#ifndef O_CREAT
  881. X#define ropen(path,type,mode)    creat(path,mode)
  882. X#endif
  883. X  while(0>(i=ropen(full,O_WRONLY|O_CREAT|O_EXCL|O_SYNC,mode))&&errno==EEXIST&&
  884. X   retry--);        /* casually check if it already exists (highly unlikely) */
  885. X  if(i<0)
  886. X   { writeerr(full);return 0;
  887. X   }
  888. X  rclose(i);return 1;
  889. X}
  890. X                     /* rename MUST fail if already existent */
  891. Xmyrename(old,newn)const char*const old,*const newn;
  892. X{ int i,serrno;struct stat stbuf;
  893. X  link(old,newn);serrno=errno;i=stat(old,&stbuf);unlink(old);errno=serrno;
  894. X  return stbuf.st_nlink==2?i:-1;
  895. X}
  896. X
  897. Xchar*lastdirsep(filename)const char*filename;     /* finds the next character */
  898. X{ const char*p;                    /* following the last DIRSEP */
  899. X  while(p=strpbrk(filename,dirsep))
  900. X     filename=p+1;
  901. X  return(char*)filename;
  902. X}
  903. END_OF_FILE
  904. if test 2227 -ne `wc -c <'procmail/exopen.c'`; then
  905.     echo shar: \"'procmail/exopen.c'\" unpacked with wrong size!
  906. fi
  907. # end of 'procmail/exopen.c'
  908. fi
  909. if test -f 'procmail/exopen.h' -a "${1}" != "-c" ; then 
  910.   echo shar: Will not clobber existing file \"'procmail/exopen.h'\"
  911. else
  912. echo shar: Extracting \"'procmail/exopen.h'\" \(284 characters\)
  913. sed "s/^X//" >'procmail/exopen.h' <<'END_OF_FILE'
  914. X/*$Id: exopen.h,v 2.4 1992/04/21 15:27:50 berg Rel $*/
  915. X#define charsSERIAL    4
  916. X#define UNIQnamelen    (1+charsSERIAL+HOSTNAMElen+1)
  917. X#define bitsSERIAL    (6*charsSERIAL)
  918. X#define maskSERIAL    ((1L<<bitsSERIAL)-1)
  919. X#define rotbSERIAL    2
  920. X#define mrotbSERIAL    ((1L<<rotbSERIAL)-1)
  921. X
  922. Xchar*lastdirsep();
  923. END_OF_FILE
  924. if test 284 -ne `wc -c <'procmail/exopen.h'`; then
  925.     echo shar: \"'procmail/exopen.h'\" unpacked with wrong size!
  926. fi
  927. # end of 'procmail/exopen.h'
  928. fi
  929. if test -f 'procmail/lockfile.c' -a "${1}" != "-c" ; then 
  930.   echo shar: Will not clobber existing file \"'procmail/lockfile.c'\"
  931. else
  932. echo shar: Extracting \"'procmail/lockfile.c'\" \(3742 characters\)
  933. sed "s/^X//" >'procmail/lockfile.c' <<'END_OF_FILE'
  934. X/************************************************************************
  935. X *    lockfile.c    a conditional semaphore-file creator        *
  936. X *                                    *
  937. X *    It has been designed to be able to be run suid/sgid root or    *
  938. X *    any id you see fit (in case your mail spool area is *not*    *
  939. X *    world writeable), without creating security holes.        *
  940. X *                                    *
  941. X *    Seems to be perfect.                        *
  942. X *                                    *
  943. X *    Created by S.R. van den Berg, The Netherlands            *
  944. X *    This file can be freely copied for any use.            *
  945. X *                                    *
  946. X ************************************************************************/
  947. X#ifdef RCS
  948. Xstatic char rcsid[]="$Id: lockfile.c,v 2.13 1992/04/21 15:27:50 berg Rel $";
  949. X#endif
  950. Xstatic char rcsdate[]="$Date: 1992/04/21 15:27:50 $";
  951. X#include "config.h"
  952. X#include "includes.h"
  953. X#include "exopen.h"
  954. X#include "strpbrk.h"
  955. X
  956. X#ifndef SYSTEM_MBOX
  957. X#define SYSTEM_MBOX    SYSTEM_MAILBOX
  958. X#endif
  959. X
  960. Xvolatile int exitflag;
  961. Xpid_t thepid;
  962. Xchar system_mbox[]=SYSTEM_MBOX;
  963. Xconst char dirsep[]=DIRSEP,lockext[]=DEFlockext;
  964. X
  965. Xvoid failure()
  966. X{ exitflag=1;
  967. X}
  968. X
  969. Xmain(argc,argv)const char*const argv[];
  970. X{ const char*const*p,*cp;uid_t uid;
  971. X  int sleepsec,retries,invert,force,suspend,retval=0,virgin=0;
  972. X  static char usage[]=
  973. X  "Usage: lockfile -nnn | -rnnn | -! | -lnnn | -snnn | -ml | -mu | file ...\n";
  974. X  sleepsec=8;force=retries=invert=0;suspend=16;thepid=getpid();uid=getuid();
  975. X  *lastdirsep(system_mbox)='\0';
  976. X  if(--argc<=0)
  977. X   { putse(usage);return EX_USAGE;
  978. X   }
  979. Xagain:
  980. X  p=argv;signal(SIGHUP,(void(*)())failure);signal(SIGINT,(void(*)())failure);
  981. X  signal(SIGQUIT,(void(*)())failure);signal(SIGTERM,(void(*)())failure);
  982. X  while(argc--)
  983. X     if(*(cp= *++p)=='-')
  984. X    switch(cp[1])
  985. X     { case '!':invert=1;break;
  986. X       case 'r':retries=strtol(cp+2,(char**)0,10);break;
  987. X       case 'l':force=strtol(cp+2,(char**)0,10);break;
  988. X       case 's':suspend=strtol(cp+2,(char**)0,10);break;
  989. X       case 'm':
  990. X        { struct passwd*pass;char*ma;
  991. X          if(virgin||!(pass=getpwuid(uid))||
  992. X           !(ma=malloc(strlen(system_mbox)+strlen(pass->pw_name)+
  993. X           STRLEN(lockext)+1)))
  994. X         goto eusg;
  995. X          strcpy(ma,system_mbox);strcat(ma,pass->pw_name);
  996. X          strcat(ma,lockext);
  997. X          if(cp[2]=='u')
  998. X           { unlink(ma);break;
  999. X           }
  1000. X          if(cp[2]=='l')
  1001. X           { cp=ma;goto stilv;
  1002. X           }
  1003. X          goto eusg;
  1004. X        }
  1005. X       default:
  1006. X          if(cp[1]-'0'>(unsigned)9)
  1007. Xeusg:           { putse(usage);retval=EX_USAGE;goto lfailure;
  1008. X           }
  1009. X          if(sleepsec>=0)
  1010. X         sleepsec=strtol(cp+1,(char**)0,10);
  1011. X     }
  1012. X     else if(sleepsec<0)
  1013. X    unlink(cp);
  1014. X     else
  1015. X      { time_t t;
  1016. X    setgid(getgid());setuid(uid);
  1017. Xstilv:    virgin=1;
  1018. X    while(0>NFSxopen(cp,&t))
  1019. X     { struct stat buf;
  1020. X       if(exitflag||retries==1)
  1021. Xlfailure:   { sleepsec= -1;argc=p-argv-1;goto again;
  1022. X        }
  1023. X       if(force&&!stat(cp,&buf)&&force<t-buf.st_mtime)
  1024. X        { unlink(cp);putse("lockfile: Forcing lock on \"");putse(cp);
  1025. X          putse("\"\n");sleep(suspend);
  1026. X        }
  1027. X       else
  1028. X          sleep(sleepsec);
  1029. X       if(retries)
  1030. X          retries--;
  1031. X     }
  1032. X      }
  1033. X  return retval?retval:invert^(sleepsec<0)?EX_CANTCREAT:EX_OK;
  1034. X}
  1035. X
  1036. Xputse(a)char*a;
  1037. X{ char*b;
  1038. X  b=a-1;
  1039. X  while(*++b);
  1040. X  write(STDERR,a,(size_t)(b-a));
  1041. X}
  1042. X
  1043. XNFSxopen(name,tim)char*name;time_t*const tim;
  1044. X{ char*p,*q;int j= -1,i;struct stat stbuf;
  1045. X  for(q=name;p=strpbrk(q,dirsep);q=p+1);
  1046. X  i=q-name;
  1047. X  if(!(p=malloc(i+UNIQnamelen)))
  1048. X     return exitflag=1;
  1049. X  strncpy(p,name,i);
  1050. X  if(unique(p,p+i,0))
  1051. X     stat(p,&stbuf),*tim=stbuf.st_mtime,j=myrename(p,name);
  1052. X  free(p);return j;
  1053. X}
  1054. X
  1055. Xvoid*tmalloc(len)const size_t len;                     /* stub */
  1056. X{ return malloc(len);
  1057. X}
  1058. X
  1059. Xropen(name,mode,mask)const char*const name;const int mode;const mode_t mask;
  1060. X{ return open(name,mode,mask);                         /* stub */
  1061. X}
  1062. X
  1063. Xrclose(fd)const int fd;                             /* stub */
  1064. X{ return close(fd);
  1065. X}
  1066. X
  1067. Xwriteerr(a)const char*const a;                         /* stub */
  1068. X{
  1069. X}
  1070. END_OF_FILE
  1071. if test 3742 -ne `wc -c <'procmail/lockfile.c'`; then
  1072.     echo shar: \"'procmail/lockfile.c'\" unpacked with wrong size!
  1073. fi
  1074. # end of 'procmail/lockfile.c'
  1075. fi
  1076. if test ! -d 'procmail/man' ; then
  1077.     echo shar: Creating directory \"'procmail/man'\"
  1078.     mkdir 'procmail/man'
  1079. fi
  1080. if test -f 'procmail/patchlevel.h' -a "${1}" != "-c" ; then 
  1081.   echo shar: Will not clobber existing file \"'procmail/patchlevel.h'\"
  1082. else
  1083. echo shar: Extracting \"'procmail/patchlevel.h'\" \(168 characters\)
  1084. sed "s/^X//" >'procmail/patchlevel.h' <<'END_OF_FILE'
  1085. X#define VERSION \
  1086. X"procmail v2.70 1992/04/30 written by Stephen R. van den Berg\n\
  1087. X\t\t\t\tberg@pool.informatik.rwth-aachen.de\n\
  1088. X\t\t\t\tberg@physik.tu-muenchen.de\n"
  1089. END_OF_FILE
  1090. if test 168 -ne `wc -c <'procmail/patchlevel.h'`; then
  1091.     echo shar: \"'procmail/patchlevel.h'\" unpacked with wrong size!
  1092. fi
  1093. # end of 'procmail/patchlevel.h'
  1094. fi
  1095. if test -f 'procmail/procmail.h' -a "${1}" != "-c" ; then 
  1096.   echo shar: Will not clobber existing file \"'procmail/procmail.h'\"
  1097. else
  1098. echo shar: Extracting \"'procmail/procmail.h'\" \(2987 characters\)
  1099. sed "s/^X//" >'procmail/procmail.h' <<'END_OF_FILE'
  1100. X/*$Id: procmail.h,v 2.19 1992/04/23 16:46:41 berg Rel $*/
  1101. X
  1102. X#include "includes.h"
  1103. X#include "exopen.h"
  1104. X#include "strpbrk.h"
  1105. X
  1106. Xtypedef unsigned char uschar;         /* sometimes uchar is already typedef'd */
  1107. X#ifdef uchar
  1108. X#undef uchar
  1109. X#endif
  1110. X#define uchar uschar
  1111. X
  1112. X#ifdef console
  1113. X#define vconsole (verbose=1,console)
  1114. X#else
  1115. X#define vconsole devnull
  1116. X#endif
  1117. X
  1118. X#ifndef DEFsendmail
  1119. X#define DEFsendmail SENDMAIL
  1120. X#endif
  1121. X
  1122. X#ifndef SYSTEM_MBOX
  1123. X#define SYSTEM_MBOX    SYSTEM_MAILBOX
  1124. X#endif
  1125. X
  1126. X#ifdef sMAILBOX_SEPARATOR
  1127. X#define smboxseparator(fd)    \
  1128. X (tofolder?rwrite(fd,sMAILBOX_SEPARATOR,STRLEN(sMAILBOX_SEPARATOR)):0)
  1129. X#define emboxseparator(fd)    \
  1130. X (tofolder?rwrite(fd,eMAILBOX_SEPARATOR,STRLEN(eMAILBOX_SEPARATOR)):0)
  1131. X#else
  1132. X#define smboxseparator(fd)
  1133. X#define emboxseparator(fd)
  1134. X#endif
  1135. X
  1136. X#ifndef KERNEL_LOCKS
  1137. X#define fdlock(fd)    0
  1138. X#define fdunlock()    0
  1139. X#else
  1140. X#ifndef SYS_FILE_H_MISSING
  1141. X#include <sys/file.h>
  1142. X#endif
  1143. X#endif
  1144. X
  1145. X#define XTRAlinebuf    2         /* surplus of LINEBUF (see readparse()) */
  1146. X#define TMNATE        '\377'             /* terminator (see readoarse()) */
  1147. X
  1148. X#define PRDO    poutfd[0]
  1149. X#define PWRO    poutfd[1]
  1150. X#define PRDI    pinfd[0]
  1151. X#define PWRI    pinfd[1]
  1152. X#define PRDB    pbackfd[0]
  1153. X#define PWRB    pbackfd[1]
  1154. X#define LENoffset    (TABWIDTH*LENtSTOP)
  1155. X#define MAXfoldlen    (LENoffset-STRLEN(sfolder)-1)
  1156. X#define MCDIRSEP    (dirsep+STRLEN(dirsep)-1)      /* most common DIRSEP */
  1157. X
  1158. X#define lck_LOCKFILE    1      /* crosscheck the order of this with msg[] */
  1159. X#define lck_ALLOCLIB    2              /* in sterminate() in retint.c */
  1160. X#define lck_MEMORY    4
  1161. X#define lck_FORK    8
  1162. X#define lck_FILDES    16
  1163. X#define lck_KERNELL    32
  1164. X
  1165. Xstruct varval{const char*const name;long val;};
  1166. X#define locksleep    (strenvvar[0].val)
  1167. X#define locktimeout    (strenvvar[1].val)
  1168. X#define suspendv    (strenvvar[2].val)
  1169. X#define noresretry    (strenvvar[3].val)
  1170. X#define timeoutv    (strenvvar[4].val)
  1171. X#define MAXvarvals    maxindex(strenvvar)
  1172. X
  1173. X#ifndef MAIN
  1174. Xextern char*buf,*buf2,*globlock,*loclock,*tolock,*lastfolder;
  1175. Xextern const char shellflags[],shell[],lockext[],newline[],binsh[],
  1176. X unexpeof[],shellmetas[],*const*gargv,*sgetcp,*rcfile,dirsep[],msgprefix[],
  1177. X devnull[],executing[],oquote[],cquote[],whilstwfor[],procmailn[],Mail[];
  1178. Xextern struct varval strenvvar[];
  1179. Xextern long lastdump;
  1180. Xextern sh,pwait,retval,retvl2,lcking,locknext,verbose,linebuf,rc,tofolder,
  1181. X tofile,ignwerr,fakedelivery;
  1182. Xextern volatile nextexit;
  1183. Xextern volatile time_t alrmtime;
  1184. Xextern pid_t thepid,pidchild;
  1185. X#endif
  1186. X
  1187. X#ifdef NOmemmove
  1188. Xvoid*smemmove();
  1189. X#endif
  1190. X#ifdef strtol
  1191. X#undef strtol
  1192. X#define NOstrtol
  1193. Xlong strtol();
  1194. X#endif
  1195. X
  1196. Xvoid*tmalloc(),*trealloc(),*bregcomp(),srequeue(),slose(),sbounce(),
  1197. X stermchild(),ftimeout();
  1198. Xpid_t sfork();
  1199. Xlong dump(),pipin(),renvint();
  1200. Xchar*readdyn(),*fromprog(),*cat(),*tstrdup(),*cstr(),*pstrspn(),
  1201. X *bregexec(),*egrepin();
  1202. Xconst char*tgetenv(),*hostname();
  1203. Xint sgetc(),getb();
  1204. X
  1205. X/*
  1206. X *    External variables that are checked/changed by the signal handlers:
  1207. X *    volatile time_t alrmtime;
  1208. X *    pid_t pidfilt,pidchild;
  1209. X *    volatile int nextexit;
  1210. X *    int lcking;
  1211. X *    static volatile mailread;    in procmail.c
  1212. X */
  1213. END_OF_FILE
  1214. if test 2987 -ne `wc -c <'procmail/procmail.h'`; then
  1215.     echo shar: \"'procmail/procmail.h'\" unpacked with wrong size!
  1216. fi
  1217. # end of 'procmail/procmail.h'
  1218. fi
  1219. if test -f 'procmail/recommend.c' -a "${1}" != "-c" ; then 
  1220.   echo shar: Will not clobber existing file \"'procmail/recommend.c'\"
  1221. else
  1222. echo shar: Extracting \"'procmail/recommend.c'\" \(2226 characters\)
  1223. sed "s/^X//" >'procmail/recommend.c' <<'END_OF_FILE'
  1224. X/************************************************************************
  1225. X *    recommend.c    analyses the installation, and makes        *
  1226. X *            recommendations about suid/sgid modes        *
  1227. X ************************************************************************/
  1228. X/*$Id: recommend.c,v 2.3 1992/04/29 15:54:33 berg Rel $*/
  1229. X#include "config.h"
  1230. X#include "includes.h"                       /* also for fprintf() */
  1231. X#include "strpbrk.h"
  1232. X
  1233. X#ifndef SYSTEM_MBOX
  1234. X#define SYSTEM_MBOX    SYSTEM_MAILBOX
  1235. X#endif
  1236. X
  1237. X#define PERMIS    (S_IRWXU|S_IRWXG&~S_IWGRP|S_IRWXO&~S_IWOTH)
  1238. X
  1239. Xchar system_mbox[]=SYSTEM_MBOX;
  1240. Xconst char dirsep[]=DIRSEP,
  1241. X *const checkf[]={"/bin/mail","/bin/lmail","/usr/lib/sendmail",
  1242. X "/usr/lib/smail",0};
  1243. X                 /* lastdirsep() has been lifted out of exopen.c */
  1244. Xchar*lastdirsep(filename)const char*filename;     /* finds the next character */
  1245. X{ const char*p;                    /* following the last DIRSEP */
  1246. X  while(p=strpbrk(filename,dirsep))
  1247. X     filename=p+1;
  1248. X  return(char*)filename;
  1249. X}
  1250. X
  1251. Xmain(argc,argv)const int argc;const char*const argv[];
  1252. X{ struct passwd*pass;struct group*grp;struct stat stbuf;
  1253. X  uid_t uid=ROOT_uid;gid_t gid=NOBODY_gid;const char*const*p;
  1254. X  mode_t suid=0,sgid=0;
  1255. X  if(argc!=3)
  1256. X   { fprintf(stderr,"Please run this program via 'make recommend'\n");
  1257. X     return EX_USAGE;
  1258. X   }
  1259. X  *lastdirsep(system_mbox)='\0';
  1260. X  for(p=checkf;*p;++p)
  1261. X     if(!stat(*p,&stbuf)&&stbuf.st_mode&(S_ISUID|S_ISGID))
  1262. X      { if(stbuf.st_mode&S_ISUID&&stbuf.st_uid!=ROOT_uid)
  1263. X       suid=S_ISUID,uid=stbuf.st_uid;
  1264. X    if(stbuf.st_mode&S_ISGID)
  1265. X       sgid=S_ISGID,gid=stbuf.st_gid;
  1266. X    break;
  1267. X      }
  1268. X  if(!stat(system_mbox,&stbuf)&&!(stbuf.st_mode&S_IWOTH))
  1269. X     if(stbuf.st_mode&S_IWGRP)
  1270. X    sgid=S_ISGID,gid=stbuf.st_gid;
  1271. X     else
  1272. X    suid=S_ISUID,uid=stbuf.st_uid;
  1273. X  if(gid!=stbuf.st_gid)
  1274. X     sgid=0;
  1275. X  printf("chown root %s\n",argv[1]);
  1276. X  if(suid)
  1277. X     if(pass=getpwuid(uid))
  1278. X    printf("chown %s %s\n",pass->pw_name,argv[2]);
  1279. X     else
  1280. X    printf("chown %u %s\n",(int)uid,argv[2]);
  1281. X  if(sgid)
  1282. X     if(grp=getgrgid(gid))
  1283. X    printf("chgrp %s %s %s\n",grp->gr_name,argv[1],argv[2]);
  1284. X     else
  1285. X    printf("chgrp %u %s %s\n",(int)gid,argv[1],argv[2]);
  1286. X  printf("chmod %o %s\n",sgid|S_ISUID|PERMIS,argv[1]);
  1287. X  if(suid||sgid)
  1288. X     printf("chmod %o %s\n",suid|sgid|PERMIS,argv[2]);
  1289. X  return EX_OK;
  1290. X}
  1291. END_OF_FILE
  1292. if test 2226 -ne `wc -c <'procmail/recommend.c'`; then
  1293.     echo shar: \"'procmail/recommend.c'\" unpacked with wrong size!
  1294. fi
  1295. # end of 'procmail/recommend.c'
  1296. fi
  1297. if test -f 'procmail/strpbrk.c' -a "${1}" != "-c" ; then 
  1298.   echo shar: Will not clobber existing file \"'procmail/strpbrk.c'\"
  1299. else
  1300. echo shar: Extracting \"'procmail/strpbrk.c'\" \(344 characters\)
  1301. sed "s/^X//" >'procmail/strpbrk.c' <<'END_OF_FILE'
  1302. X/*$Id: strpbrk.c,v 1.3 1992/04/23 16:46:41 berg Rel $*/
  1303. X#include "includes.h"
  1304. X#include "strpbrk.h"
  1305. X
  1306. X#ifdef NOstrpbrk
  1307. Xchar*strpbrk(st,del)const char*const st,*del;
  1308. X{ const char*f=0,*t;
  1309. X  for(f=0;*del;)
  1310. X     if((t=strchr(st,*del++))&&(!f||t<f))
  1311. X    f=t;
  1312. X  return(char*)f;
  1313. X}
  1314. X#else
  1315. Xchar dummy_strpbrk;            /* to keep some linkers from choking */
  1316. X#endif
  1317. END_OF_FILE
  1318. if test 344 -ne `wc -c <'procmail/strpbrk.c'`; then
  1319.     echo shar: \"'procmail/strpbrk.c'\" unpacked with wrong size!
  1320. fi
  1321. # end of 'procmail/strpbrk.c'
  1322. fi
  1323. echo shar: End of archive 1 \(of 5\).
  1324. cp /dev/null ark1isdone
  1325. MISSING=""
  1326. for I in 1 2 3 4 5 ; do
  1327.     if test ! -f ark${I}isdone ; then
  1328.     MISSING="${MISSING} ${I}"
  1329.     fi
  1330. done
  1331. if test "${MISSING}" = "" ; then
  1332.     echo You have unpacked all 5 archives.
  1333.     rm -f ark[1-9]isdone
  1334. else
  1335.     echo You still need to unpack the following archives:
  1336.     echo "        " ${MISSING}
  1337. fi
  1338. ##  End of shell archive.
  1339. exit 0
  1340. -- 
  1341. Sincerely,                                  berg@pool.informatik.rwth-aachen.de
  1342.            Stephen R. van den Berg (AKA BuGless).    berg@physik.tu-muenchen.de
  1343.  
  1344. "I have a *cunning* plan!"
  1345.  
  1346. exit 0 # Just in case...
  1347.