home *** CD-ROM | disk | FTP | other *** search
- From: Raphael Manfredi <ram@acri.fr>
- Newsgroups: comp.sources.misc
- Subject: v43i126: mailagent - Flexible mail filtering and processing package, v3.0, Patch09
- Date: 24 Jul 1994 19:41:07 -0500
- Organization: Advanced Computer Research Institute, Lyon, France
- Sender: kent@sparky.sterling.com
- Approved: kent@sparky.sterling.com
- Message-ID: <30v1n3$i3v@sparky.sterling.com>
- X-Md4-Signature: 82b5bddbeb5b10db46a6f5a791c6438e
-
- Submitted-by: Raphael Manfredi <ram@acri.fr>
- Posting-number: Volume 43, Issue 126
- Archive-name: mailagent/patch09
- Environment: UNIX, Perl
- Patch-To: mailagent: Volume 41, Issue 1-26
-
- [The latest patch for mailagent version 3.0 is #11.]
-
- System: mailagent version 3.0
- Patch #: 9
- Priority: LOW
- Subject: patch #8, continued
- Date: Fri Jul 01 17:27:43 MET DST 1994
- From: Raphael Manfredi <ram@acri.fr>
-
- Description:
- See patch #8.
-
-
- Fix: From rn, say "| patch -p -N -d DIR", where DIR is your mailagent source
- directory. Outside of rn, say "cd DIR; patch -p -N <thisarticle".
- If you don't have the patch program, apply the following by hand,
- or get patch (version 2.0, latest patchlevel).
-
- After patching:
- *** DO NOTHING--INSTALL ALL PATCHES UP THROUGH #11 FIRST ***
-
- If patch indicates that patchlevel is the wrong version, you may need
- to apply one or more previous patches, or the patch may already
- have been applied. See the patchlevel.h file to find out what has or
- has not been applied. In any event, don't continue with the patch.
-
- If you are missing previous patches they can be obtained from me:
-
- Raphael Manfredi <ram@acri.fr>
-
- If you send a mail message of the following form it will greatly speed
- processing:
-
- Subject: Command
- @SH mailpatch PATH mailagent 3.0 LIST
- ^ note the c
-
- where PATH is a return path FROM ME TO YOU either in Internet notation,
- or in bang notation from some well-known host, and LIST is the number
- of one or more patches you need, separated by spaces, commas, and/or
- hyphens. Saying 35- says everything from 35 to the end.
-
- To get some more detailed instructions, send me the following mail:
-
- Subject: Command
- @SH mailhelp PATH
-
-
- Index: patchlevel.h
- Prereq: 8
- 4c4
- < #define PATCHLEVEL 8
- ---
- > #define PATCHLEVEL 9
-
- Index: agent/man/mailagent.SH
- Prereq: 3.0.1.3
- *** agent/man/mailagent.SH.old Fri Jul 1 17:16:09 1994
- --- agent/man/mailagent.SH Fri Jul 1 17:16:10 1994
- ***************
- *** 20,26 ****
- .TH MAILAGENT $manext "Version $VERSION PL$PATCHLEVEL"
- ''' @(#) Manual page for mailagent's filter -- (c) ram February 1991
- '''
- ! ''' $Id: mailagent.SH,v 3.0.1.3 1994/04/25 15:15:56 ram Exp $
- '''
- ''' Copyright (c) 1990-1993, Raphael Manfredi
- '''
- --- 20,26 ----
- .TH MAILAGENT $manext "Version $VERSION PL$PATCHLEVEL"
- ''' @(#) Manual page for mailagent's filter -- (c) ram February 1991
- '''
- ! ''' $Id: mailagent.SH,v 3.0.1.4 1994/07/01 14:56:20 ram Exp $
- '''
- ''' Copyright (c) 1990-1993, Raphael Manfredi
- '''
- ***************
- *** 31,36 ****
- --- 31,42 ----
- ''' of the source tree for mailagent 3.0.
- '''
- ''' $Log: mailagent.SH,v $
- + ''' Revision 3.0.1.4 1994/07/01 14:56:20 ram
- + ''' patch8: documents new eleven configuration variables
- + ''' patch8: sub-section on timeouts has been expanded
- + ''' patch8: emphasize .forward optimization danger with sendmail
- + ''' patch8: new UMASK command
- + '''
- ''' Revision 3.0.1.3 1994/04/25 15:15:56 ram
- ''' patch7: documented new 'fromesc' config variable
- ''' patch7: forgot to insert the new -F option in the synopsis line
- ***************
- *** 230,235 ****
- --- 236,250 ----
- Name of the directory which should be used for dumps, preferably. This is
- optional. (suggested: ~/tmp/lost+mail)
- .TP
- + .I fromall
- + Whether or not \fImailagent\fR should escape all the \fIFrom\fR lines in the
- + message, not only those it thinks should appear dangerous (i.e. a \fIFrom\fR
- + after a blank line). This option only makes sense when \fIfromesc\fR is
- + also activated. It is ignored otherwise, and therefore is optional. By
- + default, it is assumed to be OFF. (suggested: OFF, until you have reasons to
- + believe your mail user-agent is confused in this mode: when it happens, your
- + user agent will split mail for no apparent reason).
- + .TP
- .I fromesc
- Whether or not \fImailagent\fR should escape potentially dangerous \fIFrom\fR
- lines in mail messages. If you use MH or if your mail reader does not use
- ***************
- *** 251,256 ****
- --- 266,282 ----
- .I level
- Log level, see below for a definition of available levels (suggested: 9).
- .TP
- + .I lockdekay
- + The delay in seconds between two locking attempts. (optional, defaults to: 2).
- + .TP
- + .I lockhold
- + The maximum delay in seconds for holding a lock. After that time, the lock
- + will be broken. (optional, defaults to: 3600)
- + .TP
- + .I lockmax
- + Maximum number of locking attempts before giving up. (optional,
- + defaults to: 20).
- + .TP
- .I log
- Name of the log file, put in Log directory. (suggested: agentlog).
- .TP
- ***************
- *** 374,389 ****
- --- 400,435 ----
- Queue directory (messages waiting to be processed). Required, of course.
- (suggested: \$spool/queue)
- .TP
- + .I queuehold
- + Maximum number of seconds a mail can sit in the mailagent queue before being
- + actually processed. During that time, \fImailagent\fR will not try to
- + process the message even when \fB\-q\fR is used. (optional, defaults to: 1800).
- + .TP
- + .I queuelost
- + Maximum number of seconds after which \fImailagent\fR should flag messages
- + still in its queue as being old. (optional, defaults to: 86400, i.e. a day).
- + .TP
- + .I queuewait
- + Time in seconds telling the C \fIfilter\fR program how long it must wait
- + before launching \fImailagent\fR. (optional, defaults to: 60).
- + .TP
- .I rulecache
- The name of the file used to cache the latest compiled rules. Since usually
- \fImailagent\fR works mainly with one same rule file, this saves the overhead
- of recompiling all the rules each time. (optional, suggested:
- \$spool/rulecache).
- .TP
- + .I rulemac
- + Set this to ON to enable macro substitutions in rule patterns.
- + (optional, defaults to: OFF).
- + .TP
- .I rules
- The name of the file holding the filtering rules (optional,
- suggested: ~/.rules).
- .TP
- + .I runmax
- + Timeout for RUN commands and friends. (optional, defaults to: 3600).
- + .TP
- .I scriptcc
- Flag indicating whether a copy of the SERVER session transcript should be
- send to the user running mailagent. (suggested: OFF).
- ***************
- *** 418,423 ****
- --- 464,476 ----
- File where statistics should be gathered. If no such file exists, no
- statistics will be recorded (suggested: mailagent.st).
- .TP
- + .I tome
- + This optional variable may contain a comma separated list of alternate logins
- + that are also valid for the user (mail aliases). This is used in vacation
- + mode to check whether the mail was sent to the user or to a mailing list.
- + If you have an alias like \fIFirst.Name\fR, then specify \fIname\fR only,
- + since \fImailagent\fR reduces the login name to the family name.
- + .TP
- .I track
- Set to \fIon\fR (case insensitively), this turns on the \fB\-t\fR option
- which tracks all the rule matches and the actions on standard output. This
- ***************
- *** 429,434 ****
- --- 482,493 ----
- .I tmpdir
- Directory for temporary files. Required (suggested: /tmp).
- .TP
- + .I umask
- + Default umask which is reset by \fImailagent\fR before processing a message.
- + Assumed to be decimal unless starting with '0' (for octal) or '0x' (for
- + hexadecimal). The octal format is the easiest way to specify it nonetheless.
- + (optional, defaults to: 077).
- + .TP
- .I user
- Login name of the user who runs the mailagent. This sets the value of the
- %u macro.
- ***************
- *** 478,483 ****
- --- 537,552 ----
- be necessary to move the '|' character before the leading quote, but don't
- try this unless you have no other choice (i.e. only as a last resort).
- .PP
- + It is \fIvery\fR important to redirect error messages to some file within
- + your home directory. For one thing, that will get you out of trouble if
- + strange things start to happen, but more to the point, it makes
- + your \fI.forward\fR file unique. Older \fIsendmail\fR program, in an heroic
- + attempt to "optimize" delivery, will silently remove duplicate recipients,
- + and if a recipient has a \fI.forward\fR, its litteral content is used in place
- + of his e-mail address. Therefore, two local recipients with the same
- + filtering string will be considered as one unique recipient and only one
- + of them will get the message...
- + .PP
- Note that the \fI.forward\fR file only pipes the mail to the \fIfilter\fR
- program and does not leave any copy in the mailbox. It is up to you to decide
- in the rule file whether you want to trash the mail away or leave it in the
- ***************
- *** 641,646 ****
- --- 710,719 ----
- .B \-l
- List the mailagent queue. Recently queued mails which are waited for by the
- \fIfilter\fR are \fIskipped\fR for about half an hour, to avoid race conditions.
- + This may be configured via the \fIqueuehold\fR variable. Really old messages
- + (more than \fIqueuelost\fR seconds old) are flagged with a '#' character.
- + Messages out of the queue (\fIqueue\fR variable) are flagged with a '*', whilst
- + old messages out of the queue are signaled by an '@'.
- .TP
- .B \-L\fI level\fR
- Override the log level specified in the configuration file.
- ***************
- *** 1605,1610 ****
- --- 1678,1693 ----
- lowercase. See also ASSIGN and SUBST.
- (Fails if error in \fItranslation\fR)
- .TP
- + UMASK [-l] \fImode\fR
- + Changes the process's umask to the specified \fImode\fR, which can be decimal,
- + octal (if preceded by '0') or hexadecimal (starting with '0x'). The octal
- + notation is the clearest way to specify the umask anyway. Aren't rumors saying
- + that octal was invented for that purpose only? ;-)
- + Use the \fB\-l\fR option to change the umask for the duration of the current
- + action rule only. Note that the default umask specified in your config file
- + is used to reset \fImailagent\fR's umask at the start of each mail processing.
- + (Does not alter execution status)
- + .TP
- UNIQUE [-acr] [\fImode\fR] [\fI(tag-list)\fR]
- Record message in the history and tag message as saved if it was
- already present there. If the message is recorded for the first time, processing
- ***************
- *** 1740,1746 ****
- .I @ARGV
- The arguments of the script, which were given by the PERL command. This array
- is set up the exact same way you would expect it to be set up if you invoked
- ! the command directly from the shell.
- .TP
- .I \$address
- The address part of the From: line.
- --- 1823,1832 ----
- .I @ARGV
- The arguments of the script, which were given by the PERL command. This array
- is set up the exact same way you would expect it to be set up if you invoked
- ! the command directly from the shell, excepted that
- ! .I @ARGV[0]
- ! is the name of the script (since you cannot use perl's \fI\$0\fR to get
- ! at it; that would give you mailagent's name).
- .TP
- .I \$address
- The address part of the From: line.
- ***************
- *** 2225,2234 ****
- .SS "Timeouts"
- .PP
- In order to avoid having a \fImailagent\fR waiting for a command forever, a
- ! maximum execution time of one hour is allowed. Past that amount of time, the
- child is sent a SIGTERM signal. If it does not die within the next 30 seconds,
- a SIGKILL is sent. Output from the program, if any so far, is mailed back to
- the user.
- '''
- .SS "Avoiding Loops"
- .PP
- --- 2311,2351 ----
- .SS "Timeouts"
- .PP
- In order to avoid having a \fImailagent\fR waiting for a command forever, a
- ! maximum execution time of one hour is allowed by default.
- ! Past that amount of time, the
- child is sent a SIGTERM signal. If it does not die within the next 30 seconds,
- a SIGKILL is sent. Output from the program, if any so far, is mailed back to
- the user.
- + This default behaviour may be altered by setting a proper \fIrunmax\fR variable
- + in your configuration file to allow more time for the command to complete.
- + .PP
- + There is also a \fIfilter\fR queue timeout. In order to moderate system load,
- + the C \fIfilter\fR program waits 60 seconds by default (or whatever
- + .I queuewait
- + was set to in the config file) before launching \fImailagent\fR. To avoid
- + conflicts, messages queued by the first filter (which will then sleep for
- + .I queuewait
- + seconds) are not processed by \fImailagent\fR's \fB\-q\fR option until they
- + are at least
- + .I queuehold
- + seconds old. Another queue-related parameter is
- + .I queuelost,
- + the amount of seconds after which \fImailagent\fR will flag messages as "lost"
- + when listing the queue.
- + .PP
- + Finally, the locking timeout policy may also be configured. By default, a
- + lock is broken when it is one hour old (configured by the
- + .I lockhold
- + variable) and \fImailagent\fR will only make
- + .I lockmax
- + attempts, spaced by
- + .I lockdelay
- + seconds to acquire the lock. It will then proceed whether or not it got that
- + lock. If you want a secure locking policy, make sure
- + .I lockmax
- + times
- + .I lockdelay
- + is greater than \fIlockhold\fR, that parameter being "large" enough.
- '''
- .SS "Avoiding Loops"
- .PP
-
- Index: agent/pl/actions.pl
- Prereq: 3.0.1.2
- *** agent/pl/actions.pl.old Fri Jul 1 17:16:13 1994
- --- agent/pl/actions.pl Fri Jul 1 17:16:14 1994
- ***************
- *** 1,4 ****
- ! ;# $Id: actions.pl,v 3.0.1.2 1994/04/25 15:16:53 ram Exp $
- ;#
- ;# Copyright (c) 1990-1993, Raphael Manfredi
- ;#
- --- 1,4 ----
- ! ;# $Id: actions.pl,v 3.0.1.3 1994/07/01 14:57:49 ram Exp $
- ;#
- ;# Copyright (c) 1990-1993, Raphael Manfredi
- ;#
- ***************
- *** 9,14 ****
- --- 9,18 ----
- ;# of the source tree for mailagent 3.0.
- ;#
- ;# $Log: actions.pl,v $
- + ;# Revision 3.0.1.3 1994/07/01 14:57:49 ram
- + ;# patch8: timeout for RUN commands now defined by runmax config variable
- + ;# patch8: now systematically escape leading From if fromall is ON
- + ;#
- ;# Revision 3.0.1.2 1994/04/25 15:16:53 ram
- ;# patch7: here and there fixes
- ;# patch7: global fix for From line escapes to make them configurable
- ***************
- *** 813,819 ****
- $program =~ s/\b~/$cf'home/g; # ~ substitution as first letter in word
- $SIG{'PIPE'} = 'popen_failed'; # Protect against naughty program
- $SIG{'ALRM'} = 'alarm_clock'; # Protect against loops
- ! alarm 3600; # At most one hour of processing
- eval '&execute_command($program, $input, $feedback)';
- alarm 0; # Disable alarm timeout
- $SIG{'PIPE'} = 'emergency'; # Restore initial value
- --- 817,823 ----
- $program =~ s/\b~/$cf'home/g; # ~ substitution as first letter in word
- $SIG{'PIPE'} = 'popen_failed'; # Protect against naughty program
- $SIG{'ALRM'} = 'alarm_clock'; # Protect against loops
- ! alarm $cf'runmax; # At most that amount of processing
- eval '&execute_command($program, $input, $feedback)';
- alarm 0; # Disable alarm timeout
- $SIG{'PIPE'} = 'emergency'; # Restore initial value
- ***************
- *** 828,834 ****
- &add_log("WARNING no feedback occurred") if $loglvl > 5;
- return 1; # Failed
- } elsif ($@ =~ /^alarm/) { # Timeout
- ! &add_log("WARNING time out received") if $loglvl > 5;
- return 1; # Failed
- } elsif ($@ =~ /^non-zero/) { # Program returned non-zero status
- &add_log("WARNING program returned non-zero status") if $loglvl > 5;
- --- 832,839 ----
- &add_log("WARNING no feedback occurred") if $loglvl > 5;
- return 1; # Failed
- } elsif ($@ =~ /^alarm/) { # Timeout
- ! &add_log("WARNING time out received ($cf'runmax seconds)")
- ! if $loglvl > 5;
- return 1; # Failed
- } elsif ($@ =~ /^non-zero/) { # Program returned non-zero status
- &add_log("WARNING program returned non-zero status") if $loglvl > 5;
- ***************
- *** 1009,1017 ****
- local($last_was_nl) = 1; # True when previous line was blank
- if ($input == $BODY_INPUT) { # We have to feed back the body only
- while (<TRACE>) {
- ! # Protect potentially dangerous lines
- s/^From(\s)/>From$1/ if $last_was_nl && $cf'fromesc =~ /on/i;
- ! $last_was_nl = /^$/;
- $temp .= $_;
- }
- } else {
- --- 1014,1024 ----
- local($last_was_nl) = 1; # True when previous line was blank
- if ($input == $BODY_INPUT) { # We have to feed back the body only
- while (<TRACE>) {
- ! # Protect potentially dangerous lines. If fromall is ON, then we
- ! # don't care whether From is within a paragraph, i.e. not preceded
- ! # by a blank line. This is only required with "broken" User Agents.
- s/^From(\s)/>From$1/ if $last_was_nl && $cf'fromesc =~ /on/i;
- ! $last_was_nl = /^$/ || $cf'fromall =~ /on/i;
- $temp .= $_;
- }
- } else {
- ***************
- *** 1023,1029 ****
- } else {
- # Protect potentially dangerous lines
- s/^From(\s)/>From$1/ if $last_was_nl && $cf'fromesc =~ /on/i;
- ! $last_was_nl = /^$/;
- $temp .= $_;
- }
- }
- --- 1030,1036 ----
- } else {
- # Protect potentially dangerous lines
- s/^From(\s)/>From$1/ if $last_was_nl && $cf'fromesc =~ /on/i;
- ! $last_was_nl = /^$/ || $cf'fromall =~ /on/i;
- $temp .= $_;
- }
- }
- ***************
- *** 1381,1387 ****
- # Protect potentially dangerous lines
- s/^From\s+(\S+)/>From $1/ if $last_was_space && $cf'fromesc =~ /on/i;
- s/^- -/-/; # This is the EB escape in RFC-934
- ! $last_was_space = /^$/; # From is dangerous after blank line
- }
- # Now @array holds the whole digest item
- if ($folder =~ /^\s*$/) { # No folder means we have to queue message
- --- 1388,1395 ----
- # Protect potentially dangerous lines
- s/^From\s+(\S+)/>From $1/ if $last_was_space && $cf'fromesc =~ /on/i;
- s/^- -/-/; # This is the EB escape in RFC-934
- ! # From is dangerous after blank line, but everywhere if fromall is ON.
- ! $last_was_space = /^$/ || $cf'fromall =~ /on/i;
- }
- # Now @array holds the whole digest item
- if ($folder =~ /^\s*$/) { # No folder means we have to queue message
-
- Index: agent/pl/analyze.pl
- Prereq: 3.0.1.2
- *** agent/pl/analyze.pl.old Fri Jul 1 17:16:15 1994
- --- agent/pl/analyze.pl Fri Jul 1 17:16:15 1994
- ***************
- *** 1,4 ****
- ! ;# $Id: analyze.pl,v 3.0.1.2 1994/04/25 15:17:24 ram Exp $
- ;#
- ;# Copyright (c) 1990-1993, Raphael Manfredi
- ;#
- --- 1,4 ----
- ! ;# $Id: analyze.pl,v 3.0.1.3 1994/07/01 14:59:58 ram Exp $
- ;#
- ;# Copyright (c) 1990-1993, Raphael Manfredi
- ;#
- ***************
- *** 9,14 ****
- --- 9,20 ----
- ;# of the source tree for mailagent 3.0.
- ;#
- ;# $Log: analyze.pl,v $
- + ;# Revision 3.0.1.3 1994/07/01 14:59:58 ram
- + ;# patch8: general umask is now reset before analyzing a message
- + ;# patch8: added support for the UMASK command for local rule scope
- + ;# patch8: now parses the new tome config variable for vacation messages
- + ;# patch8: disable vacation message if Illegal-Object or Illegal-Field header
- + ;#
- ;# Revision 3.0.1.2 1994/04/25 15:17:24 ram
- ;# patch7: fixed selector combination logic and added some debug logs
- ;#
- ***************
- *** 60,65 ****
- --- 66,74 ----
- local($vacation) = 1; # Vacation message allowed a priori
- local($header); # Header entry name to look for in Header table
-
- + # Reset umask
- + umask($cf'umask);
- +
- # Parse the mail message in file
- &parse_mail($file); # Parse the mail and fill-in H tables
- return 0 unless defined $Header{'All'}; # Mail not parsed correctly
- ***************
- *** 190,196 ****
- undef %Inverted; # Reset negated patterns
- $rules = $_; # Work on a copy
- $rules =~ s/^([^{]*){// && ($mode = $1); # First word is the mode
- ! $rules =~ s/\s*(.*)}// && ($action = $1); # Followed by action
- $mode =~ s/\s*$//; # Remove trailing spaces
- $rules =~ s/^\s+//; # Remove leading spaces
- $last_selector = ""; # Last selector used
- --- 199,205 ----
- undef %Inverted; # Reset negated patterns
- $rules = $_; # Work on a copy
- $rules =~ s/^([^{]*){// && ($mode = $1); # First word is the mode
- ! $rules =~ s/\s*(.*)}// && ($action = $1); # Followed by action }
- $mode =~ s/\s*$//; # Remove trailing spaces
- $rules =~ s/^\s+//; # Remove leading spaces
- $last_selector = ""; # Last selector used
- ***************
- *** 291,297 ****
- --- 300,310 ----
- &add_log("MATCH on rule #$j in mode $wmode") if $loglvl > 8;
- &track_rule($j, $wmode) if $track_all;
- &s_match($j, $wmode) if $stats; # Record match for statistics
- +
- + &u_mask'init; # Built-in support for local umask setting
- $status = &xeqte($action);
- + &u_mask'reset; # Restore previous umask if set locally in rules
- +
- last rule if $status == $FT_CONT;
- $ever_matched = 0; # No match if REJECT or RESTART
- next rule if $status == $FT_REJECT;
- ***************
- *** 344,360 ****
- --- 357,398 ----
- # was sent to the user directly, through a 'To:' or a 'Cc:'. Otherwise,
- # it must be from a mailing list or a 'Bcc:' and we don't want to
- # send something back in that case.
- +
- local($matched) = &match_list("To", $cf'user);
- $matched = &match_list("Cc", $cf'user) unless $matched;
- +
- + # Try alternate login names, in case they used a company-wide alias like
- + # First.Last or simply a plain sendmail alias.
- +
- + if (!$matched && $cf'tome ne '') {
- + foreach $addr (split(/\s*,\s*/, $cf'tome)) {
- + $matched = &match_list('To', $addr);
- + $matched = &match_list('Cc', $addr) unless $matched;
- + if ($matched) {
- + &add_log("mail was sent to alternate $addr") if $loglvl > 8;
- + last;
- + } else {
- + &add_log("mail wasn't sent to alternate $addr") if $loglvl > 12;
- + }
- + }
- + }
- +
- unless ($matched) {
- &add_log("mail was not directly sent to $cf'user") if $loglvl > 8;
- return 1;
- }
- +
- # If there is a Precedence: header set to either 'bulk', 'list' or 'junk',
- # then we do not reply either.
- local($prec) = $Header{'Precedence'};
- if ($prec =~ /^bulk|junk|list/i) {
- &add_log("mail was tagged with a '$prec' precedence") if $loglvl > 8;
- + return 1;
- + }
- + # If there is an RFC-886 Illegal-Object or Illegal-Field header, do not
- + # trust the whole header integrity, and therefore do not reply.
- + if ($Header{'Illegal-Object'} ne '' || $Header{'Illegal-Field'} ne '') {
- + &add_log("mail was received with header errors") if $loglvl > 8;
- return 1;
- }
- # Make sure the mail does not come from a "special" user, as listed in
-
- Index: agent/test/cmd/vacation.t
- Prereq: 3.0
- *** agent/test/cmd/vacation.t.old Fri Jul 1 17:16:28 1994
- --- agent/test/cmd/vacation.t Fri Jul 1 17:16:28 1994
- ***************
- *** 1,6 ****
- # The VACATION command
-
- ! # $Id: vacation.t,v 3.0 1993/11/29 13:49:55 ram Exp $
- #
- # Copyright (c) 1990-1993, Raphael Manfredi
- #
- --- 1,6 ----
- # The VACATION command
-
- ! # $Id: vacation.t,v 3.0.1.1 1994/07/01 15:09:13 ram Exp $
- #
- # Copyright (c) 1990-1993, Raphael Manfredi
- #
- ***************
- *** 11,16 ****
- --- 11,20 ----
- # of the source tree for mailagent 3.0.
- #
- # $Log: vacation.t,v $
- + # Revision 3.0.1.1 1994/07/01 15:09:13 ram
- + # patch8: added check for no vacation when Illegal-Object or Illegal-Field
- + # patch8: make sure the new tome config variable is honored
- + #
- # Revision 3.0 1993/11/29 13:49:55 ram
- # Baseline for mailagent 3.0 netwide release.
- #
- ***************
- *** 19,24 ****
- --- 23,33 ----
- do '../pl/mta.pl';
- unlink $user, 'dbr/c/o';
-
- + sub cleanup {
- + unlink 'send.mail', $user;
- + }
- +
- + `rm -rf dbr`; # Enable vacation messages
- &add_option("-o 'vacation: ON' -o 'user: ram'");
-
- open(VACATION, '>.vacation') || print "1\n";
- ***************
- *** 39,50 ****
- &check_log('^Recipients: compilers-request@iecc', 9) == 1 || print "10\n";
- &check_log('^Sent by compilers-request.$', 11) == 1 || print "12\n";
-
- ! unlink 'send.mail', $user;
- `$cmd`; # This time, no vacation message
- $? == 0 || print "13\n";
- ! -f "$user" || print "14\n"; # Mail not saved
- ! -f 'send.mail' && print "15\n";
-
- &clear_mta;
- unlink 'mail', '.vacation';
- print "0\n";
- --- 48,109 ----
- &check_log('^Recipients: compilers-request@iecc', 9) == 1 || print "10\n";
- &check_log('^Sent by compilers-request.$', 11) == 1 || print "12\n";
-
- ! &cleanup;
- `$cmd`; # This time, no vacation message
- $? == 0 || print "13\n";
- ! -f "$user" || print "14\n"; # Mail not saved, default rule applied
- ! -f 'send.mail' && print "15\n"; # No vacation message sent
- !
- ! `rm -rf dbr`; # Enable vacation messages
- !
- ! # Make sure vacation message is also sent when a rule match occurs
- !
- ! &replace_header('X-Tag: vacation #2');
- ! &cleanup;
- ! `$cmd`;
- ! $? == 0 || print "29\n";
- ! -f "$user" && print "30\n"; # Mail has been deleted
- ! &get_log(31, 'send.mail');
- ! &check_log('^$', 32) == 1 || print "33\n";
- ! &check_log('^Subject: Re: melting', 34) == 1 || print "35\n";
- ! &check_log('^Recipients: compilers-request@iecc', 36) == 1 || print "37\n";
- ! &check_log('^Sent by compilers-request.$', 38) == 1 || print "39\n";
- !
- ! `rm -rf dbr`; # Enable vacation messages
- !
- ! # Ensure vacation message is sent when mail was addressed to an alias
- !
- ! &replace_header('To: Raphael.Manfredi@acri.fr');
- ! &cleanup;
- ! &add_option('-o tome:rmanfredi,manfredi');
- ! `$cmd`;
- ! $? == 0 || print "40\n";
- ! -f "$user" && print "41\n"; # Mail has been deleted
- ! -f 'send.mail' || print "42\n"; # Assume OK at that point if mail exists
- !
- ! &replace_header('X-Tag: vacation'); # Restore non-matching header
- ! `rm -rf dbr`; # Enable vacation messages
- !
- ! &cleanup;
- ! &add_header('Illegal-Object: true'); # Will prevent vacation
- ! `$cmd`;
- ! $? == 0 || print "16\n";
- ! -f "$user" || print "17\n"; # Mail not saved, default rule applied
- ! -f 'send.mail' && print "18\n"; # No vacation message sent
- ! &get_log(19, $user);
- ! &check_log('^Illegal-Object:', 20) == 1 || print "21\n";
- !
- ! &cleanup;
- ! &replace_header('Illegal-Object:', 'mail', 'Illegal-Field: from');
- ! `$cmd`;
- ! $? == 0 || print "22\n";
- ! -f "$user" || print "23\n"; # Mail not saved, default rule applied
- ! -f 'send.mail' && print "24\n"; # No vacation message sent
- ! &get_log(25, $user);
- ! ¬_log('^Illegal-Object:', 26);
- ! &check_log('^Illegal-Field:', 27) == 1 || print "28\n";
-
- + # Last: 42
- &clear_mta;
- unlink 'mail', '.vacation';
- print "0\n";
-
- Index: agent/pl/filter.pl
- Prereq: 3.0.1.1
- *** agent/pl/filter.pl.old Fri Jul 1 17:16:16 1994
- --- agent/pl/filter.pl Fri Jul 1 17:16:17 1994
- ***************
- *** 1,4 ****
- ! ;# $Id: filter.pl,v 3.0.1.1 1994/01/26 09:31:43 ram Exp $
- ;#
- ;# Copyright (c) 1990-1993, Raphael Manfredi
- ;#
- --- 1,4 ----
- ! ;# $Id: filter.pl,v 3.0.1.2 1994/07/01 15:00:30 ram Exp $
- ;#
- ;# Copyright (c) 1990-1993, Raphael Manfredi
- ;#
- ***************
- *** 9,14 ****
- --- 9,17 ----
- ;# of the source tree for mailagent 3.0.
- ;#
- ;# $Log: filter.pl,v $
- + ;# Revision 3.0.1.2 1994/07/01 15:00:30 ram
- + ;# patch8: new UMASK command
- + ;#
- ;# Revision 3.0.1.1 1994/01/26 09:31:43 ram
- ;# patch5: added tags to UNIQUE and RECORD commands
- ;#
- ***************
- *** 597,602 ****
- --- 600,622 ----
- }
- $ever_saved = 1 if $saved; # Mark mail as saved if appropriate
- $saved ? $failed : 1; # Force failure if never saved
- + }
- +
- + # Run the UMASK command
- + sub run_umask {
- + local($mask) = $cmd =~ m|^\w+\s+(.*)|;
- + local($local); # True if -l option is given, for local setting
- + $local = $mask =~ s/^-l\s+//;
- + $mask = oct($mask) if $mask =~ /^0/;
- + if ($local) {
- + &u_mask'set($mask); # Record previous value, restored when leaving rule
- + } else {
- + umask($mask);
- + }
- + local($omask) = sprintf("0%o", $mask); # Octal string, for logging
- + $local = $local ? ' locally' : '';
- + &add_log("UMASK [$mfile] set to ${omask}$local") if $loglvl > 7;
- + 0; # Ok
- }
-
- # For SAVE, STORE or WRITE, the job is the same
-
- Index: agent/test/pl/filter.pl
- Prereq: 3.0
- *** agent/test/pl/filter.pl.old Fri Jul 1 17:16:29 1994
- --- agent/test/pl/filter.pl Fri Jul 1 17:16:30 1994
- ***************
- *** 1,16 ****
- # Common actions at the top of each filtering test
-
- ! # $Id: filter.pl,v 3.0 1993/11/29 13:50:23 ram Exp $
- ! #
- ! # Copyright (c) 1990-1993, Raphael Manfredi
- ! #
- ! # You may redistribute only under the terms of the Artistic License,
- ! # as specified in the README file that comes with the distribution.
- ! # You may reuse parts of this distribution only within the terms of
- ! # that same Artistic License; a copy of which may be found at the root
- ! # of the source tree for mailagent 3.0.
- ! #
- ! # $Log: filter.pl,v $
- ;# Revision 3.0 1993/11/29 13:50:23 ram
- ;# Baseline for mailagent 3.0 netwide release.
- ;#
- --- 1,19 ----
- # Common actions at the top of each filtering test
-
- ! ;# $Id: filter.pl,v 3.0.1.1 1994/07/01 15:10:19 ram Exp $
- ! ;#
- ! ;# Copyright (c) 1990-1993, Raphael Manfredi
- ! ;#
- ! ;# You may redistribute only under the terms of the Artistic License,
- ! ;# as specified in the README file that comes with the distribution.
- ! ;# You may reuse parts of this distribution only within the terms of
- ! ;# that same Artistic License; a copy of which may be found at the root
- ! ;# of the source tree for mailagent 3.0.
- ! ;#
- ! ;# $Log: filter.pl,v $
- ! ;# Revision 3.0.1.1 1994/07/01 15:10:19 ram
- ! ;# patch8: now uses the cp_mail routine to copy mail
- ! ;#
- ;# Revision 3.0 1993/11/29 13:50:23 ram
- ;# Baseline for mailagent 3.0 netwide release.
- ;#
- ***************
- *** 18,26 ****
- do '../pl/init.pl';
- chdir '../out';
- do '../pl/mail.pl';
- ! `cp ../mail .`;
- $user = $ENV{'USER'};
- ! unlink "$user", 'agentlog';
- $cmd = "$mailagent -L $ENV{'LEVEL'} -r ../rules mail 2>/dev/null";
-
- # Re-create pattern list
- --- 21,29 ----
- do '../pl/init.pl';
- chdir '../out';
- do '../pl/mail.pl';
- ! &cp_mail; # From mail.pl
- $user = $ENV{'USER'};
- ! unlink $user, 'agentlog';
- $cmd = "$mailagent -L $ENV{'LEVEL'} -r ../rules mail 2>/dev/null";
-
- # Re-create pattern list
-
- Index: agent/test/pl/mail.pl
- Prereq: 3.0
- *** agent/test/pl/mail.pl.old Fri Jul 1 17:16:31 1994
- --- agent/test/pl/mail.pl Fri Jul 1 17:16:31 1994
- ***************
- *** 1,16 ****
- # Utilities to twinkle default mail message
-
- ! # $Id: mail.pl,v 3.0 1993/11/29 13:50:25 ram Exp $
- ! #
- ! # Copyright (c) 1990-1993, Raphael Manfredi
- ! #
- ! # You may redistribute only under the terms of the Artistic License,
- ! # as specified in the README file that comes with the distribution.
- ! # You may reuse parts of this distribution only within the terms of
- ! # that same Artistic License; a copy of which may be found at the root
- ! # of the source tree for mailagent 3.0.
- ! #
- ! # $Log: mail.pl,v $
- ;# Revision 3.0 1993/11/29 13:50:25 ram
- ;# Baseline for mailagent 3.0 netwide release.
- ;#
- --- 1,21 ----
- # Utilities to twinkle default mail message
-
- ! ;# $Id: mail.pl,v 3.0.1.1 1994/07/01 15:11:46 ram Exp $
- ! ;#
- ! ;# Copyright (c) 1990-1993, Raphael Manfredi
- ! ;#
- ! ;# You may redistribute only under the terms of the Artistic License,
- ! ;# as specified in the README file that comes with the distribution.
- ! ;# You may reuse parts of this distribution only within the terms of
- ! ;# that same Artistic License; a copy of which may be found at the root
- ! ;# of the source tree for mailagent 3.0.
- ! ;#
- ! ;# $Log: mail.pl,v $
- ! ;# Revision 3.0.1.1 1994/07/01 15:11:46 ram
- ! ;# patch8: fixed RCS leading comment string
- ! ;# patch8: now defines the cp_mail routine
- ! ;# patch8: the replace_header routine can now supersede header lines
- ! ;#
- ;# Revision 3.0 1993/11/29 13:50:25 ram
- ;# Baseline for mailagent 3.0 netwide release.
- ;#
- ***************
- *** 31,39 ****
- rename("$file.x", "$file");
- }
-
- ! # Change first matching header with new value
- sub replace_header {
- ! local($header, $file) = @_;
- $file = 'mail' unless $file;
- local($field) = $header =~ /^(\S+):/;
- local($_);
- --- 36,50 ----
- rename("$file.x", "$file");
- }
-
- ! # Change first matching header with new value. If $supersede is given, then
- ! # the it is used instead. This enables:
- ! # &replace_header('To:', 'xxx', 'Cc: me')
- ! # to replace the whole first To: line by a Cc: header. If this third argument
- ! # is not supplied, then the first one is used verbatim, which is the case in
- ! # most calls to this routine.
- sub replace_header {
- ! local($header, $file, $supersede) = @_;
- ! $supersede = $header unless defined $supersede;
- $file = 'mail' unless $file;
- local($field) = $header =~ /^(\S+):/;
- local($_);
- ***************
- *** 41,47 ****
- open(OLD, "$file");
- while (<OLD>) {
- if ((1../^$/) && eval "/^$field:/") {
- ! print NEW $header, "\n";
- next;
- }
- print NEW;
- --- 52,58 ----
- open(OLD, "$file");
- while (<OLD>) {
- if ((1../^$/) && eval "/^$field:/") {
- ! print NEW $supersede, "\n";
- next;
- }
- print NEW;
- ***************
- *** 58,62 ****
- --- 69,83 ----
- open(NEW, ">>$file");
- print NEW $line, "\n";
- close NEW;
- + }
- +
- + # Copy mail in out/
- + sub cp_mail {
- + local($_);
- + open(MAIL, '../mail');
- + open(HERE, '>mail');
- + print HERE while <MAIL>;
- + close MAIL;
- + close HERE;
- }
-
-
- Index: agent/filter/io.c
- Prereq: 3.0.1.1
- *** agent/filter/io.c.old Fri Jul 1 17:16:03 1994
- --- agent/filter/io.c Fri Jul 1 17:16:03 1994
- ***************
- *** 11,17 ****
- */
-
- /*
- ! * $Id: io.c,v 3.0.1.1 1994/01/26 09:27:13 ram Exp $
- *
- * Copyright (c) 1990-1993, Raphael Manfredi
- *
- --- 11,17 ----
- */
-
- /*
- ! * $Id: io.c,v 3.0.1.2 1994/07/01 14:52:04 ram Exp $
- *
- * Copyright (c) 1990-1993, Raphael Manfredi
- *
- ***************
- *** 22,27 ****
- --- 22,30 ----
- * of the source tree for mailagent 3.0.
- *
- * $Log: io.c,v $
- + * Revision 3.0.1.2 1994/07/01 14:52:04 ram
- + * patch8: now honours the queuewait config variable when present
- + *
- * Revision 3.0.1.1 1994/01/26 09:27:13 ram
- * patch5: now only try to include <sys/fcntl.h> when hope is lost
- * patch5: filter will now put itself in daemon state while waiting
- ***************
- *** 76,81 ****
- --- 79,85 ----
- #define BUFSIZE 1024 /* Amount of bytes read in a single call */
- #define CHUNK (10 * BUFSIZE) /* Granularity of pool */
- #define MAX_STRING 2048 /* Maximum string's length */
- + #define QUEUE_WAIT 60 /* Default waiting time in queue */
- #define AGENT_WAIT "agent.wait" /* File listing out-of-the-queue mails */
- #define AGENT_LOCK "perl.lock" /* Lock file used by mailagent */
-
- ***************
- *** 306,311 ****
- --- 310,316 ----
- int xstat; /* The exit status value */
- int pid; /* Pid of our children */
- int res; /* Result from wait */
- + int delay; /* Delay in seconds before invoking mailagent */
-
- if (loglvl <= 20) { /* Loggging level higher than 20 is for tests */
- pid = fork();
- ***************
- *** 320,325 ****
- --- 325,336 ----
- goto_daemon(); /* Remaining child is to disassociate from tty */
- }
-
- + /*
- + * Compute waiting delay, defaults to QUEUE_WAIT seconds if not defined.
- + */
- +
- + delay = get_confval("queuewait", CF_DEFAULT, QUEUE_WAIT);
- +
- /* Now hopefully we detached ourselves from sendmail, which thinks the mail
- * has been delivered. Not yet, but close. Simply wait a little in case
- * more mail is comming. This process is going to remain alive while the
- ***************
- *** 329,335 ****
- */
-
- if (loglvl < 12) /* Loggging level 12 and higher is for debugging */
- ! sleep(60); /* Delay invocation of mailagent */
- progpid = getpid(); /* This may be the child (if fork succeded) */
- envp = make_env(); /* Build new environment */
-
- --- 340,346 ----
- */
-
- if (loglvl < 12) /* Loggging level 12 and higher is for debugging */
- ! sleep(delay); /* Delay invocation of mailagent */
- progpid = getpid(); /* This may be the child (if fork succeded) */
- envp = make_env(); /* Build new environment */
-
-
- Index: agent/filter/lock.c
- Prereq: 3.0
- *** agent/filter/lock.c.old Fri Jul 1 17:16:03 1994
- --- agent/filter/lock.c Fri Jul 1 17:16:04 1994
- ***************
- *** 11,17 ****
- */
-
- /*
- ! * $Id: lock.c,v 3.0 1993/11/29 13:48:12 ram Exp $
- *
- * Copyright (c) 1990-1993, Raphael Manfredi
- *
- --- 11,17 ----
- */
-
- /*
- ! * $Id: lock.c,v 3.0.1.1 1994/07/01 14:52:28 ram Exp $
- *
- * Copyright (c) 1990-1993, Raphael Manfredi
- *
- ***************
- *** 22,27 ****
- --- 22,30 ----
- * of the source tree for mailagent 3.0.
- *
- * $Log: lock.c,v $
- + * Revision 3.0.1.1 1994/07/01 14:52:28 ram
- + * patch8: now honours the lockhold config variable if present
- + *
- * Revision 3.0 1993/11/29 13:48:12 ram
- * Baseline for mailagent 3.0 netwide release.
- *
- ***************
- *** 29,34 ****
- --- 32,38 ----
-
- #include "config.h"
- #include "portable.h"
- + #include "parser.h"
- #include <errno.h>
- #include <sys/types.h>
- #include <sys/stat.h>
- ***************
- *** 95,104 ****
- char *file;
- {
- /* Make sure the lock file is not older than MAX_TIME seconds, otherwise
- ! * unlink it (something must have gone wrong).
- */
-
- struct stat buf;
-
- if (-1 == stat(file, &buf)) { /* Stat failed */
- if (errno == ENOENT) /* File does not exist */
- --- 99,110 ----
- char *file;
- {
- /* Make sure the lock file is not older than MAX_TIME seconds, otherwise
- ! * unlink it (something must have gone wrong). If the lockhold parameter
- ! * is set in ~/.mailagent, use that instead for timeout.
- */
-
- struct stat buf;
- + int hold; /* Lockfile timeout */
-
- if (-1 == stat(file, &buf)) { /* Stat failed */
- if (errno == ENOENT) /* File does not exist */
- ***************
- *** 108,120 ****
- return;
- }
-
- ! if (time((Time_t *) 0) - buf.st_mtime > MAX_TIME) {
- if (-1 == unlink(lockfile)) {
- add_log(1, "SYSERR unlink: %m (%e)");
- add_log(4, "WARNING could not remove old lock %s", lockfile);
- } else
- ! add_log(6, "UNLOCKED filter (lock older than 1 hour)");
- } else
- ! add_log(16, "lockfile for filter is recent");
- }
-
- --- 114,136 ----
- return;
- }
-
- ! /*
- ! * Get lockhold if defined, or use hardwired MAX_TIME.
- ! */
- !
- ! hold = get_confval("lockhold", CF_DEFAULT, MAX_TIME);
- !
- ! /*
- ! * Break lock if older than 'hold' seconds, otherwise honour it.
- ! */
- !
- ! if (time((Time_t *) 0) - buf.st_mtime > hold) {
- if (-1 == unlink(lockfile)) {
- add_log(1, "SYSERR unlink: %m (%e)");
- add_log(4, "WARNING could not remove old lock %s", lockfile);
- } else
- ! add_log(6, "UNLOCKED filter (lock older than %d seconds)", hold);
- } else
- ! add_log(16, "lockfile for filter is recent (%d seconds or less), hold");
- }
-
-
- Index: agent/test/actions
- Prereq: 3.0.1.4
- *** agent/test/actions.old Fri Jul 1 17:16:24 1994
- --- agent/test/actions Fri Jul 1 17:16:24 1994
- ***************
- *** 2,8 ****
- # Mailagent rules for action regression tests
- #
-
- ! # $Id: actions,v 3.0.1.4 1994/04/25 15:24:12 ram Exp $
- #
- # Copyright (c) 1990-1993, Raphael Manfredi
- #
- --- 2,8 ----
- # Mailagent rules for action regression tests
- #
-
- ! # $Id: actions,v 3.0.1.5 1994/07/01 15:06:56 ram Exp $
- #
- # Copyright (c) 1990-1993, Raphael Manfredi
- #
- ***************
- *** 13,18 ****
- --- 13,23 ----
- # of the source tree for mailagent 3.0.
- #
- # $Log: actions,v $
- + # Revision 3.0.1.5 1994/07/01 15:06:56 ram
- + # patch8: added exit status test for PERL command
- + # patch8: added new test for vacation message with tome config variable
- + # patch8: new set of tests for the new UMASK command
- + #
- # Revision 3.0.1.4 1994/04/25 15:24:12 ram
- # patch7: check bug reported by Andy Seaborne <afs@hplb.hpl.hp.com>
- #
- ***************
- *** 156,161 ****
- --- 161,167 ----
- }
-
- X-Tag: /perl/ { REJECT PERL };
- + <PERL> { PERL perl.2 exit_1; REJECT -t; SAVE exit_ok; REJECT };
- <PERL> { PERL perl.1; SAVE never };
- <PERL> { PERL perl.2 'arg 1' "arg 2"; SAVE never };
- <PERL> { PERL perl.1; SAVE never };
- ***************
- *** 281,286 ****
- --- 287,341 ----
- DELETE;
- }
-
- + X-Tag: /umask #1/ { REJECT UMASK; };
- + <UMASK> {
- + UMASK -l 0444;
- + PERL umask_is 0444;
- + REJECT -f UMASKF;
- + SAVE ok.1;
- + REJECT;
- + };
- + <UMASK> {
- + PERL umask_is %=umask;
- + REJECT -f UMASKF;
- + SAVE ok.2;
- + UMASK 0555;
- + REJECT;
- + };
- + <UMASK> {
- + PERL umask_is 0555;
- + REJECT -f UMASKF;
- + DELETE;
- + };
- +
- + X-Tag: /umask #2/ { REJECT UMASK; };
- + <UMASK> {
- + UMASK 0444;
- + PERL umask_is 0444;
- + REJECT -f UMASKF;
- + SAVE ok.1;
- + UMASK -l 0555;
- + PERL umask_is 0555;
- + REJECT -f UMASKF;
- + REJECT;
- + };
- + <UMASK> {
- + PERL umask_is 0444;
- + REJECT -f UMASKF;
- + SAVE ok.2;
- + };
- +
- + X-Tag: /umask #3/ { REJECT UMASK; };
- + <UMASK> {
- + PERL umask_is 0555;
- + REJECT -t UMASKF;
- + PERL umask_is %=umask;
- + REJECT -f UMASKF;
- + SAVE ok.3;
- + };
- +
- + <UMASKF> { SAVE never; };
- +
- X-Tag: /unique #1/ { UNIQUE; SAVE %u.1 };
- <_SEEN_> X-Tag: /unique #1/ { SAVE %u.1 };
- X-Tag: /unique #1/ { SAVE %u.2 };
- ***************
- *** 295,300 ****
- --- 350,357 ----
- X-Tag: /unique #6/ { UNIQUE (tag); REJECT -f; SAVE %u.1; REJECT };
- X-Tag: /unique #6/ { UNIQUE (other); REJECT -f; SAVE %u.2; REJECT };
- X-Tag: /unique #6/ { UNIQUE -a; SAVE %u.3 };
- +
- + X-Tag: /vacation #2/ { DELETE };
-
- X-Tag: /write #1/ { WRITE mbox };
- X-Tag: /write #2/ { WRITE path/another/third/mbox };
-
- Index: agent/filter/parser.c
- Prereq: 3.0.1.1
- *** agent/filter/parser.c.old Fri Jul 1 17:16:05 1994
- --- agent/filter/parser.c Fri Jul 1 17:16:05 1994
- ***************
- *** 11,17 ****
- */
-
- /*
- ! * $Id: parser.c,v 3.0.1.1 1994/01/26 09:27:37 ram Exp $
- *
- * Copyright (c) 1990-1993, Raphael Manfredi
- *
- --- 11,17 ----
- */
-
- /*
- ! * $Id: parser.c,v 3.0.1.2 1994/07/01 14:53:57 ram Exp $
- *
- * Copyright (c) 1990-1993, Raphael Manfredi
- *
- ***************
- *** 22,27 ****
- --- 22,30 ----
- * of the source tree for mailagent 3.0.
- *
- * $Log: parser.c,v $
- + * Revision 3.0.1.2 1994/07/01 14:53:57 ram
- + * patch8: new routine get_confval to get integer config variables
- + *
- * Revision 3.0.1.1 1994/01/26 09:27:37 ram
- * patch5: typo fix in a comment
- *
- ***************
- *** 34,39 ****
- --- 37,43 ----
- #include "portable.h"
- #include "hash.h"
- #include "msg.h"
- + #include "parser.h"
- #include <sys/types.h>
- #include "logfile.h"
- #include "environ.h"
- ***************
- *** 161,170 ****
- fatal("logfile not defined");
- strcat(logfile, value);
-
- ! value = ht_value(&symtab, "level"); /* Fetch logging level */
- ! if (value == (char *) 0)
- ! fatal("no logging level defined");
- ! sscanf(value, "%d", &level);
-
- set_loglvl(level); /* Logging level wanted */
- if (-1 == open_log(logfile))
- --- 165,171 ----
- fatal("logfile not defined");
- strcat(logfile, value);
-
- ! level = get_confval("level", CF_MANDATORY);
-
- set_loglvl(level); /* Logging level wanted */
- if (-1 == open_log(logfile))
- ***************
- *** 287,292 ****
- --- 288,325 ----
- if (-1 == set_env("TZ", tz))
- add_log(1, "ERROR cannot set TZ variable");
- }
- + }
- +
- + public int get_confval(name, type, dflt)
- + char *name; /* Option name */
- + int type; /* Type: mandatory or may be defaulted */
- + int dflt; /* Default value to be used if option not defined */
- + {
- + /* Return value for option and use default if not defined, or yield a
- + * fatal error when option is mandatory.
- + */
- +
- + char buffer[MAX_STRING];
- + char *namestr; /* String in H table */
- + int val; /* Returned value */
- +
- + namestr = ht_value(&symtab, name);
- + if (namestr == (char *) 0) {
- + switch(type) {
- + case CF_MANDATORY: /* Variable should have been defined */
- + sprintf(buffer, "variable '%s' not defined in config file", name);
- + fatal(buffer);
- + /* NOTREACHED */
- + case CF_DEFAULT: /* May use default if variable not defined */
- + val = dflt;
- + break;
- + default:
- + fatal("BUG: get_confval");
- + }
- + } else
- + sscanf(namestr, "%d", &val);
- +
- + return val;
- }
-
- private void substitute(value)
-
- Index: config_h.SH
- Prereq: 3.0.1.1
- *** config_h.SH.old Fri Jul 1 17:16:33 1994
- --- config_h.SH Fri Jul 1 17:16:33 1994
- ***************
- *** 25,31 ****
- * that running config.h.SH again will wipe out any changes you've made.
- * For a more permanent change edit config.sh and rerun config.h.SH.
- *
- ! * \$Id: config_h.SH,v 3.0.1.1 1994/01/26 09:36:20 ram Exp $
- */
-
- /* Configuration time: $cf_time
- --- 25,31 ----
- * that running config.h.SH again will wipe out any changes you've made.
- * For a more permanent change edit config.sh and rerun config.h.SH.
- *
- ! * \$Id: config_h.SH,v 3.0.1.2 1994/07/01 15:15:19 ram Exp $
- */
-
- /* Configuration time: $cf_time
- ***************
- *** 103,109 ****
- /* HAS_STRERROR:
- * This symbol, if defined, indicates that the strerror routine is
- * available to translate error numbers to strings. See the writeup
- ! * of strerror() in this file before you try to define your own.
- */
- /* HAS_SYS_ERRLIST:
- * This symbol, if defined, indicates that the sys_errlist array is
- --- 103,109 ----
- /* HAS_STRERROR:
- * This symbol, if defined, indicates that the strerror routine is
- * available to translate error numbers to strings. See the writeup
- ! * of Strerror() in this file before you try to define your own.
- */
- /* HAS_SYS_ERRLIST:
- * This symbol, if defined, indicates that the sys_errlist array is
- ***************
- *** 115,121 ****
- * available to translate an errno code into its symbolic name (e.g.
- * ENOENT). The extern int sys_nerrno gives the size of that table.
- */
- ! /* strerror:
- * This preprocessor symbol is defined as a macro if strerror() is
- * not available to translate error numbers to strings but sys_errlist[]
- * array is there.
- --- 115,121 ----
- * available to translate an errno code into its symbolic name (e.g.
- * ENOENT). The extern int sys_nerrno gives the size of that table.
- */
- ! /* Strerror:
- * This preprocessor symbol is defined as a macro if strerror() is
- * not available to translate error numbers to strings but sys_errlist[]
- * array is there.
- ***************
- *** 123,129 ****
- #$d_strerror HAS_STRERROR /**/
- #$d_syserrlst HAS_SYS_ERRLIST /**/
- #$d_sysernlst HAS_SYS_ERRNOLIST /**/
- ! #$d_strerrm strerror(e) ((e)<0||(e)>=sys_nerr?"unknown":sys_errlist[e]) /**/
-
- /* Time_t:
- * This symbol holds the type returned by time(). It can be long,
- --- 123,129 ----
- #$d_strerror HAS_STRERROR /**/
- #$d_syserrlst HAS_SYS_ERRLIST /**/
- #$d_sysernlst HAS_SYS_ERRNOLIST /**/
- ! #define Strerror(e) $d_strerrm
-
- /* Time_t:
- * This symbol holds the type returned by time(). It can be long,
-
- *** End of Patch 9 ***
-
- exit 0 # Just in case...
-