home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1994 October / usenetsourcesnewsgroupsinfomagicoctober1994disk2.iso / misc / volume43 / mailagent / patch09 < prev    next >
Encoding:
Internet Message Format  |  1994-07-24  |  45.3 KB

  1. From: Raphael Manfredi <ram@acri.fr>
  2. Newsgroups: comp.sources.misc
  3. Subject: v43i126:  mailagent - Flexible mail filtering and processing package, v3.0, Patch09
  4. Date: 24 Jul 1994 19:41:07 -0500
  5. Organization: Advanced Computer Research Institute, Lyon, France
  6. Sender: kent@sparky.sterling.com
  7. Approved: kent@sparky.sterling.com
  8. Message-ID: <30v1n3$i3v@sparky.sterling.com>
  9. X-Md4-Signature: 82b5bddbeb5b10db46a6f5a791c6438e
  10.  
  11. Submitted-by: Raphael Manfredi <ram@acri.fr>
  12. Posting-number: Volume 43, Issue 126
  13. Archive-name: mailagent/patch09
  14. Environment: UNIX, Perl
  15. Patch-To: mailagent: Volume 41, Issue 1-26
  16.  
  17. [The latest patch for mailagent version 3.0 is #11.]
  18.  
  19. System: mailagent version 3.0
  20. Patch #: 9
  21. Priority: LOW
  22. Subject: patch #8, continued
  23. Date: Fri Jul 01 17:27:43 MET DST 1994
  24. From: Raphael Manfredi <ram@acri.fr>
  25.  
  26. Description:
  27.     See patch #8.
  28.  
  29.  
  30. Fix:    From rn, say "| patch -p -N -d DIR", where DIR is your mailagent source
  31.     directory.  Outside of rn, say "cd DIR; patch -p -N <thisarticle".
  32.     If you don't have the patch program, apply the following by hand,
  33.     or get patch (version 2.0, latest patchlevel).
  34.  
  35.     After patching:
  36.         *** DO NOTHING--INSTALL ALL PATCHES UP THROUGH #11 FIRST ***
  37.  
  38.     If patch indicates that patchlevel is the wrong version, you may need
  39.     to apply one or more previous patches, or the patch may already
  40.     have been applied.  See the patchlevel.h file to find out what has or
  41.     has not been applied.  In any event, don't continue with the patch.
  42.  
  43.     If you are missing previous patches they can be obtained from me:
  44.  
  45.         Raphael Manfredi <ram@acri.fr>
  46.  
  47.     If you send a mail message of the following form it will greatly speed
  48.     processing:
  49.  
  50.         Subject: Command
  51.         @SH mailpatch PATH mailagent 3.0 LIST
  52.                ^ note the c
  53.  
  54.     where PATH is a return path FROM ME TO YOU either in Internet notation,
  55.     or in bang notation from some well-known host, and LIST is the number
  56.     of one or more patches you need, separated by spaces, commas, and/or
  57.     hyphens.  Saying 35- says everything from 35 to the end.
  58.  
  59.     To get some more detailed instructions, send me the following mail:
  60.  
  61.         Subject: Command
  62.         @SH mailhelp PATH
  63.  
  64.  
  65. Index: patchlevel.h
  66. Prereq: 8
  67. 4c4
  68. < #define PATCHLEVEL 8
  69. ---
  70. > #define PATCHLEVEL 9
  71.  
  72. Index: agent/man/mailagent.SH
  73. Prereq: 3.0.1.3
  74. *** agent/man/mailagent.SH.old    Fri Jul  1 17:16:09 1994
  75. --- agent/man/mailagent.SH    Fri Jul  1 17:16:10 1994
  76. ***************
  77. *** 20,26 ****
  78.   .TH MAILAGENT $manext "Version $VERSION PL$PATCHLEVEL"
  79.   ''' @(#) Manual page for mailagent's filter -- (c) ram February 1991
  80.   '''
  81. ! ''' $Id: mailagent.SH,v 3.0.1.3 1994/04/25 15:15:56 ram Exp $
  82.   '''
  83.   '''  Copyright (c) 1990-1993, Raphael Manfredi
  84.   '''  
  85. --- 20,26 ----
  86.   .TH MAILAGENT $manext "Version $VERSION PL$PATCHLEVEL"
  87.   ''' @(#) Manual page for mailagent's filter -- (c) ram February 1991
  88.   '''
  89. ! ''' $Id: mailagent.SH,v 3.0.1.4 1994/07/01 14:56:20 ram Exp $
  90.   '''
  91.   '''  Copyright (c) 1990-1993, Raphael Manfredi
  92.   '''  
  93. ***************
  94. *** 31,36 ****
  95. --- 31,42 ----
  96.   '''  of the source tree for mailagent 3.0.
  97.   '''
  98.   ''' $Log: mailagent.SH,v $
  99. + ''' Revision 3.0.1.4  1994/07/01  14:56:20  ram
  100. + ''' patch8: documents new eleven configuration variables
  101. + ''' patch8: sub-section on timeouts has been expanded
  102. + ''' patch8: emphasize .forward optimization danger with sendmail
  103. + ''' patch8: new UMASK command
  104. + '''
  105.   ''' Revision 3.0.1.3  1994/04/25  15:15:56  ram
  106.   ''' patch7: documented new 'fromesc' config variable
  107.   ''' patch7: forgot to insert the new -F option in the synopsis line
  108. ***************
  109. *** 230,235 ****
  110. --- 236,250 ----
  111.   Name of the directory which should be used for dumps, preferably. This is
  112.   optional. (suggested: ~/tmp/lost+mail)
  113.   .TP
  114. + .I fromall
  115. + Whether or not \fImailagent\fR should escape all the \fIFrom\fR lines in the
  116. + message, not only those it thinks should appear dangerous (i.e. a \fIFrom\fR
  117. + after a blank line). This option only makes sense when \fIfromesc\fR is
  118. + also activated. It is ignored otherwise, and therefore is optional. By
  119. + default, it is assumed to be OFF. (suggested: OFF, until you have reasons to
  120. + believe your mail user-agent is confused in this mode: when it happens, your
  121. + user agent will split mail for no apparent reason).
  122. + .TP
  123.   .I fromesc
  124.   Whether or not \fImailagent\fR should escape potentially dangerous \fIFrom\fR
  125.   lines in mail messages. If you use MH or if your mail reader does not use
  126. ***************
  127. *** 251,256 ****
  128. --- 266,282 ----
  129.   .I level
  130.   Log level, see below for a definition of available levels (suggested: 9).
  131.   .TP
  132. + .I lockdekay
  133. + The delay in seconds between two locking attempts. (optional, defaults to: 2).
  134. + .TP
  135. + .I lockhold
  136. + The maximum delay in seconds for holding a lock. After that time, the lock
  137. + will be broken. (optional, defaults to: 3600)
  138. + .TP
  139. + .I lockmax
  140. + Maximum number of locking attempts before giving up. (optional,
  141. + defaults to: 20).
  142. + .TP
  143.   .I log
  144.   Name of the log file, put in Log directory. (suggested: agentlog).
  145.   .TP
  146. ***************
  147. *** 374,389 ****
  148. --- 400,435 ----
  149.   Queue directory (messages waiting to be processed). Required, of course.
  150.   (suggested: \$spool/queue)
  151.   .TP
  152. + .I queuehold
  153. + Maximum number of seconds a mail can sit in the mailagent queue before being
  154. + actually processed. During that time, \fImailagent\fR will not try to
  155. + process the message even when \fB\-q\fR is used. (optional, defaults to: 1800).
  156. + .TP
  157. + .I queuelost
  158. + Maximum number of seconds after which \fImailagent\fR should flag messages
  159. + still in its queue as being old. (optional, defaults to: 86400, i.e. a day).
  160. + .TP
  161. + .I queuewait
  162. + Time in seconds telling the C \fIfilter\fR program how long it must wait
  163. + before launching \fImailagent\fR. (optional, defaults to: 60).
  164. + .TP
  165.   .I rulecache
  166.   The name of the file used to cache the latest compiled rules. Since usually
  167.   \fImailagent\fR works mainly with one same rule file, this saves the overhead
  168.   of recompiling all the rules each time. (optional, suggested:
  169.   \$spool/rulecache).
  170.   .TP
  171. + .I rulemac
  172. + Set this to ON to enable macro substitutions in rule patterns.
  173. + (optional, defaults to: OFF).
  174. + .TP
  175.   .I rules
  176.   The name of the file holding the filtering rules (optional,
  177.   suggested: ~/.rules).
  178.   .TP
  179. + .I runmax
  180. + Timeout for RUN commands and friends. (optional, defaults to: 3600).
  181. + .TP
  182.   .I scriptcc
  183.   Flag indicating whether a copy of the SERVER session transcript should be
  184.   send to the user running mailagent. (suggested: OFF).
  185. ***************
  186. *** 418,423 ****
  187. --- 464,476 ----
  188.   File where statistics should be gathered. If no such file exists, no
  189.   statistics will be recorded (suggested: mailagent.st).
  190.   .TP
  191. + .I tome
  192. + This optional variable may contain a comma separated list of alternate logins
  193. + that are also valid for the user (mail aliases). This is used in vacation
  194. + mode to check whether the mail was sent to the user or to a mailing list.
  195. + If you have an alias like \fIFirst.Name\fR, then specify \fIname\fR only,
  196. + since \fImailagent\fR reduces the login name to the family name.
  197. + .TP
  198.   .I track
  199.   Set to \fIon\fR (case insensitively), this turns on the \fB\-t\fR option
  200.   which tracks all the rule matches and the actions on standard output. This
  201. ***************
  202. *** 429,434 ****
  203. --- 482,493 ----
  204.   .I tmpdir
  205.   Directory for temporary files. Required (suggested: /tmp).
  206.   .TP
  207. + .I umask
  208. + Default umask which is reset by \fImailagent\fR before processing a message.
  209. + Assumed to be decimal unless starting with '0' (for octal) or '0x' (for
  210. + hexadecimal). The octal format is the easiest way to specify it nonetheless.
  211. + (optional, defaults to: 077).
  212. + .TP
  213.   .I user
  214.   Login name of the user who runs the mailagent. This sets the value of the
  215.   %u macro.
  216. ***************
  217. *** 478,483 ****
  218. --- 537,552 ----
  219.   be necessary to move the '|' character before the leading quote, but don't
  220.   try this unless you have no other choice (i.e. only as a last resort).
  221.   .PP
  222. + It is \fIvery\fR important to redirect error messages to some file within
  223. + your home directory. For one thing, that will get you out of trouble if
  224. + strange things start to happen, but more to the point, it makes
  225. + your \fI.forward\fR file unique. Older \fIsendmail\fR program, in an heroic
  226. + attempt to "optimize" delivery, will silently remove duplicate recipients,
  227. + and if a recipient has a \fI.forward\fR, its litteral content is used in place
  228. + of his e-mail address. Therefore, two local recipients with the same
  229. + filtering string will be considered as one unique recipient and only one
  230. + of them will get the message...
  231. + .PP
  232.   Note that the \fI.forward\fR file only pipes the mail to the \fIfilter\fR
  233.   program and does not leave any copy in the mailbox. It is up to you to decide
  234.   in the rule file whether you want to trash the mail away or leave it in the
  235. ***************
  236. *** 641,646 ****
  237. --- 710,719 ----
  238.   .B \-l
  239.   List the mailagent queue. Recently queued mails which are waited for by the
  240.   \fIfilter\fR are \fIskipped\fR for about half an hour, to avoid race conditions.
  241. + This may be configured via the \fIqueuehold\fR variable. Really old messages
  242. + (more than \fIqueuelost\fR seconds old) are flagged with a '#' character.
  243. + Messages out of the queue (\fIqueue\fR variable) are flagged with a '*', whilst
  244. + old messages out of the queue are signaled by an '@'.
  245.   .TP
  246.   .B \-L\fI level\fR
  247.   Override the log level specified in the configuration file.
  248. ***************
  249. *** 1605,1610 ****
  250. --- 1678,1693 ----
  251.   lowercase. See also ASSIGN and SUBST.
  252.   (Fails if error in \fItranslation\fR)
  253.   .TP
  254. + UMASK [-l] \fImode\fR
  255. + Changes the process's umask to the specified \fImode\fR, which can be decimal,
  256. + octal (if preceded by '0') or hexadecimal (starting with '0x'). The octal
  257. + notation is the clearest way to specify the umask anyway. Aren't rumors saying
  258. + that octal was invented for that purpose only? ;-)
  259. + Use the \fB\-l\fR option to change the umask for the duration of the current
  260. + action rule only. Note that the default umask specified in your config file
  261. + is used to reset \fImailagent\fR's umask at the start of each mail processing.
  262. + (Does not alter execution status)
  263. + .TP
  264.   UNIQUE [-acr] [\fImode\fR] [\fI(tag-list)\fR]
  265.   Record message in the history and tag message as saved if it was
  266.   already present there. If the message is recorded for the first time, processing
  267. ***************
  268. *** 1740,1746 ****
  269.   .I @ARGV
  270.   The arguments of the script, which were given by the PERL command. This array
  271.   is set up the exact same way you would expect it to be set up if you invoked
  272. ! the command directly from the shell.
  273.   .TP
  274.   .I \$address
  275.   The address part of the From: line.
  276. --- 1823,1832 ----
  277.   .I @ARGV
  278.   The arguments of the script, which were given by the PERL command. This array
  279.   is set up the exact same way you would expect it to be set up if you invoked
  280. ! the command directly from the shell, excepted that
  281. ! .I @ARGV[0]
  282. ! is the name of the script (since you cannot use perl's \fI\$0\fR to get
  283. ! at it; that would give you mailagent's name).
  284.   .TP
  285.   .I \$address
  286.   The address part of the From: line.
  287. ***************
  288. *** 2225,2234 ****
  289.   .SS "Timeouts"
  290.   .PP
  291.   In order to avoid having a \fImailagent\fR waiting for a command forever, a
  292. ! maximum execution time of one hour is allowed. Past that amount of time, the
  293.   child is sent a SIGTERM signal. If it does not die within the next 30 seconds,
  294.   a SIGKILL is sent. Output from the program, if any so far, is mailed back to
  295.   the user.
  296.   '''
  297.   .SS "Avoiding Loops"
  298.   .PP
  299. --- 2311,2351 ----
  300.   .SS "Timeouts"
  301.   .PP
  302.   In order to avoid having a \fImailagent\fR waiting for a command forever, a
  303. ! maximum execution time of one hour is allowed by default.
  304. ! Past that amount of time, the
  305.   child is sent a SIGTERM signal. If it does not die within the next 30 seconds,
  306.   a SIGKILL is sent. Output from the program, if any so far, is mailed back to
  307.   the user.
  308. + This default behaviour may be altered by setting a proper \fIrunmax\fR variable
  309. + in your configuration file to allow more time for the command to complete.
  310. + .PP
  311. + There is also a \fIfilter\fR queue timeout. In order to moderate system load,
  312. + the C \fIfilter\fR program waits 60 seconds by default (or whatever
  313. + .I queuewait
  314. + was set to in the config file) before launching \fImailagent\fR. To avoid
  315. + conflicts, messages queued by the first filter (which will then sleep for
  316. + .I queuewait
  317. + seconds) are not processed by \fImailagent\fR's \fB\-q\fR option until they
  318. + are at least
  319. + .I queuehold
  320. + seconds old. Another queue-related parameter is
  321. + .I queuelost,
  322. + the amount of seconds after which \fImailagent\fR will flag messages as "lost"
  323. + when listing the queue.
  324. + .PP
  325. + Finally, the locking timeout policy may also be configured. By default, a
  326. + lock is broken when it is one hour old (configured by the
  327. + .I lockhold
  328. + variable) and \fImailagent\fR will only make
  329. + .I lockmax
  330. + attempts, spaced by
  331. + .I lockdelay
  332. + seconds to acquire the lock. It will then proceed whether or not it got that
  333. + lock. If you want a secure locking policy, make sure
  334. + .I lockmax
  335. + times
  336. + .I lockdelay
  337. + is greater than \fIlockhold\fR, that parameter being "large" enough.
  338.   '''
  339.   .SS "Avoiding Loops"
  340.   .PP
  341.  
  342. Index: agent/pl/actions.pl
  343. Prereq: 3.0.1.2
  344. *** agent/pl/actions.pl.old    Fri Jul  1 17:16:13 1994
  345. --- agent/pl/actions.pl    Fri Jul  1 17:16:14 1994
  346. ***************
  347. *** 1,4 ****
  348. ! ;# $Id: actions.pl,v 3.0.1.2 1994/04/25 15:16:53 ram Exp $
  349.   ;#
  350.   ;#  Copyright (c) 1990-1993, Raphael Manfredi
  351.   ;#  
  352. --- 1,4 ----
  353. ! ;# $Id: actions.pl,v 3.0.1.3 1994/07/01 14:57:49 ram Exp $
  354.   ;#
  355.   ;#  Copyright (c) 1990-1993, Raphael Manfredi
  356.   ;#  
  357. ***************
  358. *** 9,14 ****
  359. --- 9,18 ----
  360.   ;#  of the source tree for mailagent 3.0.
  361.   ;#
  362.   ;# $Log: actions.pl,v $
  363. + ;# Revision 3.0.1.3  1994/07/01  14:57:49  ram
  364. + ;# patch8: timeout for RUN commands now defined by runmax config variable
  365. + ;# patch8: now systematically escape leading From if fromall is ON
  366. + ;#
  367.   ;# Revision 3.0.1.2  1994/04/25  15:16:53  ram
  368.   ;# patch7: here and there fixes
  369.   ;# patch7: global fix for From line escapes to make them configurable
  370. ***************
  371. *** 813,819 ****
  372.       $program =~ s/\b~/$cf'home/g;    # ~ substitution as first letter in word
  373.       $SIG{'PIPE'} = 'popen_failed';    # Protect against naughty program
  374.       $SIG{'ALRM'} = 'alarm_clock';    # Protect against loops
  375. !     alarm 3600;                        # At most one hour of processing
  376.       eval '&execute_command($program, $input, $feedback)';
  377.       alarm 0;                        # Disable alarm timeout
  378.       $SIG{'PIPE'} = 'emergency';        # Restore initial value
  379. --- 817,823 ----
  380.       $program =~ s/\b~/$cf'home/g;    # ~ substitution as first letter in word
  381.       $SIG{'PIPE'} = 'popen_failed';    # Protect against naughty program
  382.       $SIG{'ALRM'} = 'alarm_clock';    # Protect against loops
  383. !     alarm $cf'runmax;                # At most that amount of processing
  384.       eval '&execute_command($program, $input, $feedback)';
  385.       alarm 0;                        # Disable alarm timeout
  386.       $SIG{'PIPE'} = 'emergency';        # Restore initial value
  387. ***************
  388. *** 828,834 ****
  389.           &add_log("WARNING no feedback occurred") if $loglvl > 5;
  390.           return 1;                    # Failed
  391.       } elsif ($@ =~ /^alarm/) {        # Timeout
  392. !         &add_log("WARNING time out received") if $loglvl > 5;
  393.           return 1;                    # Failed
  394.       } elsif ($@ =~ /^non-zero/) {    # Program returned non-zero status
  395.           &add_log("WARNING program returned non-zero status") if $loglvl > 5;
  396. --- 832,839 ----
  397.           &add_log("WARNING no feedback occurred") if $loglvl > 5;
  398.           return 1;                    # Failed
  399.       } elsif ($@ =~ /^alarm/) {        # Timeout
  400. !         &add_log("WARNING time out received ($cf'runmax seconds)")
  401. !             if $loglvl > 5;
  402.           return 1;                    # Failed
  403.       } elsif ($@ =~ /^non-zero/) {    # Program returned non-zero status
  404.           &add_log("WARNING program returned non-zero status") if $loglvl > 5;
  405. ***************
  406. *** 1009,1017 ****
  407.       local($last_was_nl) = 1;            # True when previous line was blank
  408.       if ($input == $BODY_INPUT) {        # We have to feed back the body only
  409.           while (<TRACE>) {
  410. !             # Protect potentially dangerous lines
  411.               s/^From(\s)/>From$1/ if $last_was_nl && $cf'fromesc =~ /on/i;
  412. !             $last_was_nl = /^$/;
  413.               $temp .= $_;
  414.           }
  415.       } else {
  416. --- 1014,1024 ----
  417.       local($last_was_nl) = 1;            # True when previous line was blank
  418.       if ($input == $BODY_INPUT) {        # We have to feed back the body only
  419.           while (<TRACE>) {
  420. !             # Protect potentially dangerous lines. If fromall is ON, then we
  421. !             # don't care whether From is within a paragraph, i.e. not preceded
  422. !             # by a blank line. This is only required with "broken" User Agents.
  423.               s/^From(\s)/>From$1/ if $last_was_nl && $cf'fromesc =~ /on/i;
  424. !             $last_was_nl = /^$/ || $cf'fromall =~ /on/i;
  425.               $temp .= $_;
  426.           }
  427.       } else {
  428. ***************
  429. *** 1023,1029 ****
  430.               } else {
  431.                   # Protect potentially dangerous lines
  432.                   s/^From(\s)/>From$1/ if $last_was_nl && $cf'fromesc =~ /on/i;
  433. !                 $last_was_nl = /^$/;
  434.                   $temp .= $_;
  435.               }
  436.           }
  437. --- 1030,1036 ----
  438.               } else {
  439.                   # Protect potentially dangerous lines
  440.                   s/^From(\s)/>From$1/ if $last_was_nl && $cf'fromesc =~ /on/i;
  441. !                 $last_was_nl = /^$/ || $cf'fromall =~ /on/i;
  442.                   $temp .= $_;
  443.               }
  444.           }
  445. ***************
  446. *** 1381,1387 ****
  447.           # Protect potentially dangerous lines
  448.           s/^From\s+(\S+)/>From $1/ if $last_was_space && $cf'fromesc =~ /on/i;
  449.           s/^- -/-/;                    # This is the EB escape in RFC-934
  450. !         $last_was_space = /^$/;        # From is dangerous after blank line
  451.       }
  452.       # Now @array holds the whole digest item
  453.       if ($folder =~ /^\s*$/) {        # No folder means we have to queue message
  454. --- 1388,1395 ----
  455.           # Protect potentially dangerous lines
  456.           s/^From\s+(\S+)/>From $1/ if $last_was_space && $cf'fromesc =~ /on/i;
  457.           s/^- -/-/;                    # This is the EB escape in RFC-934
  458. !         # From is dangerous after blank line, but everywhere if fromall is ON.
  459. !         $last_was_space = /^$/ || $cf'fromall =~ /on/i;
  460.       }
  461.       # Now @array holds the whole digest item
  462.       if ($folder =~ /^\s*$/) {        # No folder means we have to queue message
  463.  
  464. Index: agent/pl/analyze.pl
  465. Prereq: 3.0.1.2
  466. *** agent/pl/analyze.pl.old    Fri Jul  1 17:16:15 1994
  467. --- agent/pl/analyze.pl    Fri Jul  1 17:16:15 1994
  468. ***************
  469. *** 1,4 ****
  470. ! ;# $Id: analyze.pl,v 3.0.1.2 1994/04/25 15:17:24 ram Exp $
  471.   ;#
  472.   ;#  Copyright (c) 1990-1993, Raphael Manfredi
  473.   ;#  
  474. --- 1,4 ----
  475. ! ;# $Id: analyze.pl,v 3.0.1.3 1994/07/01 14:59:58 ram Exp $
  476.   ;#
  477.   ;#  Copyright (c) 1990-1993, Raphael Manfredi
  478.   ;#  
  479. ***************
  480. *** 9,14 ****
  481. --- 9,20 ----
  482.   ;#  of the source tree for mailagent 3.0.
  483.   ;#
  484.   ;# $Log: analyze.pl,v $
  485. + ;# Revision 3.0.1.3  1994/07/01  14:59:58  ram
  486. + ;# patch8: general umask is now reset before analyzing a message
  487. + ;# patch8: added support for the UMASK command for local rule scope
  488. + ;# patch8: now parses the new tome config variable for vacation messages
  489. + ;# patch8: disable vacation message if Illegal-Object or Illegal-Field header
  490. + ;#
  491.   ;# Revision 3.0.1.2  1994/04/25  15:17:24  ram
  492.   ;# patch7: fixed selector combination logic and added some debug logs
  493.   ;#
  494. ***************
  495. *** 60,65 ****
  496. --- 66,74 ----
  497.       local($vacation) = 1;        # Vacation message allowed a priori
  498.       local($header);                # Header entry name to look for in Header table
  499.   
  500. +     # Reset umask
  501. +     umask($cf'umask);
  502.       # Parse the mail message in file
  503.       &parse_mail($file);            # Parse the mail and fill-in H tables
  504.       return 0 unless defined $Header{'All'};        # Mail not parsed correctly
  505. ***************
  506. *** 190,196 ****
  507.           undef %Inverted;                        # Reset negated patterns
  508.           $rules = $_;                            # Work on a copy
  509.           $rules =~ s/^([^{]*){// && ($mode = $1);    # First word is the mode
  510. !         $rules =~ s/\s*(.*)}// && ($action = $1);    # Followed by action
  511.           $mode =~ s/\s*$//;                            # Remove trailing spaces
  512.           $rules =~ s/^\s+//;                        # Remove leading spaces
  513.           $last_selector = "";                    # Last selector used
  514. --- 199,205 ----
  515.           undef %Inverted;                        # Reset negated patterns
  516.           $rules = $_;                            # Work on a copy
  517.           $rules =~ s/^([^{]*){// && ($mode = $1);    # First word is the mode
  518. !         $rules =~ s/\s*(.*)}// && ($action = $1);    # Followed by action }
  519.           $mode =~ s/\s*$//;                            # Remove trailing spaces
  520.           $rules =~ s/^\s+//;                        # Remove leading spaces
  521.           $last_selector = "";                    # Last selector used
  522. ***************
  523. *** 291,297 ****
  524. --- 300,310 ----
  525.               &add_log("MATCH on rule #$j in mode $wmode") if $loglvl > 8;
  526.               &track_rule($j, $wmode) if $track_all;
  527.               &s_match($j, $wmode) if $stats;    # Record match for statistics
  528. +             &u_mask'init;    # Built-in support for local umask setting
  529.               $status = &xeqte($action);
  530. +             &u_mask'reset;    # Restore previous umask if set locally in rules
  531.               last rule if $status == $FT_CONT;
  532.               $ever_matched = 0;                # No match if REJECT or RESTART
  533.               next rule if $status == $FT_REJECT;
  534. ***************
  535. *** 344,360 ****
  536. --- 357,398 ----
  537.       # was sent to the user directly, through a 'To:' or a 'Cc:'. Otherwise,
  538.       # it must be from a mailing list or a 'Bcc:' and we don't want to
  539.       # send something back in that case.
  540.       local($matched) = &match_list("To", $cf'user);
  541.       $matched = &match_list("Cc", $cf'user) unless $matched;
  542. +     # Try alternate login names, in case they used a company-wide alias like
  543. +     # First.Last or simply a plain sendmail alias.
  544. +     if (!$matched && $cf'tome ne '') {
  545. +         foreach $addr (split(/\s*,\s*/, $cf'tome)) {
  546. +             $matched = &match_list('To', $addr);
  547. +             $matched = &match_list('Cc', $addr) unless $matched;
  548. +             if ($matched) {
  549. +                 &add_log("mail was sent to alternate $addr") if $loglvl > 8;
  550. +                 last;
  551. +             } else {
  552. +                 &add_log("mail wasn't sent to alternate $addr") if $loglvl > 12;
  553. +             }
  554. +         }
  555. +     }
  556.       unless ($matched) {
  557.           &add_log("mail was not directly sent to $cf'user") if $loglvl > 8;
  558.           return 1;
  559.       }
  560.       # If there is a Precedence: header set to either 'bulk', 'list' or 'junk',
  561.       # then we do not reply either.
  562.       local($prec) = $Header{'Precedence'};
  563.       if ($prec =~ /^bulk|junk|list/i) {
  564.           &add_log("mail was tagged with a '$prec' precedence") if $loglvl > 8;
  565. +         return 1;
  566. +     }
  567. +     # If there is an RFC-886 Illegal-Object or Illegal-Field header, do not
  568. +     # trust the whole header integrity, and therefore do not reply.
  569. +     if ($Header{'Illegal-Object'} ne '' || $Header{'Illegal-Field'} ne '') {
  570. +         &add_log("mail was received with header errors") if $loglvl > 8;
  571.           return 1;
  572.       }
  573.       # Make sure the mail does not come from a "special" user, as listed in
  574.  
  575. Index: agent/test/cmd/vacation.t
  576. Prereq: 3.0
  577. *** agent/test/cmd/vacation.t.old    Fri Jul  1 17:16:28 1994
  578. --- agent/test/cmd/vacation.t    Fri Jul  1 17:16:28 1994
  579. ***************
  580. *** 1,6 ****
  581.   # The VACATION command
  582.   
  583. ! # $Id: vacation.t,v 3.0 1993/11/29 13:49:55 ram Exp $
  584.   #
  585.   #  Copyright (c) 1990-1993, Raphael Manfredi
  586.   #  
  587. --- 1,6 ----
  588.   # The VACATION command
  589.   
  590. ! # $Id: vacation.t,v 3.0.1.1 1994/07/01 15:09:13 ram Exp $
  591.   #
  592.   #  Copyright (c) 1990-1993, Raphael Manfredi
  593.   #  
  594. ***************
  595. *** 11,16 ****
  596. --- 11,20 ----
  597.   #  of the source tree for mailagent 3.0.
  598.   #
  599.   # $Log: vacation.t,v $
  600. + # Revision 3.0.1.1  1994/07/01  15:09:13  ram
  601. + # patch8: added check for no vacation when Illegal-Object or Illegal-Field
  602. + # patch8: make sure the new tome config variable is honored
  603. + #
  604.   # Revision 3.0  1993/11/29  13:49:55  ram
  605.   # Baseline for mailagent 3.0 netwide release.
  606.   #
  607. ***************
  608. *** 19,24 ****
  609. --- 23,33 ----
  610.   do '../pl/mta.pl';
  611.   unlink $user, 'dbr/c/o';
  612.   
  613. + sub cleanup {
  614. +     unlink 'send.mail', $user;
  615. + }
  616. + `rm -rf dbr`;        # Enable vacation messages
  617.   &add_option("-o 'vacation: ON' -o 'user: ram'");
  618.   
  619.   open(VACATION, '>.vacation') || print "1\n";
  620. ***************
  621. *** 39,50 ****
  622.   &check_log('^Recipients: compilers-request@iecc', 9) == 1 || print "10\n";
  623.   &check_log('^Sent by compilers-request.$', 11) == 1 || print "12\n";
  624.   
  625. ! unlink 'send.mail', $user;
  626.   `$cmd`;                            # This time, no vacation message
  627.   $? == 0 || print "13\n";
  628. ! -f "$user" || print "14\n";        # Mail not saved
  629. ! -f 'send.mail' && print "15\n";
  630.   
  631.   &clear_mta;
  632.   unlink 'mail', '.vacation';
  633.   print "0\n";
  634. --- 48,109 ----
  635.   &check_log('^Recipients: compilers-request@iecc', 9) == 1 || print "10\n";
  636.   &check_log('^Sent by compilers-request.$', 11) == 1 || print "12\n";
  637.   
  638. ! &cleanup;
  639.   `$cmd`;                            # This time, no vacation message
  640.   $? == 0 || print "13\n";
  641. ! -f "$user" || print "14\n";        # Mail not saved, default rule applied
  642. ! -f 'send.mail' && print "15\n";    # No vacation message sent
  643. ! `rm -rf dbr`;        # Enable vacation messages
  644. ! # Make sure vacation message is also sent when a rule match occurs
  645. ! &replace_header('X-Tag: vacation #2');
  646. ! &cleanup;
  647. ! `$cmd`;
  648. ! $? == 0 || print "29\n";
  649. ! -f "$user" && print "30\n";        # Mail has been deleted
  650. ! &get_log(31, 'send.mail');
  651. ! &check_log('^$', 32) == 1 || print "33\n";
  652. ! &check_log('^Subject: Re: melting', 34) == 1 || print "35\n";
  653. ! &check_log('^Recipients: compilers-request@iecc', 36) == 1 || print "37\n";
  654. ! &check_log('^Sent by compilers-request.$', 38) == 1 || print "39\n";
  655. ! `rm -rf dbr`;        # Enable vacation messages
  656. ! # Ensure vacation message is sent when mail was addressed to an alias
  657. ! &replace_header('To: Raphael.Manfredi@acri.fr');
  658. ! &cleanup;
  659. ! &add_option('-o tome:rmanfredi,manfredi');
  660. ! `$cmd`;
  661. ! $? == 0 || print "40\n";
  662. ! -f "$user" && print "41\n";        # Mail has been deleted
  663. ! -f 'send.mail' || print "42\n";    # Assume OK at that point if mail exists
  664. ! &replace_header('X-Tag: vacation');    # Restore non-matching header
  665. ! `rm -rf dbr`;                        # Enable vacation messages
  666. ! &cleanup;
  667. ! &add_header('Illegal-Object: true');    # Will prevent vacation
  668. ! `$cmd`;
  669. ! $? == 0 || print "16\n";
  670. ! -f "$user" || print "17\n";        # Mail not saved, default rule applied
  671. ! -f 'send.mail' && print "18\n";    # No vacation message sent
  672. ! &get_log(19, $user);
  673. ! &check_log('^Illegal-Object:', 20) == 1 || print "21\n";
  674. ! &cleanup;
  675. ! &replace_header('Illegal-Object:', 'mail', 'Illegal-Field: from');
  676. ! `$cmd`;
  677. ! $? == 0 || print "22\n";
  678. ! -f "$user" || print "23\n";        # Mail not saved, default rule applied
  679. ! -f 'send.mail' && print "24\n";    # No vacation message sent
  680. ! &get_log(25, $user);
  681. ! ¬_log('^Illegal-Object:', 26);
  682. ! &check_log('^Illegal-Field:', 27) == 1 || print "28\n";
  683.   
  684. + # Last: 42
  685.   &clear_mta;
  686.   unlink 'mail', '.vacation';
  687.   print "0\n";
  688.  
  689. Index: agent/pl/filter.pl
  690. Prereq: 3.0.1.1
  691. *** agent/pl/filter.pl.old    Fri Jul  1 17:16:16 1994
  692. --- agent/pl/filter.pl    Fri Jul  1 17:16:17 1994
  693. ***************
  694. *** 1,4 ****
  695. ! ;# $Id: filter.pl,v 3.0.1.1 1994/01/26 09:31:43 ram Exp $
  696.   ;#
  697.   ;#  Copyright (c) 1990-1993, Raphael Manfredi
  698.   ;#  
  699. --- 1,4 ----
  700. ! ;# $Id: filter.pl,v 3.0.1.2 1994/07/01 15:00:30 ram Exp $
  701.   ;#
  702.   ;#  Copyright (c) 1990-1993, Raphael Manfredi
  703.   ;#  
  704. ***************
  705. *** 9,14 ****
  706. --- 9,17 ----
  707.   ;#  of the source tree for mailagent 3.0.
  708.   ;#
  709.   ;# $Log: filter.pl,v $
  710. + ;# Revision 3.0.1.2  1994/07/01  15:00:30  ram
  711. + ;# patch8: new UMASK command
  712. + ;#
  713.   ;# Revision 3.0.1.1  1994/01/26  09:31:43  ram
  714.   ;# patch5: added tags to UNIQUE and RECORD commands
  715.   ;#
  716. ***************
  717. *** 597,602 ****
  718. --- 600,622 ----
  719.       }
  720.       $ever_saved = 1 if $saved;        # Mark mail as saved if appropriate
  721.       $saved ? $failed : 1;            # Force failure if never saved
  722. + }
  723. + # Run the UMASK command
  724. + sub run_umask {
  725. +     local($mask) = $cmd =~ m|^\w+\s+(.*)|;
  726. +     local($local);            # True if -l option is given, for local setting
  727. +     $local = $mask =~ s/^-l\s+//;
  728. +     $mask = oct($mask) if $mask =~ /^0/;
  729. +     if ($local) {
  730. +         &u_mask'set($mask);    # Record previous value, restored when leaving rule
  731. +     } else {
  732. +         umask($mask);
  733. +     }
  734. +     local($omask) = sprintf("0%o", $mask);    # Octal string, for logging
  735. +     $local = $local ? ' locally' : '';
  736. +     &add_log("UMASK [$mfile] set to ${omask}$local") if $loglvl > 7;
  737. +     0;    # Ok
  738.   }
  739.   
  740.   # For SAVE, STORE or WRITE, the job is the same
  741.  
  742. Index: agent/test/pl/filter.pl
  743. Prereq: 3.0
  744. *** agent/test/pl/filter.pl.old    Fri Jul  1 17:16:29 1994
  745. --- agent/test/pl/filter.pl    Fri Jul  1 17:16:30 1994
  746. ***************
  747. *** 1,16 ****
  748.   # Common actions at the top of each filtering test
  749.   
  750. ! # $Id: filter.pl,v 3.0 1993/11/29 13:50:23 ram Exp $
  751. ! #
  752. ! #  Copyright (c) 1990-1993, Raphael Manfredi
  753. ! #  
  754. ! #  You may redistribute only under the terms of the Artistic License,
  755. ! #  as specified in the README file that comes with the distribution.
  756. ! #  You may reuse parts of this distribution only within the terms of
  757. ! #  that same Artistic License; a copy of which may be found at the root
  758. ! #  of the source tree for mailagent 3.0.
  759. ! #
  760. ! # $Log: filter.pl,v $
  761.   ;# Revision 3.0  1993/11/29  13:50:23  ram
  762.   ;# Baseline for mailagent 3.0 netwide release.
  763.   ;#
  764. --- 1,19 ----
  765.   # Common actions at the top of each filtering test
  766.   
  767. ! ;# $Id: filter.pl,v 3.0.1.1 1994/07/01 15:10:19 ram Exp $
  768. ! ;#
  769. ! ;#  Copyright (c) 1990-1993, Raphael Manfredi
  770. ! ;#  
  771. ! ;#  You may redistribute only under the terms of the Artistic License,
  772. ! ;#  as specified in the README file that comes with the distribution.
  773. ! ;#  You may reuse parts of this distribution only within the terms of
  774. ! ;#  that same Artistic License; a copy of which may be found at the root
  775. ! ;#  of the source tree for mailagent 3.0.
  776. ! ;#
  777. ! ;# $Log: filter.pl,v $
  778. ! ;# Revision 3.0.1.1  1994/07/01  15:10:19  ram
  779. ! ;# patch8: now uses the cp_mail routine to copy mail
  780. ! ;#
  781.   ;# Revision 3.0  1993/11/29  13:50:23  ram
  782.   ;# Baseline for mailagent 3.0 netwide release.
  783.   ;#
  784. ***************
  785. *** 18,26 ****
  786.   do '../pl/init.pl';
  787.   chdir '../out';
  788.   do '../pl/mail.pl';
  789. ! `cp ../mail .`;
  790.   $user = $ENV{'USER'};
  791. ! unlink "$user", 'agentlog';
  792.   $cmd = "$mailagent -L $ENV{'LEVEL'} -r ../rules mail 2>/dev/null";
  793.   
  794.   # Re-create pattern list
  795. --- 21,29 ----
  796.   do '../pl/init.pl';
  797.   chdir '../out';
  798.   do '../pl/mail.pl';
  799. ! &cp_mail;                # From mail.pl
  800.   $user = $ENV{'USER'};
  801. ! unlink $user, 'agentlog';
  802.   $cmd = "$mailagent -L $ENV{'LEVEL'} -r ../rules mail 2>/dev/null";
  803.   
  804.   # Re-create pattern list
  805.  
  806. Index: agent/test/pl/mail.pl
  807. Prereq: 3.0
  808. *** agent/test/pl/mail.pl.old    Fri Jul  1 17:16:31 1994
  809. --- agent/test/pl/mail.pl    Fri Jul  1 17:16:31 1994
  810. ***************
  811. *** 1,16 ****
  812.   # Utilities to twinkle default mail message
  813.   
  814. ! # $Id: mail.pl,v 3.0 1993/11/29 13:50:25 ram Exp $
  815. ! #
  816. ! #  Copyright (c) 1990-1993, Raphael Manfredi
  817. ! #  
  818. ! #  You may redistribute only under the terms of the Artistic License,
  819. ! #  as specified in the README file that comes with the distribution.
  820. ! #  You may reuse parts of this distribution only within the terms of
  821. ! #  that same Artistic License; a copy of which may be found at the root
  822. ! #  of the source tree for mailagent 3.0.
  823. ! #
  824. ! # $Log: mail.pl,v $
  825.   ;# Revision 3.0  1993/11/29  13:50:25  ram
  826.   ;# Baseline for mailagent 3.0 netwide release.
  827.   ;#
  828. --- 1,21 ----
  829.   # Utilities to twinkle default mail message
  830.   
  831. ! ;# $Id: mail.pl,v 3.0.1.1 1994/07/01 15:11:46 ram Exp $
  832. ! ;#
  833. ! ;#  Copyright (c) 1990-1993, Raphael Manfredi
  834. ! ;#  
  835. ! ;#  You may redistribute only under the terms of the Artistic License,
  836. ! ;#  as specified in the README file that comes with the distribution.
  837. ! ;#  You may reuse parts of this distribution only within the terms of
  838. ! ;#  that same Artistic License; a copy of which may be found at the root
  839. ! ;#  of the source tree for mailagent 3.0.
  840. ! ;#
  841. ! ;# $Log: mail.pl,v $
  842. ! ;# Revision 3.0.1.1  1994/07/01  15:11:46  ram
  843. ! ;# patch8: fixed RCS leading comment string
  844. ! ;# patch8: now defines the cp_mail routine
  845. ! ;# patch8: the replace_header routine can now supersede header lines
  846. ! ;#
  847.   ;# Revision 3.0  1993/11/29  13:50:25  ram
  848.   ;# Baseline for mailagent 3.0 netwide release.
  849.   ;#
  850. ***************
  851. *** 31,39 ****
  852.       rename("$file.x", "$file");
  853.   }
  854.   
  855. ! # Change first matching header with new value
  856.   sub replace_header {
  857. !     local($header, $file) = @_;
  858.       $file = 'mail' unless $file;
  859.       local($field) = $header =~ /^(\S+):/;
  860.       local($_);
  861. --- 36,50 ----
  862.       rename("$file.x", "$file");
  863.   }
  864.   
  865. ! # Change first matching header with new value. If $supersede is given, then
  866. ! # the it is used instead. This enables:
  867. ! #    &replace_header('To:', 'xxx', 'Cc: me')
  868. ! # to replace the whole first To: line by a Cc: header. If this third argument
  869. ! # is not supplied, then the first one is used verbatim, which is the case in
  870. ! # most calls to this routine.
  871.   sub replace_header {
  872. !     local($header, $file, $supersede) = @_;
  873. !     $supersede = $header unless defined $supersede;
  874.       $file = 'mail' unless $file;
  875.       local($field) = $header =~ /^(\S+):/;
  876.       local($_);
  877. ***************
  878. *** 41,47 ****
  879.       open(OLD, "$file");
  880.       while (<OLD>) {
  881.           if ((1../^$/) && eval "/^$field:/") {
  882. !             print NEW $header, "\n";
  883.               next;
  884.           }
  885.           print NEW;
  886. --- 52,58 ----
  887.       open(OLD, "$file");
  888.       while (<OLD>) {
  889.           if ((1../^$/) && eval "/^$field:/") {
  890. !             print NEW $supersede, "\n";
  891.               next;
  892.           }
  893.           print NEW;
  894. ***************
  895. *** 58,62 ****
  896. --- 69,83 ----
  897.       open(NEW, ">>$file");
  898.       print NEW $line, "\n";
  899.       close NEW;
  900. + }
  901. + # Copy mail in out/
  902. + sub cp_mail {
  903. +     local($_);
  904. +     open(MAIL, '../mail');
  905. +     open(HERE, '>mail');
  906. +     print HERE while <MAIL>;
  907. +     close MAIL;
  908. +     close HERE;
  909.   }
  910.   
  911.  
  912. Index: agent/filter/io.c
  913. Prereq: 3.0.1.1
  914. *** agent/filter/io.c.old    Fri Jul  1 17:16:03 1994
  915. --- agent/filter/io.c    Fri Jul  1 17:16:03 1994
  916. ***************
  917. *** 11,17 ****
  918.   */
  919.   
  920.   /*
  921. !  * $Id: io.c,v 3.0.1.1 1994/01/26 09:27:13 ram Exp $
  922.    *
  923.    *  Copyright (c) 1990-1993, Raphael Manfredi
  924.    *  
  925. --- 11,17 ----
  926.   */
  927.   
  928.   /*
  929. !  * $Id: io.c,v 3.0.1.2 1994/07/01 14:52:04 ram Exp $
  930.    *
  931.    *  Copyright (c) 1990-1993, Raphael Manfredi
  932.    *  
  933. ***************
  934. *** 22,27 ****
  935. --- 22,30 ----
  936.    *  of the source tree for mailagent 3.0.
  937.    *
  938.    * $Log: io.c,v $
  939. +  * Revision 3.0.1.2  1994/07/01  14:52:04  ram
  940. +  * patch8: now honours the queuewait config variable when present
  941. +  *
  942.    * Revision 3.0.1.1  1994/01/26  09:27:13  ram
  943.    * patch5: now only try to include <sys/fcntl.h> when hope is lost
  944.    * patch5: filter will now put itself in daemon state while waiting
  945. ***************
  946. *** 76,81 ****
  947. --- 79,85 ----
  948.   #define BUFSIZE        1024            /* Amount of bytes read in a single call */
  949.   #define CHUNK        (10 * BUFSIZE)    /* Granularity of pool */
  950.   #define MAX_STRING    2048            /* Maximum string's length */
  951. + #define QUEUE_WAIT    60                /* Default waiting time in queue */
  952.   #define AGENT_WAIT    "agent.wait"    /* File listing out-of-the-queue mails */
  953.   #define AGENT_LOCK    "perl.lock"        /* Lock file used by mailagent */
  954.   
  955. ***************
  956. *** 306,311 ****
  957. --- 310,316 ----
  958.       int xstat;                /* The exit status value */
  959.       int pid;                /* Pid of our children */
  960.       int res;                /* Result from wait */
  961. +     int delay;                /* Delay in seconds before invoking mailagent */
  962.   
  963.       if (loglvl <= 20) {        /* Loggging level higher than 20 is for tests */
  964.           pid = fork();
  965. ***************
  966. *** 320,325 ****
  967. --- 325,336 ----
  968.               goto_daemon();    /* Remaining child is to disassociate from tty */
  969.       }
  970.   
  971. +     /*
  972. +      * Compute waiting delay, defaults to QUEUE_WAIT seconds if not defined.
  973. +      */
  974. +     delay = get_confval("queuewait", CF_DEFAULT, QUEUE_WAIT);
  975.       /* Now hopefully we detached ourselves from sendmail, which thinks the mail
  976.        * has been delivered. Not yet, but close. Simply wait a little in case
  977.        * more mail is comming. This process is going to remain alive while the
  978. ***************
  979. *** 329,335 ****
  980.        */
  981.   
  982.       if (loglvl < 12)        /* Loggging level 12 and higher is for debugging */
  983. !         sleep(60);            /* Delay invocation of mailagent */
  984.       progpid = getpid();        /* This may be the child (if fork succeded) */
  985.       envp = make_env();        /* Build new environment */
  986.   
  987. --- 340,346 ----
  988.        */
  989.   
  990.       if (loglvl < 12)        /* Loggging level 12 and higher is for debugging */
  991. !         sleep(delay);        /* Delay invocation of mailagent */
  992.       progpid = getpid();        /* This may be the child (if fork succeded) */
  993.       envp = make_env();        /* Build new environment */
  994.   
  995.  
  996. Index: agent/filter/lock.c
  997. Prereq: 3.0
  998. *** agent/filter/lock.c.old    Fri Jul  1 17:16:03 1994
  999. --- agent/filter/lock.c    Fri Jul  1 17:16:04 1994
  1000. ***************
  1001. *** 11,17 ****
  1002.   */
  1003.   
  1004.   /*
  1005. !  * $Id: lock.c,v 3.0 1993/11/29 13:48:12 ram Exp $
  1006.    *
  1007.    *  Copyright (c) 1990-1993, Raphael Manfredi
  1008.    *  
  1009. --- 11,17 ----
  1010.   */
  1011.   
  1012.   /*
  1013. !  * $Id: lock.c,v 3.0.1.1 1994/07/01 14:52:28 ram Exp $
  1014.    *
  1015.    *  Copyright (c) 1990-1993, Raphael Manfredi
  1016.    *  
  1017. ***************
  1018. *** 22,27 ****
  1019. --- 22,30 ----
  1020.    *  of the source tree for mailagent 3.0.
  1021.    *
  1022.    * $Log: lock.c,v $
  1023. +  * Revision 3.0.1.1  1994/07/01  14:52:28  ram
  1024. +  * patch8: now honours the lockhold config variable if present
  1025. +  *
  1026.    * Revision 3.0  1993/11/29  13:48:12  ram
  1027.    * Baseline for mailagent 3.0 netwide release.
  1028.    *
  1029. ***************
  1030. *** 29,34 ****
  1031. --- 32,38 ----
  1032.   
  1033.   #include "config.h"
  1034.   #include "portable.h"
  1035. + #include "parser.h"
  1036.   #include <errno.h>
  1037.   #include <sys/types.h>
  1038.   #include <sys/stat.h>
  1039. ***************
  1040. *** 95,104 ****
  1041.   char *file;
  1042.   {
  1043.       /* Make sure the lock file is not older than MAX_TIME seconds, otherwise
  1044. !      * unlink it (something must have gone wrong).
  1045.        */
  1046.   
  1047.       struct stat buf;
  1048.   
  1049.       if (-1 == stat(file, &buf)) {        /* Stat failed */
  1050.           if (errno == ENOENT)            /* File does not exist */
  1051. --- 99,110 ----
  1052.   char *file;
  1053.   {
  1054.       /* Make sure the lock file is not older than MAX_TIME seconds, otherwise
  1055. !      * unlink it (something must have gone wrong). If the lockhold parameter
  1056. !      * is set in ~/.mailagent, use that instead for timeout.
  1057.        */
  1058.   
  1059.       struct stat buf;
  1060. +     int hold;            /* Lockfile timeout */
  1061.   
  1062.       if (-1 == stat(file, &buf)) {        /* Stat failed */
  1063.           if (errno == ENOENT)            /* File does not exist */
  1064. ***************
  1065. *** 108,120 ****
  1066.           return;
  1067.       }
  1068.   
  1069. !     if (time((Time_t *) 0) - buf.st_mtime > MAX_TIME) {
  1070.           if (-1 == unlink(lockfile)) {
  1071.               add_log(1, "SYSERR unlink: %m (%e)");
  1072.               add_log(4, "WARNING could not remove old lock %s", lockfile);
  1073.           } else
  1074. !             add_log(6, "UNLOCKED filter (lock older than 1 hour)");
  1075.       } else
  1076. !         add_log(16, "lockfile for filter is recent");
  1077.   }
  1078.   
  1079. --- 114,136 ----
  1080.           return;
  1081.       }
  1082.   
  1083. !     /*
  1084. !      * Get lockhold if defined, or use hardwired MAX_TIME.
  1085. !      */
  1086. !     hold = get_confval("lockhold", CF_DEFAULT, MAX_TIME);
  1087. !     /*
  1088. !      * Break lock if older than 'hold' seconds, otherwise honour it.
  1089. !      */
  1090. !     if (time((Time_t *) 0) - buf.st_mtime > hold) {
  1091.           if (-1 == unlink(lockfile)) {
  1092.               add_log(1, "SYSERR unlink: %m (%e)");
  1093.               add_log(4, "WARNING could not remove old lock %s", lockfile);
  1094.           } else
  1095. !             add_log(6, "UNLOCKED filter (lock older than %d seconds)", hold);
  1096.       } else
  1097. !         add_log(16, "lockfile for filter is recent (%d seconds or less), hold");
  1098.   }
  1099.   
  1100.  
  1101. Index: agent/test/actions
  1102. Prereq: 3.0.1.4
  1103. *** agent/test/actions.old    Fri Jul  1 17:16:24 1994
  1104. --- agent/test/actions    Fri Jul  1 17:16:24 1994
  1105. ***************
  1106. *** 2,8 ****
  1107.   # Mailagent rules for action regression tests
  1108.   #
  1109.   
  1110. ! # $Id: actions,v 3.0.1.4 1994/04/25 15:24:12 ram Exp $
  1111.   #
  1112.   #  Copyright (c) 1990-1993, Raphael Manfredi
  1113.   #  
  1114. --- 2,8 ----
  1115.   # Mailagent rules for action regression tests
  1116.   #
  1117.   
  1118. ! # $Id: actions,v 3.0.1.5 1994/07/01 15:06:56 ram Exp $
  1119.   #
  1120.   #  Copyright (c) 1990-1993, Raphael Manfredi
  1121.   #  
  1122. ***************
  1123. *** 13,18 ****
  1124. --- 13,23 ----
  1125.   #  of the source tree for mailagent 3.0.
  1126.   #
  1127.   # $Log: actions,v $
  1128. + # Revision 3.0.1.5  1994/07/01  15:06:56  ram
  1129. + # patch8: added exit status test for PERL command
  1130. + # patch8: added new test for vacation message with tome config variable
  1131. + # patch8: new set of tests for the new UMASK command
  1132. + #
  1133.   # Revision 3.0.1.4  1994/04/25  15:24:12  ram
  1134.   # patch7: check bug reported by Andy Seaborne <afs@hplb.hpl.hp.com>
  1135.   #
  1136. ***************
  1137. *** 156,161 ****
  1138. --- 161,167 ----
  1139.   }
  1140.   
  1141.   X-Tag: /perl/    { REJECT PERL };
  1142. + <PERL>            { PERL perl.2 exit_1; REJECT -t; SAVE exit_ok; REJECT };
  1143.   <PERL>            { PERL perl.1; SAVE never };
  1144.   <PERL>            { PERL perl.2 'arg 1' "arg 2"; SAVE never };
  1145.   <PERL>            { PERL perl.1; SAVE never };
  1146. ***************
  1147. *** 281,286 ****
  1148. --- 287,341 ----
  1149.       DELETE;
  1150.   }
  1151.   
  1152. + X-Tag: /umask #1/        { REJECT UMASK; };
  1153. + <UMASK>    {
  1154. +     UMASK -l 0444;
  1155. +     PERL umask_is 0444;
  1156. +     REJECT -f UMASKF;
  1157. +     SAVE ok.1;
  1158. +     REJECT;
  1159. + };
  1160. + <UMASK> {
  1161. +     PERL umask_is %=umask;
  1162. +     REJECT -f UMASKF;
  1163. +     SAVE ok.2;
  1164. +     UMASK 0555;
  1165. +     REJECT;
  1166. + };
  1167. + <UMASK> {
  1168. +     PERL umask_is 0555;
  1169. +     REJECT -f UMASKF;
  1170. +     DELETE;
  1171. + };
  1172. + X-Tag: /umask #2/        { REJECT UMASK; };
  1173. + <UMASK> {
  1174. +     UMASK 0444;
  1175. +     PERL umask_is 0444;
  1176. +     REJECT -f UMASKF;
  1177. +     SAVE ok.1;
  1178. +     UMASK -l 0555;
  1179. +     PERL umask_is 0555;
  1180. +     REJECT -f UMASKF;
  1181. +     REJECT;
  1182. + };
  1183. + <UMASK> {
  1184. +     PERL umask_is 0444;
  1185. +     REJECT -f UMASKF;
  1186. +     SAVE ok.2;
  1187. + };
  1188. + X-Tag: /umask #3/        { REJECT UMASK; };
  1189. + <UMASK> {
  1190. +     PERL umask_is 0555;
  1191. +     REJECT -t UMASKF;
  1192. +     PERL umask_is %=umask;
  1193. +     REJECT -f UMASKF;
  1194. +     SAVE ok.3;
  1195. + };
  1196. + <UMASKF>    { SAVE never; };
  1197.   X-Tag: /unique #1/                { UNIQUE; SAVE %u.1 };
  1198.   <_SEEN_> X-Tag: /unique #1/        { SAVE %u.1 };
  1199.   X-Tag: /unique #1/                { SAVE %u.2 };
  1200. ***************
  1201. *** 295,300 ****
  1202. --- 350,357 ----
  1203.   X-Tag: /unique #6/            { UNIQUE (tag); REJECT -f; SAVE %u.1; REJECT };
  1204.   X-Tag: /unique #6/            { UNIQUE (other); REJECT -f; SAVE %u.2; REJECT };
  1205.   X-Tag: /unique #6/            { UNIQUE -a; SAVE %u.3 };
  1206. + X-Tag: /vacation #2/        { DELETE };
  1207.   
  1208.   X-Tag: /write #1/    { WRITE mbox };
  1209.   X-Tag: /write #2/    { WRITE path/another/third/mbox };
  1210.  
  1211. Index: agent/filter/parser.c
  1212. Prereq: 3.0.1.1
  1213. *** agent/filter/parser.c.old    Fri Jul  1 17:16:05 1994
  1214. --- agent/filter/parser.c    Fri Jul  1 17:16:05 1994
  1215. ***************
  1216. *** 11,17 ****
  1217.   */
  1218.   
  1219.   /*
  1220. !  * $Id: parser.c,v 3.0.1.1 1994/01/26 09:27:37 ram Exp $
  1221.    *
  1222.    *  Copyright (c) 1990-1993, Raphael Manfredi
  1223.    *  
  1224. --- 11,17 ----
  1225.   */
  1226.   
  1227.   /*
  1228. !  * $Id: parser.c,v 3.0.1.2 1994/07/01 14:53:57 ram Exp $
  1229.    *
  1230.    *  Copyright (c) 1990-1993, Raphael Manfredi
  1231.    *  
  1232. ***************
  1233. *** 22,27 ****
  1234. --- 22,30 ----
  1235.    *  of the source tree for mailagent 3.0.
  1236.    *
  1237.    * $Log: parser.c,v $
  1238. +  * Revision 3.0.1.2  1994/07/01  14:53:57  ram
  1239. +  * patch8: new routine get_confval to get integer config variables
  1240. +  *
  1241.    * Revision 3.0.1.1  1994/01/26  09:27:37  ram
  1242.    * patch5: typo fix in a comment
  1243.    *
  1244. ***************
  1245. *** 34,39 ****
  1246. --- 37,43 ----
  1247.   #include "portable.h"
  1248.   #include "hash.h"
  1249.   #include "msg.h"
  1250. + #include "parser.h"
  1251.   #include <sys/types.h>
  1252.   #include "logfile.h"
  1253.   #include "environ.h"
  1254. ***************
  1255. *** 161,170 ****
  1256.           fatal("logfile not defined");
  1257.       strcat(logfile, value);
  1258.   
  1259. !     value = ht_value(&symtab, "level");        /* Fetch logging level */
  1260. !     if (value == (char *) 0)
  1261. !         fatal("no logging level defined");
  1262. !     sscanf(value, "%d", &level);
  1263.   
  1264.       set_loglvl(level);                        /* Logging level wanted */
  1265.       if (-1 == open_log(logfile))
  1266. --- 165,171 ----
  1267.           fatal("logfile not defined");
  1268.       strcat(logfile, value);
  1269.   
  1270. !     level = get_confval("level", CF_MANDATORY);
  1271.   
  1272.       set_loglvl(level);                        /* Logging level wanted */
  1273.       if (-1 == open_log(logfile))
  1274. ***************
  1275. *** 287,292 ****
  1276. --- 288,325 ----
  1277.           if (-1 == set_env("TZ", tz))
  1278.               add_log(1, "ERROR cannot set TZ variable");
  1279.       }
  1280. + }
  1281. + public int get_confval(name, type, dflt)
  1282. + char *name;        /* Option name */
  1283. + int type;        /* Type: mandatory or may be defaulted */
  1284. + int dflt;        /* Default value to be used if option not defined */
  1285. + {
  1286. +     /* Return value for option and use default if not defined, or yield a
  1287. +      * fatal error when option is mandatory.
  1288. +      */
  1289. +     char buffer[MAX_STRING];
  1290. +     char *namestr;        /* String in H table */
  1291. +     int val;            /* Returned value */
  1292. +     namestr = ht_value(&symtab, name);
  1293. +     if (namestr == (char *) 0) {
  1294. +         switch(type) {
  1295. +         case CF_MANDATORY:    /* Variable should have been defined */
  1296. +             sprintf(buffer, "variable '%s' not defined in config file", name);
  1297. +             fatal(buffer);
  1298. +             /* NOTREACHED */
  1299. +         case CF_DEFAULT:    /* May use default if variable not defined */
  1300. +             val = dflt;
  1301. +             break;
  1302. +         default:
  1303. +             fatal("BUG: get_confval");
  1304. +         }
  1305. +     } else
  1306. +         sscanf(namestr, "%d", &val);
  1307. +     return val;
  1308.   }
  1309.   
  1310.   private void substitute(value)
  1311.  
  1312. Index: config_h.SH
  1313. Prereq: 3.0.1.1
  1314. *** config_h.SH.old    Fri Jul  1 17:16:33 1994
  1315. --- config_h.SH    Fri Jul  1 17:16:33 1994
  1316. ***************
  1317. *** 25,31 ****
  1318.    * that running config.h.SH again will wipe out any changes you've made.
  1319.    * For a more permanent change edit config.sh and rerun config.h.SH.
  1320.    *
  1321. !  * \$Id: config_h.SH,v 3.0.1.1 1994/01/26 09:36:20 ram Exp $
  1322.    */
  1323.   
  1324.   /* Configuration time: $cf_time
  1325. --- 25,31 ----
  1326.    * that running config.h.SH again will wipe out any changes you've made.
  1327.    * For a more permanent change edit config.sh and rerun config.h.SH.
  1328.    *
  1329. !  * \$Id: config_h.SH,v 3.0.1.2 1994/07/01 15:15:19 ram Exp $
  1330.    */
  1331.   
  1332.   /* Configuration time: $cf_time
  1333. ***************
  1334. *** 103,109 ****
  1335.   /* HAS_STRERROR:
  1336.    *    This symbol, if defined, indicates that the strerror routine is
  1337.    *    available to translate error numbers to strings. See the writeup
  1338. !  *    of strerror() in this file before you try to define your own.
  1339.    */
  1340.   /* HAS_SYS_ERRLIST:
  1341.    *    This symbol, if defined, indicates that the sys_errlist array is
  1342. --- 103,109 ----
  1343.   /* HAS_STRERROR:
  1344.    *    This symbol, if defined, indicates that the strerror routine is
  1345.    *    available to translate error numbers to strings. See the writeup
  1346. !  *    of Strerror() in this file before you try to define your own.
  1347.    */
  1348.   /* HAS_SYS_ERRLIST:
  1349.    *    This symbol, if defined, indicates that the sys_errlist array is
  1350. ***************
  1351. *** 115,121 ****
  1352.    *    available to translate an errno code into its symbolic name (e.g.
  1353.    * ENOENT). The extern int sys_nerrno gives the size of that table.
  1354.    */
  1355. ! /* strerror:
  1356.    *    This preprocessor symbol is defined as a macro if strerror() is
  1357.    *    not available to translate error numbers to strings but sys_errlist[]
  1358.    *    array is there.
  1359. --- 115,121 ----
  1360.    *    available to translate an errno code into its symbolic name (e.g.
  1361.    * ENOENT). The extern int sys_nerrno gives the size of that table.
  1362.    */
  1363. ! /* Strerror:
  1364.    *    This preprocessor symbol is defined as a macro if strerror() is
  1365.    *    not available to translate error numbers to strings but sys_errlist[]
  1366.    *    array is there.
  1367. ***************
  1368. *** 123,129 ****
  1369.   #$d_strerror HAS_STRERROR        /**/
  1370.   #$d_syserrlst HAS_SYS_ERRLIST    /**/
  1371.   #$d_sysernlst HAS_SYS_ERRNOLIST    /**/
  1372. ! #$d_strerrm strerror(e) ((e)<0||(e)>=sys_nerr?"unknown":sys_errlist[e]) /**/
  1373.   
  1374.   /* Time_t:
  1375.    *    This symbol holds the type returned by time(). It can be long,
  1376. --- 123,129 ----
  1377.   #$d_strerror HAS_STRERROR        /**/
  1378.   #$d_syserrlst HAS_SYS_ERRLIST    /**/
  1379.   #$d_sysernlst HAS_SYS_ERRNOLIST    /**/
  1380. ! #define Strerror(e) $d_strerrm
  1381.   
  1382.   /* Time_t:
  1383.    *    This symbol holds the type returned by time(). It can be long,
  1384.  
  1385. *** End of Patch 9 ***
  1386.  
  1387. exit 0 # Just in case...
  1388.