filter2.6.3/0000755000127400000010000000000010162732015013013 5ustar philother00000000000000filter2.6.3/bin/0000755000127400000010000000000007076526205013577 5ustar philother00000000000000filter2.6.3/doc/0000755000127400000010000000000007743720411013570 5ustar philother00000000000000filter2.6.3/doc/filter.1.orig0000644000127400000010000000703106510363357016102 0ustar philother00000000000000.if n \{\ . ds ct " .\} .if t \{\ . ds ct \\(co .\} .TH FILTER 1L "Elm Version 2.4" "USENET Community Trust" .SH NAME filter - filter incoming messages before adding to mailbox .SH SYNOPSIS .B filter [-q] [-v] [-l] [-o output] [-f rules-file] .br .B filter [-n] [-f rules-file] .br .B filter [-r] [-o output] [-f rules-file] .br .B filter [-c] [-s] [-o output] [-f rules-file] .br .B filter [-c] [-S] [-o output] [-f rules-file] .SH DESCRIPTION .I Filter uses a set of selection rules to process incoming mail messages. The format for the rules, located in $HOME/.elm/filter-rules, is; .nf \fIrule\fR ::= \fBif (\fIexpression\fP) then \fIaction\fR .fi where \fIexpression\fR is: .nf \fIexpression\fR ::= { \fBnot\fR } \fIcondition\fR \fIexpr2\fR \fIexpr2\fR ::= \fINULL\fR | \fBand\fI condition expr2 \fIcondition\fR ::= \fIfield relationship value\fR ::= \fBlines\fI relop numvalue\fR or ::= \fBalways\fR .fi These further break down as: .nf \fIfield\fR ::= \fBfrom\fR | \fBsubject\fR | \fBto\fR | \fBlines\fR | \fBsender\fR \fIrelationship\fR ::= \fB=\fR | \fB!=\fR \fIrelop\fR ::= \fB=\fR | \fB!=\fR | \fB<\fR | \fB>\fR | \fB<=\fR | \fB>=\fR \fIvalue\fR ::= \fIany quoted string\fR \fInumvalue\fR ::= \fIany integer value\fR .fi \fIAction\fR can be any of: .nf \fBdelete\fR \fBsave \fIfoldername\fR \fBsavecopy \fIfoldername\fR \fBexecute \fIcommand\fR \fBexecutec \fIcommand\fR \fBforward \fIaddress\fR \fBleave\fR .fi For further information about the rules language, please see \fIThe Elm Filter Guide\fR. .sp The flags the \fIfilter\fR program understands are; .TP 1.0i .B "-c" Clear logs. If this flag is used, the log files will be removed after being summarized by either "-s" or "-S" (see below). .TP \fB-f \fIrules-file\fR Get rules from specified file instead of default $HOME/.elm/filter-rules .TP .B "-l" Log actions only. Do not log information about mailed messages. .TP .B "-n" Not really. Output what would happen if given message from standard input, but don't actually do anything with it. .TP \fB-o \fIfile\fR Redirect stdout messages to the specified file or device. Logging of filter actions is not affected. (This is added to more gracefully deal with changes in the file system (since sendmail is quite picky about modes of files being redirected into.)) .TP .B "-q" Quiet. Do not log filtering actions. .TP .B "-r" Rules. List the rules currently being used. .TP .B "-s" Summarize. List a summary of the message filtering log. .TP .B "-S" This is the same as `-s' but includes message-by-message information additionally. .TP .B "-v" Verbose. Give output on standard out for each message filtered. Useful to have redirected to ``/dev/console'' and such. (see \fB-o\fR too). .SH AUTHOR Elm Development Group .SH FILES $HOME/.elm/filter-rules Default rules file .br $HOME/.elm/filterlog A log of what has been done .br $HOME/.elm/filtersum A summary of what has been done .br /etc/passwd Used to get users home directory .SH SEE ALSO .I "The Elm Filter Guide" .br readmsg(1L), elm(1L), mail(1), mailx(1), sendmail(1,8) .SH COMMENTS Not really smart about pattern matching. .SH BUG REPORTS TO Syd Weinstein elm@DSI.COM (dsinc!elm) .SH COPYRIGHTS \fB\*(ct\fRCopyright 1988-1992 by The USENET Community Trust .br Derived from Elm 2.0, \fB\*(ct\fR Copyright 1986, 1987 by Dave Taylor filter2.6.3/doc/Filter.guid0000644000127400000010000005057607744677075015726 0ustar philother00000000000000.\" @(#)$Id: Filter.guid,v 5.7 1993/04/16 04:11:29 syd Exp $ .\" .\" A guide to the Elm Filter program .\" format with: .\" 'troff Filter.guid > Filter.format' .\" .\" (C) Copyright 1986,1987 Dave Taylor .\" (C) Copyright 1988-1992 Usenet Community Trust .\" .\" Elm is now in the public trust. Bug reports, comments, suggestions, flames .\" etc. should go to: .\" Syd Weinstein elm@DSI.COM (dsinc!elm) .\" .\" $Log: Filter.guid,v $ .\" Revision 5.7 1993/04/16 04:11:29 syd .\" Fix wrong variable used in shell script .\" From: Bruce Tindall .\" .\" Revision 5.6 1993/04/12 01:46:12 syd .\" Update for quotes .\" From: dwolfe@pffft.sps.mot.com (Dave Wolfe) .\" .\" Revision 5.5 1993/01/27 19:45:15 syd .\" Filter turns spaces in quoted strings into _ and then back again. This destroys .\" any _ that where there in the first place. This patch removes that. .\" Also fixed a minor bug where 'filter -r' wrote out the wrong thing if the .\" relation in a rule was '~'. .\" From: Jan Djarv .\" .\" Revision 5.4 1993/01/27 19:40:01 syd .\" I implemented a change to filter's default verbose message format .\" including %x %X style date and time along with username .\" From: mark@drd.com (Mark Lawrence) .\" .\" Revision 5.3 1992/12/24 23:48:05 syd .\" make Nroff not use co symbol, just the word .\" From: Syd via request from Tim Pierce .\" .\" Revision 5.2 1992/11/15 01:41:50 syd .\" Add regexp processing to filter. .\" Add execc operator .\" From: Jan Djarv .\" .\" Revision 5.1 1992/10/03 20:51:50 syd .\" Initial checkin as of 2.4 Release at PL0 .\" .\" .po 1i .ds h0 .ds h1 .ds h2 .ds f0 .ds f1 .ds f2 .nr Hy 1 .nr Pt 1 .nr Pi 8 .lg 0 .nf .na .rs .za .sp |3.0i .ce 99 .ps 20 .ss 18 .vs 12 \f3The Elm Filter System Guide\f1 .sp 4 .ps 12 .ss 14 .vs 14 \f2What the filter program is, what it does, and how to use it\f1 .sp 3 Filter, version 2.0 .sp 2 Now maintailed by Philip Brown http://www.bolthole.com/filter/ .sp email: filter\s-1@\s+1bolthole.com .sp |9.0i \s18\f3\*(ct\f1\s12 Copyright 1986,1987 by Dave Taylor \s18\f3\*(ct\f1\s12 Copyright 1988-1992 by The USENET Community Trust .fi .ad .bp 1 .sv 5v .ps 14 .ss 12 .vs 16 \f3The Elm Filter System Guide\f1 .ds h0 "Elm Filter Guide .ds h1 .ds h2 "Version 2.4 .ds f0 "October 1, 1992 .ds f1 .ds f2 "Page % .sp .ps 10 .ss 12 .vs 12 (originally in The Elm Mail System, \*(h2) .sp \*(f0 .sp 2 Syd Weinstein Datacomp Systems, Inc. 3837 Byron Road Huntingdon Valley, PA 19006-2320 .sp email: elm\s-1@\s+1DSI.COM or dsinc\s-1!\s+1elm .sp 2 Derived from \*QThe Elm Mail System, Version 2.0\*U by Dave Taylor Intuitive Systems Mountain View, California .ce 0 .sp 3 One of the greatest problems with the burgeoning electronic mail explosion is that I tend to get lots of mail that I don't care about. Amusingly, perhaps, I have the equivalent of electronic junk mail. Not amusing, however, is the fact that this can rapidly accumulate and end up taking over my mailbox. .sp At the same time I often get mail that, while it is interesting and important, can easily be filed to be read later, without ever actually having to clutter up my incoming mailbox. .sp This, then, is what \f2filter\f1 does! The \f2filter\f1 program allows you to define a set of rules by which all incoming mail is screened, and a subsequent set of actions to perform based on whether the conditions are met or not. \f2Filter\f1 also has the ability to mail a summary of what actions it performed on the incoming mail as often as you'd like. .ne 5 .hu Writing the Rules .sp The language for writing \f2filter\f1 rules is pretty simple, actually. The fundamental structure is: .nf .ti .5i if (\f2condition\f1) then \f2action\f1 .fi Where \f2condition\f1 is constructed by an arbitrary number of individual conditions of the form \*Q\f2field\f1 \f2relation\f1 \f2value\f1\*U (an optional further type of rule is of the form \*Qalways \f2action\f1\*U but should only be used as the last rule in the ruleset, for obvious reasons). The \f2field\f1 value can be: .sp .nf .in .5i subject (or alphasubject) sender from to lines .in 0 .fi .sp For the field \f3lines\f1, the \f2relation\f1 can be any of the standard relationships (\*q>\*u, \*q<\*u, \*q>=\*u, \*q<=\*u, \*q!=\*u and \*q=\*u). \f3contains\f1 is equivalent to the relation \*q=\*u or you can skip the relationship entirely (e.g. \*Qsubject = "joe"\*U, \*Qsubject contains "joe"\*U, and \*Qsubject "joe"\*U are all equivalent). The \f2value\f1 is any quoted string that is to be matched against or a number if \f3lines\f1 is the \f2field\f1 being considered. .sp The relation \f3matches\f1 (or \*q~\*u) takes an \f2egrep\f1 like regular expression as the \f2value\f1. The regular expression must be enclosed in pairs of \*q/\*u. If you need a \*q/\*u in your expression write it as .ie t \*Q\\\ /\*U. .el \*Q\\/\*U. .sp Individual conditions are joined together by using the word \f3and\f1, and the logic of a condition can be flipped by using \f3not\f1 as the first word (e.g. \*Qsubject "fun" and not subject "games"\*U). We'll see more examples of this later. .sp Note that the \*Qor\*U logical conjunction isn't a valid part of the \f2filter\f1 conditional statement. .sp Finally, \f2action\f1 can be any of: .sp .nr TW \w'savecopy \f2foldername\f1\0\0\0'u .si .5i .ad l .lp \f3Action \n(TWu Description .ft 1 .lp "delete" \n(TWu Deletes the message .lp "save \f2foldername\f1" \n(TWu Saves a copy of the message in the specified foldername. .lp "savecopy \f2foldername\f1" \n(TWu Does the same as save, but also puts a copy in your mailbox. .lp "forward \f2address\f1" \n(TWu Sends the message to the specified address. .lp "forwardc \f2address\f1" \n(TWu Sends the message to the specified address and leaves a copy in your mailbox. .lp "resend \f2address\f1" \n(TWu Resends the message to the specified address. NOTE: sendmail and other mailers will tend to set your "real" address in the "envelope". So a careful examination of the new email headers will show your address, but a normal glance at the presentation by most mailers will not. .lp "execute \f2command\f1" \n(TWu Feeds the message to the specified command (or complex sequence of commands) as standard input. .lp "executec \f2command\f1" \n(TWu Like \f3execute\f1 but also leaves a copy in your mailbox. .lp "leave" \n(TWu Leaves the message in your mailbox. .ad .ei .in 0 .sp Note that the \f3execute\f1 command assumes that you are doing something useful with incoming mail. The command does \f2not\f1 automatically append the message to your mail spool. Use \f3executec\f1 for that. A command such as: .sp .ft CW .zf .nf .ti .5i if (from = "dave") then execute "echo mail from dave > /dev/tty" .ft 1 .fi .sp will result in \f2losing\f1 your mail. A more suitable use for execute would be: .sp .ft CW .zf .nf .ti .5i if (from = "boss") then execute "vacation pat" .ft 1 .fi .sp Foldernames can contain any of a number of macros, too, as we'll see in the example ruleset below. The macros available for the string fields are: .sp .ne 5 .nr TW \w'%1-%9\0\0\0'u .si .5i .ad l .lp \f3Macro \n(TWu Meaning .ft 1 .lp "%d" \n(TWu day of the month .lp "%D" \n(TWu day of the week (0-6) .lp "%h" \n(TWu hour of the day (0-23) .lp "%m" \n(TWu month of the year (1-12) .lp "%r" \n(TWu return address of message .lp "%s" \n(TWu subject of original message .lp "%S" \n(TWu \*QRe: \f2subject of original message\f1\*U .lp "%t" \n(TWu current hour and minute in HH:MM format .lp "%y" \n(TWu year (last two digits) .lp "%Y" \n(TWu year (4-digit) .lp "%&" \n(TWu the string that matched the last regular expression .lp "%1-%9" \n(TWu the corresponding subexpression in the last regular expression that matched .ad .ei .in 0 .sp If a message has a subject of \*QThis is a test\*U, and the rule is .sp .ft CW .zf .nf .ti .5i if (subject matches /([a\-z]+) a ([a\-z]+)/) then "echo %& %1 %2" .ft 1 .fi .sp then \f3%&\f1 expands to \*Qis a test\*U, \f3%1\f1 expands to \*Qis\*U and \f3%2\f1 expands to \*Qtest\*U. .sp Foldernames may contain a leading \*Q~/\*U which expands to your home directory. .sp The rules file can also contain comments (any line starting with a \*q#\*u) and blank lines. Metacharacters may be escaped by a preceding \*q\\\*u to remove any special meaning. If you need a \*q%\*u character as part of an argument (such as an address), use \*Q\\%\*U. If you need a double quote in a double quoted string, use \*Q\\"\*U. If you need a single quote in a single quoted string, use \*Q\\\'\*U. If you need a backslash in any kind of string, use \*Q\\\\\*U. .sp Unless you specify an alternate file via the \f3\-f\f1 option, the rules file needs to reside in your \f2.filter\f1 directory off your home directory and be called \f2.filter/filter\-rules\f1. Here's an example: .sp .nf .ft CW .zf # $HOME/.filter/filter\-rules # # Filter rules for the Elm Filter program. Don\'t change without some # serious thought. (remember \- order counts) # # (for Dave Taylor) # rule 1 if (from contains "!uucp") then delete # rule 2 to "postmaster" ? save "/tmp/postmaster\-mail.%d" # rule 3 if (to "culture" and lines > 20) ? save "~/Mail/culture" # rule 4 subject = "filter test" ? forward "hpldat!test" # rule 5 if [ subject = "elm" ] savecopy "~/Mail/elm\-incoming" # rule 6 subject = "display\-to\-console" ? execute "cat \- > /dev/console" .fi .ft 1 .sp (Notice the loose syntax \(em there are lots of valid ways to specify a rule in the \f2filter\f1 program!!) .sp To translate these into English: .sp .nr TW \w'1. 'u .in .5i .ti -\n(TWu 1. All messages from \*Quucp\*U should be summarily deleted. .ti -\n(TWu 2. All mail to \*Qpostmaster\*U should be saved in a folder (file) called \f2/tmp/postmaster\-mail.n\f1, where \f2n\f1 is the numeric-day-of-the-week. .ti -\n(TWu 3. All mail addressed to \*Qculture\*U with at least 20 lines should be automatically appended to the folder \f2$HOME/Mail/culture\f1. .ti -\n(TWu 4. All messages that contain the subject \*Qfilter test\*U should be forwarded to me, but via the address \*Qhpldat!test\*U (to force a non-user forward). .ti -\n(TWu 5. All messages with a subject that contains the word \*Qelm\*U should be saved in the folder \f2$HOME/Mail/elm\-incoming\f1 and also dropped into my mailbox. .ti -\n(TWu 6. Any message with the subject \*Qdisplay-to-console\*U will be immediately written to the console. .in 0 .sp Notice that the \f2order\f1 of the rules is very important. If we, for example, were to get a message from \*Quucp\*U that had the subject \*Qfilter test\*U, the \f2filter\f1 program would match rule 1 and delete the message. It would never be forwarded to \*Qhpldat!test\*U. It is for this reason that great care should be taken with the ordering of the rules. .ne 5 .hu Checking the rules out .sp The \f2filter\f1 program has a convenient way of checking out the rules you have written. Simply invoke it with the \f3\-r\f1 (\f3rules\f1) option: .sp .nf .in .5i % \f3filter \-r\f1 .ft CW .zf .in .5i+\w'Rule 1: 'u .ti .5i Rule 1: if (from = "!uucp") then Delete .ti .5i Rule 2: if (to = "postmaster") then Save /tmp/postmaster\-mail.3 .ti .5i Rule 3: if (to = "culture" and lines > 20) then Save ~/Mail/culture .ti .5i Rule 4: if (subject = "filter test") then Forward hpldat!test .ti .5i Rule 5: if (subject="elm") then Copy and Save ~/Mail/elm\-incoming .ti .5i Rule 6: if (subject="display\-to\-console") then Execute "cat \- > /dev/console" .ft 1 .in 0 .fi .sp There are a few things to notice \(em first off, these are the parsed and rebuilt rules, so we see them all in a consistent format. Also, notice on the filename for rule 2 that \f2filter\f1 has correctly expanded the \f3%d\f1 macro to be the day of the week (in this case, Wednesday, denoted by the digit \*q3\*u). .sp It is \f3highly\f1 recommended that you always check your ruleset before actually using it to filter your mail! .ne 5 .hu Actually Using the Program .sp Now the bad news. If you aren't running \f2sendmail\f1 or some other Mail Transport Agent that supports delivery to a program you cannot use this program as currently written. Why? Because the \f2filter\f1 program expects to be put in your \f2.forward\f1 file (or equivalent concept for MTAs other than \f2sendmail\f1) that causes the messages to be delivered to the \f2filter\f1 program. That is something that only \f2sendmail\f1 and other smart MTAs look at! .sp The format for the entry in the \f2.forward\f1 file (located in your home directory) is simply: .sp .nf .ti .5i "|/usr/local/bin/filter" .fi .sp Alright, it isn't quite \f2that\f1 simple! Since \f2filter\f1 is invoked by processes that don't know where you are logged in, you need to have some way to trap the error messages. For ease of use, it was decided to have all the messages written to the file specified by \f3\-o\f1 (or \f2stderr\f1) which means that you have two main choices for the actual entry. Either: .sp .nf .ti .5i "|/usr/local/bin/filter \-o /dev/console" .fi .sp which will log all errors on the system console (each error is prefixed with \*Qfilter (\f2username\f1)\*U to distinguish it), or: .sp .nf .ti .5i "|/usr/local/bin/filter \-o /tmp/joe.filter_errors" .fi .sp if you want to have a copy saved to a file. Note that the quotes are a required part of the line. A possible strategy would be to have the errors written to a file and to then have a few lines in your \f2.login\f1 (or equivalent) script like: .sp .nf .ft CW .zf .in .5i+\w'if 'u .ti .5i if ( \-f /tmp/joe.filter_errors) then echo "\0" echo "Filter program errors;" cat /tmp/joe.filter_errors echo "\0" .ti .5i endif .ft 1 .in 0 .fi .sp You can also use the \f3\-v\f1 option in combination with the above to have a more verbose log file (including action taken with date/time stamp) saved by having in your \f2.forward\f1 file: .sp .ft CW .zf .nf .ti .5i "|/usr/local/bin/filter \-vo /tmp/joe.filter_errors" .ft 1 .fi .sp Suffice it to say, you can get pretty tricky with all this!! .ne 5 .hu Summarizing the Actions Taken .sp The \f2filter\f1 program can keep a log of all actions performed, including what rules it matched against, in your \f2.filter\f1 directory in a file called \f2.filter/filterlog\f1. You can either directly operate on this file, or, much more recommended, you can use one of the two summarization options to \f2filter\f1 and let \f2it\f1 do the work for you! .sp The difference between the two is best demonstrated by example: .sp .in .5i .nf % \f3filter \-s\f1 .ft CW .zf Summary of Filter Activity \l'\w'Summary of Filter Activity'u\&-' A total of 418 messages were filtered: The default rule of putting mail into your mailbox .in .5i+\w'Rule #1: 'u applied 364 times (87%) .ti .5i Rule #1: (delete message) applied 1 time (0%) .ti .5i Rule #2: (save in "~/Filtered\-Mail/netnews.12") applied 8 times (2%) .ti .5i Rule #3: (save in "~/Filtered\-Mail/postmaster.12") applied 14 times (3%) .ti .5i Rule #5: (save in "~/Filtered\-Mail/risks.12") applied 3 times (1%) .ti .5i Rule #6: (save in "~/Filtered\-Mail/rays.12") applied 28 times (7%) .ft 1 .sp .ti 0 versus: .sp .ti .5i % \f3filter \-S\f1 .ti .5i \f2[the output as listed above, followed by:]\f1 .ft CW .zf .ti .5i Explicit log of each action; .ti .5i Mail from taylor about Filter Summary PUT in mailbox: the default action .ti .5i Mail from news@hplabsz.hpl.hp.com about Newsgroup comp.editors created PUT in mailbox: the default action .ti .5i Mail from root about Log file: cleanuplog PUT in mailbox: the default action .ft 1 .ti .5i \f2[etc.]\f1 .in 0 .ft 1 .fi .sp To actually use either of the summarizing options, there are two ways that are recommended. The preferred way is to have a line in either your \f2crontab\f1 file (ask your administrator for help with this) that invokes the \f2filter\f1 program as often as you desire with the \f3\-s\f1 option. For example, I have a summary mailed to me every morning at 8 o'clock: .sp .nf .ft CW .zf .ti .5i 0 8 * * * "/usr/local/bin/filter \-s | elm \-s \'Filter Summary\' taylor" .ft 1 .fi .sp An alternative is to have your \f2.login\f1 (or equivalent) execute the command each time you log in. .sp Note that if you want to have your log files cleared out each time the summary is generated you'll need to use the \f3\-c\f1 option too. Also, if you want to keep a long list of actions performed you can do this by saving it as you display it. A way to do this would be, if you were to have the invocation in your \f2.login\f1 (or equivalent) script, to use: .sp .nf .in .5i .ft CW .zf echo "Filter Log;" filter \-c \-s | tee \-a PERM.filter.log\f1 .ft 1 .in 0 .fi .sp which would append a copy of all the output to the file \f2PERM.filter.log\f1 and would avoid you having to read larger and larger summaries of what the program had done. .sp If you prefer not to have \f2filter\f1 generate log files, use the \f3\-q\f1 option. Messages that are written to \f2stderr\f1 or the \f3\-o\f1 file are still generated; only message to the log files are quashed. .ne 5 .hu Further Testing of the Ruleset .sp Using the \f2readmsg\f1 command, it is quite easy to test the rules you've written to see if they do what you desire. .sp For example, we can use the \f3\-n\f1 option to \f2filter\f1, which means \*Qdon't actually do this, just tell me what rule you matched, if any, and what action you would have performed\*U (you can see why a single letter option is easier to type in!!), and feed it each message in our mailbox by using a command like: .sp .nf .in .5i % \f3set message=1\f1 % \f3set total_messages=\`messages\`\f1 % \f3while (1)\f1 > \f3if ($message > $total_messages) exit\f1 > \f3readmsg \-h $message | filter \-n\f1 > \f3@ message++\f1 > \f3end\f1 .in 0 .fi .sp which will then hand each of the messages in your mailbox to the \f2filter\f1 program and display what action would have been taken with that message and why. .sp For example, if we do this for a few interesting messages in my mailbox, we'd end up with output like: .sp .ft CW .zf .nf .in .5i Mail from taylor about filter test .ti +\w'Mail 'u FORWARDED to hpldat!taylor by rule; .ti +\w'Mail 'u subject="filter test" ? forward "hpldat!test" Mail from bradley%hplkab@hplabsc about Re: AI-ED mailing address for HP .ti +\w'Mail 'u PUT in mailbox: the default action Mail from taylor about display-to-console .ti +\w'Mail 'u EXECUTED "cat \- > /dev/console" .ft 1 .in 0 .fi .sp (Sharp users will notice that this is exactly the same format as the longer summary listing.) .ne 5 .hu What Forwarded Messages Look Like .sp When a message is forwarded to another user by the \f2action\f1 being specified as \*Q\f3forward\f1 \f2address\f1\*U, then \f2filter\f1 can generate one of two styles of message. If the message is to you, then it simply adds it to your mailbox in such a way as to ensure that the return address is that of the person who sent the message. .sp If not, then the message is enclosed in a message of the form: .sp .in .5i .ft CW .zf .nf \&From taylor Thu Oct 2 15:07:04 1986 \&Date: Thu, 2 Oct 86 15:06:58 pdt \&Subject: "filter test" \&From: The filter of taylor@hpldat \&To: hpldat!taylor \&X-Filtered-By: filter, version 1.4 \-\- Begin filtered message \-\- .in +\w'\-\- 'u \&From taylor Thu Oct 2 15:06:41 1986 \&Date: Thu, 2 Oct 86 15:06:33 pdt \&From: Dave Taylor \&Subject: filter test Just a simple test. .in -\w'\-\- 'u \-\- End of filtered message \-\- .ft 1 .in 0 .fi .sp The subject of the actual message is the same as the subject of the message being forwarded, but in quotes. The \f3From:\f1 header indicates how the message was sent, and the \f3X-Filtered-By:\f1 header identifies what version of \f2filter\f1 was used. .ne 5 .hu Areas to Improve .sp While the \f2filter\f1 program as presented herein is obviously a nice addition to the set of tools available for dealing with electronic mail, there are some key features that are missing and will be added in the future based on demand. .sp As I see it, the main things missing are: .in .5i .ti -\n(TWu 1. Perhaps more \f2actions\f1 available (but what?) .ti -\n(TWu 2. Certainly the ability to filter based on any field or combination of fields. .in 0 .ne 5 .hu Warnings and Things to Look Out For .sp Since this is a pretty simple program, there are a few pitfalls, some of which have already been mentioned: .sp .in .5i \f3Order\f1 counts in the rules. Beware! .sp \f3Matching\f1 is pretty simple \(em make sure your patterns are sufficiently exclusive before having any destructive rules. .sp .in 0 The log files can grow indefinitely unless you use the \f3\-c\f1 or \f3\-q\f1 options or you trim the files by other means. .sp Finally, I welcome feedback and suggestion on how to improve this program!! filter2.6.3/doc/Filter.ps0000644000127400000010000010244107744700247015371 0ustar philother00000000000000%!PS-Adobe-3.0 %%Creator: groff version 1.18.1 %%CreationDate: Sun Oct 19 23:28:55 2003 %%DocumentNeededResources: font Times-Bold %%+ font Times-Italic %%+ font Times-Roman %%+ font Courier %%DocumentSuppliedResources: procset grops 1.18 1 %%Pages: 7 %%PageOrder: Ascend %%Orientation: Portrait %%EndComments %%BeginProlog %%BeginResource: procset grops 1.18 1 /setpacking where{ pop currentpacking true setpacking }if /grops 120 dict dup begin /SC 32 def /A/show load def /B{0 SC 3 -1 roll widthshow}bind def /C{0 exch ashow}bind def /D{0 exch 0 SC 5 2 roll awidthshow}bind def /E{0 rmoveto show}bind def /F{0 rmoveto 0 SC 3 -1 roll widthshow}bind def /G{0 rmoveto 0 exch ashow}bind def /H{0 rmoveto 0 exch 0 SC 5 2 roll awidthshow}bind def /I{0 exch rmoveto show}bind def /J{0 exch rmoveto 0 SC 3 -1 roll widthshow}bind def /K{0 exch rmoveto 0 exch ashow}bind def /L{0 exch rmoveto 0 exch 0 SC 5 2 roll awidthshow}bind def /M{rmoveto show}bind def /N{rmoveto 0 SC 3 -1 roll widthshow}bind def /O{rmoveto 0 exch ashow}bind def /P{rmoveto 0 exch 0 SC 5 2 roll awidthshow}bind def /Q{moveto show}bind def /R{moveto 0 SC 3 -1 roll widthshow}bind def /S{moveto 0 exch ashow}bind def /T{moveto 0 exch 0 SC 5 2 roll awidthshow}bind def /SF{ findfont exch [exch dup 0 exch 0 exch neg 0 0]makefont dup setfont [exch/setfont cvx]cvx bind def }bind def /MF{ findfont [5 2 roll 0 3 1 roll neg 0 0]makefont dup setfont [exch/setfont cvx]cvx bind def }bind def /level0 0 def /RES 0 def /PL 0 def /LS 0 def /MANUAL{ statusdict begin/manualfeed true store end }bind def /PLG{ gsave newpath clippath pathbbox grestore exch pop add exch pop }bind def /BP{ /level0 save def 1 setlinecap 1 setlinejoin 72 RES div dup scale LS{ 90 rotate }{ 0 PL translate }ifelse 1 -1 scale }bind def /EP{ level0 restore showpage }bind def /DA{ newpath arcn stroke }bind def /SN{ transform .25 sub exch .25 sub exch round .25 add exch round .25 add exch itransform }bind def /DL{ SN moveto SN lineto stroke }bind def /DC{ newpath 0 360 arc closepath }bind def /TM matrix def /DE{ TM currentmatrix pop translate scale newpath 0 0 .5 0 360 arc closepath TM setmatrix }bind def /RC/rcurveto load def /RL/rlineto load def /ST/stroke load def /MT/moveto load def /CL/closepath load def /Fr{ setrgbcolor fill }bind def /Fk{ setcmykcolor fill }bind def /Fg{ setgray fill }bind def /FL/fill load def /LW/setlinewidth load def /Cr/setrgbcolor load def /Ck/setcmykcolor load def /Cg/setgray load def /RE{ findfont dup maxlength 1 index/FontName known not{1 add}if dict begin { 1 index/FID ne{def}{pop pop}ifelse }forall /Encoding exch def dup/FontName exch def currentdict end definefont pop }bind def /DEFS 0 def /EBEGIN{ moveto DEFS begin }bind def /EEND/end load def /CNT 0 def /level1 0 def /PBEGIN{ /level1 save def translate div 3 1 roll div exch scale neg exch neg exch translate 0 setgray 0 setlinecap 1 setlinewidth 0 setlinejoin 10 setmiterlimit []0 setdash /setstrokeadjust where{ pop false setstrokeadjust }if /setoverprint where{ pop false setoverprint }if newpath /CNT countdictstack def userdict begin /showpage{}def }bind def /PEND{ clear countdictstack CNT sub{end}repeat level1 restore }bind def end def /setpacking where{ pop setpacking }if %%EndResource %%IncludeResource: font Times-Bold %%IncludeResource: font Times-Italic %%IncludeResource: font Times-Roman %%IncludeResource: font Courier grops begin/DEFS 1 dict def DEFS begin/u{.001 mul}bind def end/RES 72 def/PL 792 def/LS false def/ENC0[/asciicircum/asciitilde/Scaron/Zcaron /scaron/zcaron/Ydieresis/trademark/quotesingle/Euro/.notdef/.notdef /.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef /.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef /.notdef/.notdef/space/exclam/quotedbl/numbersign/dollar/percent /ampersand/quoteright/parenleft/parenright/asterisk/plus/comma/hyphen /period/slash/zero/one/two/three/four/five/six/seven/eight/nine/colon /semicolon/less/equal/greater/question/at/A/B/C/D/E/F/G/H/I/J/K/L/M/N/O /P/Q/R/S/T/U/V/W/X/Y/Z/bracketleft/backslash/bracketright/circumflex /underscore/quoteleft/a/b/c/d/e/f/g/h/i/j/k/l/m/n/o/p/q/r/s/t/u/v/w/x/y /z/braceleft/bar/braceright/tilde/.notdef/quotesinglbase/guillemotleft /guillemotright/bullet/florin/fraction/perthousand/dagger/daggerdbl /endash/emdash/ff/fi/fl/ffi/ffl/dotlessi/dotlessj/grave/hungarumlaut /dotaccent/breve/caron/ring/ogonek/quotedblleft/quotedblright/oe/lslash /quotedblbase/OE/Lslash/.notdef/exclamdown/cent/sterling/currency/yen /brokenbar/section/dieresis/copyright/ordfeminine/guilsinglleft /logicalnot/minus/registered/macron/degree/plusminus/twosuperior /threesuperior/acute/mu/paragraph/periodcentered/cedilla/onesuperior /ordmasculine/guilsinglright/onequarter/onehalf/threequarters /questiondown/Agrave/Aacute/Acircumflex/Atilde/Adieresis/Aring/AE /Ccedilla/Egrave/Eacute/Ecircumflex/Edieresis/Igrave/Iacute/Icircumflex /Idieresis/Eth/Ntilde/Ograve/Oacute/Ocircumflex/Otilde/Odieresis /multiply/Oslash/Ugrave/Uacute/Ucircumflex/Udieresis/Yacute/Thorn /germandbls/agrave/aacute/acircumflex/atilde/adieresis/aring/ae/ccedilla /egrave/eacute/ecircumflex/edieresis/igrave/iacute/icircumflex/idieresis /eth/ntilde/ograve/oacute/ocircumflex/otilde/odieresis/divide/oslash /ugrave/uacute/ucircumflex/udieresis/yacute/thorn/ydieresis]def /Courier@0 ENC0/Courier RE/Times-Roman@0 ENC0/Times-Roman RE /Times-Italic@0 ENC0/Times-Italic RE/Times-Bold@0 ENC0/Times-Bold RE %%EndProlog %%Page: 1 1 %%BeginPageSetup BP %%EndPageSetup /F0 20/Times-Bold@0 SF 2.5(The Elm Filter System Guide)176 228 R/F1 12 /Times-Italic@0 SF .5(What the f)208.616 290 R .5(ilter pr)-.24 F -.12 (og)-.54 G -.18(ra).12 G 3.5(mi).18 G .5(s, what it does,)-3.5 F .5 (and how to use it)263.996 304 R/F2 12/Times-Roman@0 SF(Filter)263.164 360 Q 3.5(,v)-.48 G .5(ersion 2.0)-3.68 F(No)259.654 402 Q 3.5(wm)-.3 G .5(aintailed by)-3.5 F .5(Philip Bro)273.728 416 R(wn)-.3 E(http://www) 231.174 430 Q(.bolthole.com/f)-.78 E(ilter/)-.24 E .5(email: f)241.14 458 R(ilter)-.24 E/F3 11/Times-Roman@0 SF(@)A F2(bolthole.com)A(Cop) 217.008 662 Q .5(yright 1986,1987 by Da)-.12 F .86 -.18(ve T)-.24 H (aylor)-.78 E(Cop)167.518 676 Q .5 (yright 1988-1992 by The USENET Community T)-.12 F(rust)-.42 E 0 Cg EP %%Page: 1 2 %%BeginPageSetup BP %%EndPageSetup /F0 14/Times-Bold@0 SF(The Elm Filter System Guide)218.5 86 Q/F1 10 /Times-Roman@0 SF(\(originally in The Elm Mail System, V)207.53 114 Q (ersion 2.4\))-1.11 E(October 1, 1992)273.645 138 Q(Syd W)277.095 174 Q (einstein)-.8 E(Datacomp Systems, Inc.)257.395 186 Q(3837 Byron Road) 270.445 198 Q(Huntingdon V)234.64 210 Q(alle)-1.11 E 1.3 -.65(y, P)-.15 H 2.5(A1)-.27 G(9006-2320)-2.5 E(email: elm)231.192 234 Q/F2 9 /Times-Roman@0 SF(@)A F1 2.5(DSI.COM or dsinc)B F2(!)A F1(elm)A(Deri) 279.125 270 Q -.15(ve)-.25 G 2.5(df).15 G(rom)-2.5 E (The Elm Mail System, V)236.695 282 Q(ersion 2.0)-1.11 E(by)301 294 Q (Da)281.445 306 Q .3 -.15(ve T)-.2 H(aylor)-.65 E(Intuiti)271.335 318 Q .3 -.15(ve S)-.25 H(ystems).15 E(Mountain V)252.45 330 Q(ie)-.6 E 1.3 -.65(w, C)-.25 H(alifornia).65 E .845 (One of the greatest problems with the b)72 390 R(ur)-.2 E .845 (geoning electronic mail e)-.18 F .845 (xplosion is that I tend to get lots of mail that I)-.15 F(don')72 402 Q 3.151(tc)-.18 G .651(are about.)-3.151 F(Amusingly)5.651 E 3.151(,p)-.65 G .652(erhaps, I ha)-3.151 F .952 -.15(ve t)-.2 H .652(he equi).15 F -.25(va)-.25 G .652(lent of electronic junk mail.).25 F .652 (Not amusing, ho)5.652 F(we)-.25 E -.15(ve)-.25 G 1.452 -.4(r, i).15 H 3.152(st).4 G(he)-3.152 E -.1(fa)72 414 S (ct that this can rapidly accumulate and end up taking o).1 E -.15(ve) -.15 G 2.5(rm).15 G 2.5(ym)-2.5 G(ailbox.)-2.5 E .256(At the same time \ I often get mail that, while it is interesting and important, can easil\ y be f)72 438 R .255(iled to be read later)-.2 F 2.755(,w)-.4 G(ith-) -2.755 E(out e)72 450 Q -.15(ve)-.25 G 2.5(ra).15 G(ctually ha)-2.5 E (ving to clutter up my incoming mailbox.)-.2 E .517(This, then, is what) 72 474 R/F3 10/Times-Italic@0 SF -.2(fi)3.017 G(lter).2 E F1 3.017 (does! The)3.017 F F3 -.2(fi)3.017 G(lter).2 E F1 .517(program allo) 3.017 F .517(ws you to def)-.25 F .518 (ine a set of rules by which all incoming mail is)-.2 F .274(screened, \ and a subsequent set of actions to perform based on whether the conditi\ ons are met or not.)72 486 R F3 -.45(Fi)5.274 G(lter).45 E F1 .274 (also has)2.774 F(the ability to mail a summary of what actions it perf\ ormed on the incoming mail as often as you')72 498 Q 2.5(dl)-.5 G(ik) -2.5 E(e.)-.1 E(The language for writing)72 522 Q F3 -.2(fi)2.5 G(lter) .2 E F1(rules is pretty simple, actually)2.5 E 5(.T)-.65 G (he fundamental structure is:)-5 E 2.5(if \()108 546 R F3(condition)A F1 5(\)t)C(hen)-5 E F3(action)5 E F1(Where)72 570 Q F3(condition)2.81 E F1 .31(is constructed by an arbitrary number of indi)2.81 F .31 (vidual conditions of the form)-.25 F F3 -.2(fi)2.81 G 2.81(eld r).2 F 2.81(elation value)-.37 F F1(\(an)2.81 E .634 (optional further type of rule is of the form al)72 582 R -.1(wa)-.1 G (ys).1 E F3(action)3.134 E F1 -.2(bu)3.134 G 3.133(ts).2 G .633 (hould only be used as the last rule in the ruleset, for)-3.133 F(ob)72 594 Q(vious reasons\).)-.15 E(The)5 E F3 -.2(fi)2.5 G(eld).2 E F1 -.25 (va)2.5 G(lue can be:).25 E(subject \(or alphasubject\))108 618 Q (sender)108 630 Q(from)108 642 Q(to)108 654 Q(lines)108 666 Q -.15(Fo)72 690 S 2.873(rt).15 G .373(he f)-2.873 F(ield)-.2 E/F4 10/Times-Bold@0 SF (lines)2.873 E F1 2.873(,t)C(he)-2.873 E F3 -.37(re)2.873 G(lation).37 E F1 .373(can be an)2.873 F 2.873(yo)-.15 G 2.873(ft)-2.873 G .373 (he standard relationships \(>, <, >=, <=, != and =\).)-2.873 F F4 (contains)5.374 E F1 .374(is equi)2.874 F(v-)-.25 E .384(alent to the r\ elation = or you can skip the relationship entirely \(e.g. subject = "j\ oe", subject contains "joe", and sub-)72 702 R .303 (ject "joe" are all equi)72 714 R -.25(va)-.25 G 2.804(lent\). The).25 F F3(value)2.804 E F1 .304(is an)2.804 F 2.804(yq)-.15 G .304 (uoted string that is to be matched ag)-2.804 F .304 (ainst or a number if)-.05 F F4(lines)2.804 E F1 .304(is the)2.804 F F3 -.2(fi)72 726 S(eld).2 E F1(being considered.)2.5 E .569(The relation)72 750 R F4(matches)3.069 E F1 .569(\(or ~\) tak)3.069 F .569(es an)-.1 F F3 -.4(eg)3.069 G -.37(re).4 G(p).37 E F1(lik)3.069 E 3.068(er)-.1 G -.15(eg)-3.068 G .568(ular e).15 F .568(xpression as the)-.15 F F3 (value)3.068 E F1 3.068(.T)C .568(he re)-3.068 F .568(gular e)-.15 F .568(xpression must be en-)-.15 F(closed in pairs of /.)72 762 Q (If you need a / in your e)5 E(xpression write it as \\ /.)-.15 E(Indi) 72 786 Q .1(vidual conditions are joined together by using the w)-.25 F (ord)-.1 E F4(and)2.6 E F1 2.6(,a)C .1 (nd the logic of a condition can be flipped by using)-2.6 F F4(not)72 798 Q F1(as the f)2.5 E(irst w)-.2 E (ord \(e.g. subject "fun" and not subject "g)-.1 E 2.5(ames"\). W)-.05 F (e')-.8 E(ll see more e)-.1 E(xamples of this later)-.15 E(.)-.55 E 0 Cg EP %%Page: 2 3 %%BeginPageSetup BP %%EndPageSetup /F0 10/Times-Roman@0 SF(Note that the or logical conjunction isn')72 24 Q 2.5(tav)-.18 G(alid part of the)-2.75 E/F1 10/Times-Italic@0 SF -.2 (fi)2.5 G(lter).2 E F0(conditional statement.)2.5 E(Finally)72 48 Q(,) -.65 E F1(action)2.5 E F0(can be an)2.5 E 2.5(yo)-.15 G(f:)-2.5 E (Description Deletes the message Sa)72 72 Q -.15(ve)-.2 G 2.5(sac).15 G (op)-2.5 E 2.5(yo)-.1 G 2.5(ft)-2.5 G(he message in the specif)-2.5 E (ied foldername.)-.2 E(Does the same as sa)5 E -.15(ve)-.2 G(,).15 E -.2 (bu)72 84 S 2.5(ta).2 G(lso puts a cop)-2.5 E 2.5(yi)-.1 G 2.5(ny)-2.5 G (our mailbox.)-2.5 E(Sends the message to the specif)5 E(ied address.) -.2 E(Sends the message to the speci-)5 E -.2(fi)72 96 S (ed address and lea).2 E -.15(ve)-.2 G 2.5(sac).15 G(op)-2.5 E 2.5(yi) -.1 G 2.5(ny)-2.5 G(our mailbox.)-2.5 E (Resends the message to the specif)5 E(ied address. NO)-.2 E (TE: sendmail and)-.4 E (other mailers will tend to set your "real" address in the "en)72 108 Q -.15(ve)-.4 G(lope". So a careful e).15 E(xamination of the ne)-.15 E 2.5(we)-.25 G(mail head-)-2.5 E(ers will sho)72 120 Q 2.5(wy)-.25 G (our address, b)-2.5 E (ut a normal glance at the presentation by most mailers will not.)-.2 E (Feeds the message to)5 E(the specif)72 132 Q(ied command \(or comple) -.2 E 2.5(xs)-.15 G(equence of commands\) as standard input.)-2.5 E(Lik) 5 E(e)-.1 E/F2 10/Times-Bold@0 SF(execute)2.5 E F0 -.2(bu)2.5 G 2.5(ta) .2 G(lso lea)-2.5 E -.15(ve)-.2 G 2.5(sac).15 G(op)-2.5 E(y)-.1 E (in your mailbox.)72 144 Q(Lea)5 E -.15(ve)-.2 G 2.5(st).15 G (he message in your mailbox.)-2.5 E .781(Note that the)72 168 R F2 (execute)3.281 E F0 .781(command assumes that you are doing something u\ seful with incoming mail.)3.281 F .78(The command)5.78 F(does)72 180 Q F1(not)2.5 E F0(automatically append the message to your mail spool.)2.5 E(Use)5 E F2(executec)2.5 E F0(for that.)2.5 E 2.5(Ac)5 G (ommand such as:)-2.5 E/F3 10/Courier@0 SF (if \(from = "dave"\) then execute "echo mail from dave > /dev/tty")108 204 Q F0(will result in)72 228 Q F1(losing)2.5 E F0(your mail.)2.5 E 2.5 (Am)5 G(ore suitable use for e)-2.5 E -.15(xe)-.15 G(cute w).15 E (ould be:)-.1 E F3(if \(from = "boss"\) then execute "vacation pat")108 252 Q F0 -.15(Fo)72 276 S .955(ldernames can contain an).15 F 3.455(yo) -.15 G 3.456(fan)-3.455 G .956(umber of macros, too, as we')-3.456 F .956(ll see in the e)-.1 F .956(xample ruleset belo)-.15 F 4.756 -.65 (w. T)-.25 H .956(he macros).65 F -.2(av)72 288 S (ailable for the string f)-.05 E(ields are:)-.2 E(Meaning day of the mo\ nth day of the week \(0-6\) hour of the day \(0-23\) month of the year \ \(1-12\) return address of)72 312 Q (message subject of original message Re:)72 324 Q F1 (subject of original messa)2.5 E -.1(ge)-.1 G F0 (current hour and minute in HH:MM format)2.6 E(year \(last tw)72 336 Q 2.5(od)-.1 G (igits\) year \(4-digit\) the string that matched the last re)-2.5 E (gular e)-.15 E(xpression the corresponding sube)-.15 E(xpres-)-.15 E (sion in the last re)72 348 Q(gular e)-.15 E(xpression that matched)-.15 E(If a message has a subject of This is a test, and the rule is)72 372 Q F3(if \(subject matches /\([a\255z]+\) a \([a\255z]+\)/\) then "echo %&\ %1 %2")108 396 Q F0(then)72 420 Q F2(%&)2.5 E F0 -.15(ex)2.5 G (pands to is a test,).15 E F2(%1)2.5 E F0 -.15(ex)2.5 G(pands to is and) .15 E F2(%2)2.5 E F0 -.15(ex)2.5 G(pands to test.).15 E -.15(Fo)72 444 S (ldernames may contain a leading ~/ which e).15 E (xpands to your home directory)-.15 E(.)-.65 E .985(The rules f)72 468 R .985(ile can also contain comments \(an)-.2 F 3.485(yl)-.15 G .985 (ine starting with a #\) and blank lines.)-3.485 F .986 (Metacharacters may be es-)5.986 F .128(caped by a preceding \\ to remo) 72 480 R .428 -.15(ve a)-.15 H .428 -.15(ny s).15 H .128 (pecial meaning.).15 F .128(If you need a % character as part of an ar) 5.128 F .127(gument \(such as an)-.18 F .166(address\), use \\%.)72 492 R .166(If you need a double quote in a double quoted string, use \\".) 5.166 F .167(If you need a single quote in a single)5.166 F (quoted string, use \\\264.)72 504 Q(If you need a backslash in an)5 E 2.5(yk)-.15 G(ind of string, use \\\\.)-2.5 E .617 (Unless you specify an alternate f)72 528 R .617(ile via the)-.2 F F2 3.117 E F0 .617(option, the rules f)3.117 F .616 (ile needs to reside in your)-.2 F F1(.f)3.116 E(ilter)-.2 E F0 .616 (directory of)3.116 F 3.116(fy)-.25 G(our)-3.116 E (home directory and be called)72 540 Q F1(.f)2.5 E(ilter/f)-.2 E (ilter\255rules)-.2 E F0 5(.H)C(ere')-5 E 2.5(sa)-.55 G 2.5(ne)-2.5 G (xample:)-2.65 E F3 6(#$)84 564 S(HOME/.filter/filter\255rules)-6 E(#)84 576 Q 6(#F)84 588 S (ilter rules for the Elm Filter program. Don\264t change without some)-6 E 6(#s)84 600 S(erious thought. \(remember \255 order counts\))-6 E(#)84 612 Q 6(#\()84 624 S(for Dave Taylor\))-6 E 6(#r)84 636 S(ule 1)-6 E (if \(from contains "!uucp"\) then delete)84 648 Q 6(#r)84 660 S(ule 2) -6 E(to "postmaster" ? save "/tmp/postmaster\255mail.%d")84 672 Q 6(#r) 84 684 S(ule 3)-6 E (if \(to "culture" and lines > 20\) ? save "~/Mail/culture")84 696 Q 6 (#r)84 708 S(ule 4)-6 E(subject = "filter test" ? forward "hpldat!test") 84 720 Q 6(#r)84 732 S(ule 5)-6 E (if [ subject = "elm" ] savecopy "~/Mail/elm\255incoming")84 744 Q 6(#r) 84 756 S(ule 6)-6 E(subject = "display\255to\255console" ? execute "cat\ \255 > /dev/console")84 768 Q F0 (\(Notice the loose syntax \212 there are lots of v)72 792 Q(alid w)-.25 E(ays to specify a rule in the)-.1 E F1 -.2(fi)2.5 G(lter).2 E F0 (program!!\))2.5 E 0 Cg EP %%Page: 3 4 %%BeginPageSetup BP %%EndPageSetup /F0 10/Times-Roman@0 SF 1.6 -.8(To t)72 24 T (ranslate these into English:).8 E (1. All messages from uucp should be summarily deleted.)98 48 Q .494 (2. All mail to postmaster should be sa)98 72 R -.15(ve)-.2 G 2.994(di) .15 G 2.994(naf)-2.994 G .495(older \(f)-2.994 F .495(ile\) called)-.2 F /F1 10/Times-Italic@0 SF(/tmp/postmaster\255mail.n)2.995 E F0 2.995(,w)C (here)-2.995 E F1(n)2.995 E F0 .495(is the nu-)2.995 F (meric-day-of-the-week.)108 84 Q 2.441(3. All mail addressed to culture\ with at least 20 lines should be automatically appended to the folder) 98 108 R F1($HOME/Mail/cultur)108 120 Q(e)-.37 E F0(.)A .666 (4. All messages that contain the subject f)98 144 R .667 (ilter test should be forw)-.2 F .667(arded to me, b)-.1 F .667 (ut via the address hpldat!test)-.2 F(\(to force a non-user forw)108 156 Q(ard\).)-.1 E .11(5. All messages with a subject that contains the w)98 180 R .109(ord elm should be sa)-.1 F -.15(ve)-.2 G 2.609(di).15 G 2.609 (nt)-2.609 G .109(he folder)-2.609 F F1($HOME/Mail/elm\255in-)2.609 E (coming)108 192 Q F0(and also dropped into my mailbox.)2.5 E(6. An)98 216 Q 2.5(ym)-.15 G(essage with the subject display-to-console will be \ immediately written to the console.)-2.5 E .65(Notice that the)72 240 R F1(or)3.151 E(der)-.37 E F0 .651(of the rules is v)3.151 F .651 (ery important.)-.15 F .651(If we, for e)5.651 F .651 (xample, were to get a message from uucp that had)-.15 F .307 (the subject f)72 252 R .307(ilter test, the)-.2 F F1 -.2(fi)2.807 G (lter).2 E F0 .307(program w)2.807 F .306 (ould match rule 1 and delete the message.)-.1 F .306(It w)5.306 F .306 (ould ne)-.1 F -.15(ve)-.25 G 2.806(rb).15 G 2.806(ef)-2.806 G(orw) -2.806 E .306(arded to)-.1 F 2.5(hpldat!test. It)72 264 R (is for this reason that great care should be tak)2.5 E (en with the ordering of the rules.)-.1 E(The)72 288 Q F1 -.2(fi)3.24 G (lter).2 E F0 .74(program has a con)3.24 F -.15(ve)-.4 G .74(nient w).15 F .74(ay of checking out the rules you ha)-.1 F 1.041 -.15(ve w)-.2 H 3.241(ritten. Simply).15 F(in)3.241 E -.2(vo)-.4 G .941 -.1(ke i).2 H 3.241(tw).1 G .741(ith the)-3.241 F/F2 10/Times-Bold@0 SF3.241 E F0(\()72 300 Q F2(rules)A F0 2.5(\)o)C(ption:)-2.5 E(%)108 324 Q F2 -.25 (fi)2.5 G(lter \255r).25 E/F3 10/Courier@0 SF (Rule 1: if \(from = "!uucp"\) then)108 336 Q(Delete)156 348 Q (Rule 2: if \(to = "postmaster"\) then)108 360 Q 6 (Save /tmp/postmaster\255mail.3)156 372 R (Rule 3: if \(to = "culture" and lines > 20\) then)108 384 Q 6 (Save ~/Mail/culture)156 396 R (Rule 4: if \(subject = "filter test"\) then)108 408 Q 6 (Forward hpldat!test)156 420 R(Rule 5: if \(subject="elm"\) then)108 432 Q 6(Copy and Save ~/Mail/elm\255incoming)156 444 R (Rule 6: if \(subject="display\255to\255console"\) then)108 456 Q (Execute "cat \255 > /dev/console")156 468 Q F0 .329(There are a fe)72 492 R 2.829(wt)-.25 G .329(hings to notice \212 f)-2.829 F .329(irst of) -.2 F .329(f, these are the parsed and reb)-.25 F .328 (uilt rules, so we see them all in a consistent)-.2 F 2.854 (format. Also,)72 504 R .354(notice on the f)2.854 F .354 (ilename for rule 2 that)-.2 F F1 -.2(fi)2.854 G(lter).2 E F0 .355 (has correctly e)2.855 F .355(xpanded the)-.15 F F2(%d)2.855 E F0 .355 (macro to be the day of the)2.855 F(week \(in this case, W)72 516 Q (ednesday)-.8 E 2.5(,d)-.65 G(enoted by the digit 3\).)-2.5 E(It is)72 540 Q F2(highly)2.5 E F0(recommended that you al)2.5 E -.1(wa)-.1 G (ys check your ruleset before actually using it to f).1 E (ilter your mail!)-.2 E(No)72 564 Q 3.132(wt)-.25 G .632(he bad ne) -3.132 F 3.132(ws. If)-.25 F .632(you aren')3.132 F 3.132(tr)-.18 G (unning)-3.132 E F1(sendmail)3.132 E F0 .632(or some other Mail T)3.132 F .631(ransport Agent that supports deli)-.35 F -.15(ve)-.25 G .631 (ry to a).15 F .856 (program you cannot use this program as currently written.)72 576 R(Wh) 5.857 E 3.357(y? Because)-.05 F(the)3.357 E F1 -.2(fi)3.357 G(lter).2 E F0 .857(program e)3.357 F .857(xpects to be put in)-.15 F(your)72 588 Q F1(.forwar)2.851 E(d)-.37 E F0 -.2(fi)2.851 G .351(le \(or equi).2 F -.25(va)-.25 G .351(lent concept for MT).25 F .351(As other than)-.93 F F1(sendmail)2.851 E F0 2.85(\)t)C .35 (hat causes the messages to be deli)-2.85 F -.15(ve)-.25 G .35(red to) .15 F(the)72 600 Q F1 -.2(fi)2.5 G(lter).2 E F0 2.5(program. That)2.5 F (is something that only)2.5 E F1(sendmail)2.5 E F0(and other smart MT) 2.5 E(As look at!)-.93 E(The format for the entry in the)72 624 Q F1 (.forwar)2.5 E(d)-.37 E F0 -.2(fi)2.5 G (le \(located in your home directory\) is simply:).2 E ("|/usr/local/bin/f)108 648 Q(ilter")-.2 E .268(Alright, it isn')72 672 R 2.768(tq)-.18 G(uite)-2.768 E F1(that)2.768 E F0 2.768(simple! Since) 2.768 F F1 -.2(fi)2.768 G(lter).2 E F0 .268(is in)2.768 F -.2(vo)-.4 G -.1(ke).2 G 2.768(db).1 G 2.769(yp)-2.768 G .269(rocesses that don') -2.769 F 2.769(tk)-.18 G(no)-2.769 E 2.769(ww)-.25 G .269 (here you are logged in, you)-2.769 F .012(need to ha)72 684 R .312 -.15 (ve s)-.2 H .012(ome w).15 F .012(ay to trap the error messages.)-.1 F -.15(Fo)5.011 G 2.511(re).15 G .011(ase of use, it w)-2.511 F .011 (as decided to ha)-.1 F .311 -.15(ve a)-.2 H .011 (ll the messages written to).15 F(the f)72 696 Q(ile specif)-.2 E (ied by)-.2 E F22.5 E F0(\(or)2.5 E F1(stderr)2.5 E F0 2.5(\)w)C (hich means that you ha)-2.5 E .3 -.15(ve t)-.2 H .2 -.1(wo m).15 H (ain choices for the actual entry).1 E 5(.E)-.65 G(ither:)-5 E ("|/usr/local/bin/f)108 720 Q(ilter \255o /de)-.2 E(v/console")-.25 E (which will log all errors on the system console \(each error is pref)72 744 Q(ix)-.2 E(ed with f)-.15 E(ilter \()-.2 E F1(username)A F0 2.5(\)t) C 2.5(od)-2.5 G(istinguish it\), or:)-2.5 E("|/usr/local/bin/f)108 768 Q (ilter \255o /tmp/joe.f)-.2 E(ilter_errors")-.2 E .597(if you w)72 792 R .597(ant to ha)-.1 F .897 -.15(ve a c)-.2 H(op).15 E 3.097(ys)-.1 G -2.25 -.2(av e)-3.097 H 3.097(dt).2 G 3.097(oaf)-3.097 G 3.097 (ile. Note)-3.297 F .598 (that the quotes are a required part of the line.)3.097 F 3.098(Ap)5.598 G .598(ossible strate)-3.098 F(gy)-.15 E 0 Cg EP %%Page: 4 5 %%BeginPageSetup BP %%EndPageSetup /F0 10/Times-Roman@0 SF -.1(wo)72 12 S(uld be to ha).1 E .3 -.15(ve t) -.2 H(he errors written to a f).15 E(ile and to then ha)-.2 E .3 -.15 (ve a f)-.2 H .5 -.25(ew l).15 H(ines in your).25 E/F1 10/Times-Italic@0 SF(.lo)2.5 E(gin)-.1 E F0(\(or equi)2.5 E -.25(va)-.25 G (lent\) script lik).25 E(e:)-.1 E/F2 10/Courier@0 SF (if \( \255f /tmp/joe.filter_errors\) then)108 36 Q 6(echo ")126 48 R(") 6 E(echo "Filter program errors;")126 60 Q(cat /tmp/joe.filter_errors) 126 72 Q(echo " ")126 84 Q(endif)108 96 Q F0 -1.1(Yo)72 120 S 2.546(uc) 1.1 G .046(an also use the)-2.546 F/F3 10/Times-Bold@0 SF2.546 E F0 .045(option in combination with the abo)2.545 F .345 -.15(ve t)-.15 H 2.545(oh).15 G -2.25 -.2(av e)-2.545 H 2.545(am)2.745 G .045(ore v) -2.545 F .045(erbose log f)-.15 F .045(ile \(including action tak)-.2 F (en)-.1 E(with date/time stamp\) sa)72 132 Q -.15(ve)-.2 G 2.5(db).15 G 2.5(yh)-2.5 G -.2(av)-2.5 G(ing in your).2 E F1(.forwar)2.5 E(d)-.37 E F0 -.2(fi)2.5 G(le:).2 E F2 ("|/usr/local/bin/filter \255vo /tmp/joe.filter_errors")108 156 Q F0 (Suf)72 180 Q -.2(fi)-.25 G(ce it to say).2 E 2.5(,y)-.65 G (ou can get pretty trick)-2.5 E 2.5(yw)-.15 G(ith all this!!)-2.5 E(The) 72 204 Q F1 -.2(fi)2.639 G(lter).2 E F0 .139(program can k)2.639 F .139 (eep a log of all actions performed, including what rules it matched ag) -.1 F .139(ainst, in your)-.05 F F1(.f)2.639 E(ilter)-.2 E F0(di-)2.639 E .212(rectory in a f)72 216 R .212(ile called)-.2 F F1(.f)2.712 E (ilter/f)-.2 E(ilterlo)-.2 E(g)-.1 E F0 5.212(.Y)C .212 (ou can either directly operate on this f)-6.312 F .211(ile, or)-.2 F 2.711(,m)-.4 G .211(uch more recommended, you)-2.711 F (can use one of the tw)72 228 Q 2.5(os)-.1 G(ummarization options to) -2.5 E F1 -.2(fi)2.5 G(lter).2 E F0(and let)2.5 E F1(it)2.5 E F0 (do the w)2.5 E(ork for you!)-.1 E(The dif)72 252 Q (ference between the tw)-.25 E 2.5(oi)-.1 G 2.5(sb)-2.5 G (est demonstrated by e)-2.5 E(xample:)-.15 E(%)108 276 Q F3 -.25(fi)2.5 G(lter \255s).25 E F2(Summary of Filter Activity)204 288 Q (--------------------------)204 300 Q 6(At)108 312 S (otal of 418 messages were filtered:)-6 E (The default rule of putting mail into your mailbox)108 324 Q (applied 364 times \(87%\))162 336 Q(Rule #1: \(delete message\))108 348 Q(applied 1 time \(0%\))162 360 Q (Rule #2: \(save in "~/Filtered\255Mail/netnews.12"\))108 372 Q (applied 8 times \(2%\))162 384 Q (Rule #3: \(save in "~/Filtered\255Mail/postmaster.12"\))108 396 Q (applied 14 times \(3%\))162 408 Q (Rule #5: \(save in "~/Filtered\255Mail/risks.12"\))108 420 Q (applied 3 times \(1%\))162 432 Q (Rule #6: \(save in "~/Filtered\255Mail/rays.12"\))108 444 Q (applied 28 times \(7%\))162 456 Q F0 -.15(ve)72 480 S(rsus:).15 E(%)108 504 Q F3 -.25(fi)2.5 G(lter \255S).25 E F1([the output as listed abo)108 516 Q(ve)-.1 E 2.5(,f)-.1 G(ollowed by:])-2.5 E F2 (Explicit log of each action;)108 528 Q (Mail from taylor about Filter Summary)108 540 Q (PUT in mailbox: the default action)162 552 Q (Mail from news@hplabsz.hpl.hp.com about Newsgroup comp.editors created) 108 564 Q(PUT in mailbox: the default action)162 576 Q (Mail from root about Log file: cleanuplog)108 588 Q (PUT in mailbox: the default action)162 600 Q F1([etc.])108 612 Q F0 2.065 -.8(To a)72 636 T .465 (ctually use either of the summarizing options, there are tw).8 F 2.966 (ow)-.1 G .466(ays that are recommended.)-3.066 F .466(The preferred w) 5.466 F .466(ay is)-.1 F .25(to ha)72 648 R .549 -.15(ve a l)-.2 H .249 (ine in either your).15 F F1(cr)2.749 E(ontab)-.45 E F0 -.2(fi)2.749 G .249(le \(ask your administrator for help with this\) that in).2 F -.2 (vo)-.4 G -.1(ke).2 G 2.749(st).1 G(he)-2.749 E F1 -.2(fi)2.749 G(lter) .2 E F0 .249(program as)2.749 F(often as you desire with the)72 660 Q F3 2.5 E F0 2.5(option. F)2.5 F(or e)-.15 E(xample, I ha)-.15 E .3 -.15(ve a s)-.2 H(ummary mailed to me e).15 E -.15(ve)-.25 G (ry morning at 8 o'clock:).15 E F2 6(08***")114 684 S (/usr/local/bin/filter \255s | elm \255s \264Filter Summary\264 taylor") -6 E F0(An alternati)72 708 Q .3 -.15(ve i)-.25 H 2.5(st).15 G 2.5(oh) -2.5 G -2.25 -.2(av e)-2.5 H(your)2.7 E F1(.lo)2.5 E(gin)-.1 E F0 (\(or equi)2.5 E -.25(va)-.25 G(lent\) e).25 E -.15(xe)-.15 G (cute the command each time you log in.).15 E .1(Note that if you w)72 732 R .1(ant to ha)-.1 F .4 -.15(ve y)-.2 H .1(our log f).15 F .1 (iles cleared out each time the summary is generated you')-.2 F .1 (ll need to use the)-.1 F F32.6 E F0 .351(option too.)72 744 R .351(Also, if you w)5.351 F .351(ant to k)-.1 F .351 (eep a long list of actions performed you can do this by sa)-.1 F .35 (ving it as you display it.)-.2 F 2.5(Aw)72 756 S(ay to do this w)-2.6 E (ould be, if you were to ha)-.1 E .3 -.15(ve t)-.2 H(he in).15 E -.2(vo) -.4 G(cation in your).2 E F1(.lo)2.5 E(gin)-.1 E F0(\(or equi)2.5 E -.25 (va)-.25 G(lent\) script, to use:).25 E F2(echo "Filter Log;")108 780 Q (filter \255c \255s | tee \255a PERM.filter.log)108 792 Q 0 Cg EP %%Page: 5 6 %%BeginPageSetup BP %%EndPageSetup /F0 10/Times-Roman@0 SF .648(which w)72 24 R .648(ould append a cop)-.1 F 3.148(yo)-.1 G 3.148(fa)-3.148 G .648(ll the output to the f)-3.148 F (ile)-.2 E/F1 10/Times-Italic@0 SF(PERM.f)3.149 E(ilter)-.2 E(.lo)-1.11 E(g)-.1 E F0 .649(and w)3.149 F .649(ould a)-.1 F -.2(vo)-.2 G .649 (id you ha).2 F .649(ving to read lar)-.2 F(ger)-.18 E(and lar)72 36 Q (ger summaries of what the program had done.)-.18 E .114 (If you prefer not to ha)72 60 R -.15(ve)-.2 G F1 -.2(fi)2.764 G(lter).2 E F0 .114(generate log f)2.614 F .114(iles, use the)-.2 F/F2 10 /Times-Bold@0 SF2.614 E F0 2.614(option. Messages)2.614 F .114 (that are written to)2.614 F F1(stderr)2.614 E F0 .114(or the)2.614 F F2 2.613 E F0 -.2(fi)2.613 G(le).2 E (are still generated; only message to the log f)72 72 Q (iles are quashed.)-.2 E(Using the)72 96 Q F1 -.37(re)2.5 G(admsg).37 E F0(command, it is quite easy to test the rules you')2.5 E .3 -.15(ve w) -.5 H(ritten to see if the).15 E 2.5(yd)-.15 G 2.5(ow)-2.5 G (hat you desire.)-2.5 E -.15(Fo)72 120 S 3.886(re).15 G 1.386 (xample, we can use the)-4.036 F F23.886 E F0 1.387(option to) 3.886 F F1 -.2(fi)3.887 G(lter).2 E F0 3.887(,w)C 1.387(hich means don') -3.887 F 3.887(ta)-.18 G 1.387 (ctually do this, just tell me what rule you)-3.887 F .329 (matched, if an)72 132 R 1.628 -.65(y, a)-.15 H .328 (nd what action you w).65 F .328(ould ha)-.1 F .628 -.15(ve p)-.2 H .328 (erformed \(you can see wh).15 F 2.828(yas)-.05 G .328 (ingle letter option is easier to type)-2.828 F (in!!\), and feed it each message in our mailbox by using a command lik) 72 144 Q(e:)-.1 E(%)108 168 Q F2(set message=1)2.5 E F0(%)108 180 Q F2 (set total_messages=\222messages\222)2.5 E F0(%)108 192 Q F2 2.5 (while \(1\))2.5 F F0(>)108 204 Q F2 (if \($message > $total_messages\) exit)2.5 E F0(>)108 216 Q F2 -.18(re) 2.5 G(admsg \255h $message | f).18 E(ilter \255n)-.25 E F0(>)108 228 Q F2 2.5(@m)2.5 G(essage++)-2.5 E F0(>)108 240 Q F2(end)2.5 E F0 .102 (which will then hand each of the messages in your mailbox to the)72 264 R F1 -.2(fi)2.602 G(lter).2 E F0 .102(program and display what action w) 2.602 F .102(ould ha)-.1 F -.15(ve)-.2 G(been tak)72 276 Q (en with that message and wh)-.1 E -.65(y.)-.05 G -.15(Fo)72 300 S 2.5 (re).15 G(xample, if we do this for a fe)-2.65 E 2.5(wi)-.25 G (nteresting messages in my mailbox, we')-2.5 E 2.5(de)-.5 G (nd up with output lik)-2.5 E(e:)-.1 E/F3 10/Courier@0 SF (Mail from taylor about filter test)108 324 Q (FORWARDED to hpldat!taylor by rule;)138 336 Q(subject="filter test")150 348 Q 6(?f)12 G(orward "hpldat!test")-6 E(Mail from bradley%hplkab@hpla\ bsc about Re: AI-ED mailing address for HP)108 360 Q (PUT in mailbox: the default action)138 372 Q (Mail from taylor about display-to-console)108 384 Q (EXECUTED "cat \255 > /dev/console")138 396 Q F0 (\(Sharp users will notice that this is e)72 420 Q (xactly the same format as the longer summary listing.\))-.15 E .339 (When a message is forw)72 444 R .339(arded to another user by the)-.1 F F1(action)2.839 E F0 .339(being specif)2.839 F .339(ied as)-.2 F F2 -.25 (fo)2.839 G(rward).25 E F1(addr)2.839 E(ess)-.37 E F0 2.839(,t)C(hen) -2.839 E F1 -.2(fi)2.839 G(lter).2 E F0 .338(can gen-)2.839 F .218 (erate one of tw)72 456 R 2.718(os)-.1 G .218(tyles of message.)-2.718 F .219(If the message is to you, then it simply adds it to your mailbox i\ n such a w)5.219 F .219(ay as)-.1 F(to ensure that the return address i\ s that of the person who sent the message.)72 468 Q (If not, then the message is enclosed in a message of the form:)72 492 Q F3(From taylor Thu Oct)108 516 Q 6(21)12 G(5:07:04 1986)-6 E (Date: Thu, 2 Oct 86 15:06:58 pdt)108 528 Q(Subject: "filter test")108 540 Q(From: The filter of taylor@hpldat )108 552 Q (To: hpldat!taylor)108 564 Q(X-Filtered-By: filter, version 1.4)108 576 Q(\255\255 Begin filtered message \255\255)108 588 Q (From taylor Thu Oct)126 612 Q 6(21)12 G(5:06:41 1986)-6 E (Date: Thu, 2 Oct 86 15:06:33 pdt)126 624 Q(From: Dave Taylor ) 126 636 Q(Subject: filter test)126 648 Q(Just a simple test.)126 660 Q (\255\255 End of filtered message \255\255)108 672 Q F0 1.017(The subje\ ct of the actual message is the same as the subject of the message bein\ g forw)72 696 R 1.016(arded, b)-.1 F 1.016(ut in quotes.)-.2 F(The)6.016 E F2(Fr)72 708 Q(om:)-.18 E F0 .776(header indicates ho)3.276 F 3.276 (wt)-.25 G .776(he message w)-3.276 F .776(as sent, and the)-.1 F F2 (X-Filter)3.276 E(ed-By:)-.18 E F0 .776(header identif)3.276 F .777 (ies what v)-.2 F .777(ersion of)-.15 F F1 -.2(fi)3.277 G(lter).2 E F0 -.1(wa)72 720 S 2.5(su).1 G(sed.)-2.5 E .165(While the)72 744 R F1 -.2 (fi)2.665 G(lter).2 E F0 .165(program as presented herein is ob)2.665 F .165(viously a nice addition to the set of tools a)-.15 F -.25(va)-.2 G .165(ilable for dealing with).25 F(electronic mail, there are some k)72 756 Q .3 -.15(ey f)-.1 H(eatures that are missing and will be added in \ the future based on demand.).15 E (As I see it, the main things missing are:)72 780 Q 0 Cg EP %%Page: 6 7 %%BeginPageSetup BP %%EndPageSetup /F0 10/Times-Roman@0 SF(1. Perhaps more)98 12 Q/F1 10/Times-Italic@0 SF (actions)2.5 E F0 -.2(av)2.5 G(ailable \(b)-.05 E(ut what?\))-.2 E (2. Certainly the ability to f)98 36 Q(ilter based on an)-.2 E 2.5(yf) -.15 G(ield or combination of f)-2.7 E(ields.)-.2 E (Since this is a pretty simple program, there are a fe)72 60 Q 2.5(wp) -.25 G(itf)-2.5 E(alls, some of which ha)-.1 E .3 -.15(ve a)-.2 H (lready been mentioned:).15 E/F2 10/Times-Bold@0 SF(Order)108 84 Q F0 (counts in the rules.)2.5 E(Be)5 E -.1(wa)-.25 G(re!).1 E F2(Matching) 108 108 Q F0 .328(is pretty simple \212 mak)2.828 F 2.828(es)-.1 G .328 (ure your patterns are suf)-2.828 F -.2(fi)-.25 G .328(ciently e).2 F (xclusi)-.15 E .628 -.15(ve b)-.25 H .328(efore ha).15 F .328(ving an) -.2 F 2.828(yd)-.15 G(estruc-)-2.828 E(ti)108 120 Q .3 -.15(ve r)-.25 H (ules.).15 E(The log f)72 144 Q(iles can gro)-.2 E 2.5(wi)-.25 G(ndef) -2.5 E(initely unless you use the)-.2 E F22.5 E F0(or)2.5 E F2 2.5 E F0(options or you trim the f)2.5 E(iles by other means.)-.2 E(Finally)72 168 Q 2.5(,Iw)-.65 G(elcome feedback and suggestion on ho) -2.5 E 2.5(wt)-.25 G 2.5(oi)-2.5 G(mpro)-2.5 E .3 -.15(ve t)-.15 H (his program!!).15 E 0 Cg EP %%Trailer end %%EOF filter2.6.3/doc/Makefile0000644000127400000010000000537507700222275015240 0ustar philother00000000000000# # Variables # Variables established by Configure CHMOD = /bin/chmod CP = /bin/cp DEST = $(DESTDIR)/usr/local/bin ECHO = /bin/echo FORMATTER = /bin/troff FORMATTER_OPTS = LN = /bin/ln MAKE = /usr/ccs/bin/make MAN = $(DESTDIR)/usr/man/mann MANEXT = .n CATMAN = none CATMANEXT = RM = /bin/rm -f TBL = /bin/tbl MANROFF = MANROFF_OPTS = MV = /bin/mv TEST = test SUFFIX = PACKED = PACKER = # Other variables SHELL = /bin/sh # List of installed man pages MAN_LIST = $(MAN)/filter$(MANEXT) CATMAN_LIST = $(CATMAN)/filter$(CATMANEXT)$(SUFFIX) # List of formatted pages for catman FORMATTED_PAGES_LIST = catman/filter$(CATMANEXT)$(SUFFIX) REMOTE_MAN_LIST = $(REMOTE)$(MAN)/filter$(MANEXT) # List of formatted guides FORMATTED_LIST = Filter.fmtd # Targets all: @if $(TEST) '$(CATMAN)' != none; then $(MAKE) $(MFLAGS) formatted_pages ; else true ; fi # The following are no-ops lint: clean: formatted_pages: catman $(FORMATTED_PAGES_LIST) catman: mkdir catman install: @if $(TEST) '$(MAN)' != none; then $(MAKE) $(MFLAGS) install_man ; else true ; fi @if $(TEST) '$(CATMAN)' != none; then $(MAKE) $(MFLAGS) install_catman ; else true ; fi install_man: $(MAN_LIST) install_catman: $(CATMAN_LIST) uninstall: @if $(TEST) '$(MAN)' != none; then \ $(RM) $(MAN_LIST) ; \ else \ true ; \ fi @if $(TEST) '$(CATMAN)' != none; then \ $(RM) $(CATMAN_LIST) ; \ else \ true ; \ fi # Dependencies and rules for installing man pages and lib files # taken from a remote system # This is the only target that gets installed even if not out-of-date # with respect the files from which it is installed. rmt-install: rmt-defined $(CP) $(REMOTE_MAN_LIST) $(MAN) $(CHMOD) u=rw,go=r $(MAN_LIST) rmt-defined: @(if [ "$(REMOTE)" = "" ];\ then\ $(ECHO) "You need to define 'REMOTE' as the remote file system";\ $(ECHO) "for this particular command. The easiest way to do this";\ $(ECHO) "to type:";\ $(ECHO) " make REMOTE= rmt-install";\ exit 1;\ fi); # Dependencies and rules for installing man pages and lib files $(MAN)/filter$(MANEXT): filter.1 $(CP) $? $@ $(CHMOD) u=rw,go=r $@ # Dependencies and rules for installing catman $(CATMAN)/filter$(CATMANEXT)$(SUFFIX): catman/filter$(CATMANEXT)$(SUFFIX) $(CP) $? $@ $(CHMOD) u=rw,go=r $@ # Dependencies and rules for making catman pages catman/filter$(CATMANEXT)$(SUFFIX): filter.1 $(MANROFF) $(MANROFF_OPTS) -man $? > catman/filter$(CATMANEXT) @if $(TEST) "$(PACKED)" = y ; then \ $(RM) $@ ; \ $(PACKER) catman/filter$(CATMANEXT) ; \ else \ true ; \ fi # Dependencies and rules for formatting guides documentation: $(FORMATTED_LIST) Filter.fmtd: Filter.guid $(TBL) $? | $(FORMATTER) $(FORMATTER_OPTS) tmac.n - > $@ filter2.6.3/doc/Makefile.SH0000644000127400000010000000624007204566204015543 0ustar philother00000000000000case $CONFIG in '') if test ! -f config.sh; then ln ../config.sh . || \ ln ../../config.sh . || \ ln ../../../config.sh . || \ (echo "Can't find config.sh."; exit 1) fi . ./config.sh ;; esac case "$0" in */*) cd `expr X$0 : 'X\(.*\)/'` ;; esac echo "Extracting doc/Makefile (with variable substitutions)" cat >Makefile <>Makefile <<'!NO!SUBS!' # Other variables SHELL = /bin/sh # List of installed man pages MAN_LIST = $(MAN)/filter$(MANEXT) CATMAN_LIST = $(CATMAN)/filter$(CATMANEXT)$(SUFFIX) # List of formatted pages for catman FORMATTED_PAGES_LIST = catman/filter$(CATMANEXT)$(SUFFIX) REMOTE_MAN_LIST = $(REMOTE)$(MAN)/filter$(MANEXT) # List of formatted guides FORMATTED_LIST = Filter.fmtd # Targets all: @if $(TEST) '$(CATMAN)' != none; then $(MAKE) $(MFLAGS) formatted_pages ; else true ; fi # The following are no-ops lint: clean: formatted_pages: catman $(FORMATTED_PAGES_LIST) catman: mkdir catman install: @if $(TEST) '$(MAN)' != none; then $(MAKE) $(MFLAGS) install_man ; else true ; fi @if $(TEST) '$(CATMAN)' != none; then $(MAKE) $(MFLAGS) install_catman ; else true ; fi install_man: $(MAN_LIST) install_catman: $(CATMAN_LIST) uninstall: @if $(TEST) '$(MAN)' != none; then \ $(RM) $(MAN_LIST) ; \ else \ true ; \ fi @if $(TEST) '$(CATMAN)' != none; then \ $(RM) $(CATMAN_LIST) ; \ else \ true ; \ fi # Dependencies and rules for installing man pages and lib files # taken from a remote system # This is the only target that gets installed even if not out-of-date # with respect the files from which it is installed. rmt-install: rmt-defined $(CP) $(REMOTE_MAN_LIST) $(MAN) $(CHMOD) u=rw,go=r $(MAN_LIST) rmt-defined: @(if [ "$(REMOTE)" = "" ];\ then\ $(ECHO) "You need to define 'REMOTE' as the remote file system";\ $(ECHO) "for this particular command. The easiest way to do this";\ $(ECHO) "to type:";\ $(ECHO) " make REMOTE= rmt-install";\ exit 1;\ fi); # Dependencies and rules for installing man pages and lib files $(MAN)/filter$(MANEXT): filter.1 $(CP) $? $@ $(CHMOD) u=rw,go=r $@ # Dependencies and rules for installing catman $(CATMAN)/filter$(CATMANEXT)$(SUFFIX): catman/filter$(CATMANEXT)$(SUFFIX) $(CP) $? $@ $(CHMOD) u=rw,go=r $@ # Dependencies and rules for making catman pages catman/filter$(CATMANEXT)$(SUFFIX): filter.1 $(MANROFF) $(MANROFF_OPTS) -man $? > catman/filter$(CATMANEXT) @if $(TEST) "$(PACKED)" = y ; then \ $(RM) $@ ; \ $(PACKER) catman/filter$(CATMANEXT) ; \ else \ true ; \ fi # Dependencies and rules for formatting guides documentation: $(FORMATTED_LIST) Filter.fmtd: Filter.guid $(TBL) $? | $(FORMATTER) $(FORMATTER_OPTS) tmac.n - > $@ !NO!SUBS! filter2.6.3/doc/config.sh0000644000127400000010000000570507204563710015377 0ustar philother00000000000000#!/bin/sh # config.sh # This file was produced by running the Configure script. bin='/usr/local/bin' contains='grep' cppstdin='/usr/lib/cpp' cppminus='' d_havetlib='define' termlib='-lcurses' d_memcpy='define' d_whoami='undef' n='' c='\c' package='filter' startsh='#!/bin/sh' d_eunice='undef' define='define' eunicefix=':' loclist=' cat chgrp chmod cp echo expr grep ln ls make mv rm sed touch tr ' expr='/bin/expr' sed='/bin/sed' echo='/bin/echo' cat='/bin/cat' rm='/bin/rm' mv='/bin/mv' cp='/bin/cp' tail='' tr='/bin/tr' mkdir='' sort='' uniq='' grep='/bin/grep' trylist=' Mcc compress cpp execmail line lint mips nroff pack pmake rmail sendmail smail submit tbl test troff uname uuname ' test='test' inews='' ispell='' egrep='' more='' pg='' Mcc='Mcc' vi='' mailx='' mail='' cpp='/usr/lib/cpp' perl='' emacs='' ls='/bin/ls' rmail='/bin/rmail' sendmail='/usr/lib/sendmail' shar='' smail='smail' submit='' tbl='/bin/tbl' troff='/bin/troff' nroff='/bin/nroff' uname='/bin/uname' uuname='/bin/uuname' line='/bin/line' chgrp='/bin/chgrp' chmod='/bin/chmod' lint='/usr/ucb/lint' sleep='' pr='' tar='' ln='/bin/ln' lpr='' lp='' touch='/bin/touch' make='/usr/ccs/bin/make' date='' csh='' pmake='pmake' mips='false' col='' pack='/bin/pack' compress='/bin/compress' execmail='' libswanted='intl nls' d_broke_ctype='define' d_chown_neg1='' d_cuserid='define' d_flock='undef' d_dotlock='define' d_fcntlock='define' lock_dir='/usr/spool/locks' has_flock='define' has_fcntl='define' d_gethname='define' d_douname='undef' d_host_comp='undef' ign_hname='n' d_index='define' d_internet='define' d_locale='define' d_nl_types='define' d_msgcat='define' d_usenls='undef' d_mallocvoid='undef' d_mmdf='undef' d_noxheader='undef' d_pidcheck='undef' d_setgid='undef' d_savegrpmboxid='' mailermode='755' d_sigvec='undef' d_sigvectr='undef' d_sigset='undef' d_sighold='undef' d_sigprocmask='define' d_sigblock='undef' d_sigaction='define' d_strings='undef' d_pwdinsys='undef' strings='/usr/include/string.h' includepath='' d_strstr='' d_useembed='define' d_utimbuf='undef' hostname='zaphod' phostname='hostname' mydomain='' autohostname='define' i_memory='define' i_stdarg='define' i_stdlib='define' i_time='undef' i_systime='undef' d_systimekernel='undef' i_unistd='define' i_utime='define' i_sysutime='undef' lib='' libc='/usr/lib/libc.so' maildir='/var/mail' mailhome='/var/mail/%u' mailer='/usr/lib/sendmail' mailgrp='mail' mansrc='/usr/local/man/mann' catmansrc='none' manext='.n' manext_choice='.n' catmanext='' catmanext_choice='' packed='' manroff='' manroffopts='' suffix='' packer='' models='none' split='' small='' medium='' large='' huge='' optimize='-O' ccflags='' cppflags='' ldflags='' cc='cc' libs='-lintl -lnls' nametype='' d_passnames='' d_berknames='' d_usgnames='' rcpthdr='none' passcat='cat /etc/passwd' roff='/bin/troff' roffopts='' d_rcpthdr='undef' sigtype='void' spitshell='cat' shsharp='true' sharpbang='#!' tzname_handling='UNKNOWN' use_pmake='n' xencf='' xenlf='' d_xenix='undef' d_bsd='undef' CONFIG=true filter2.6.3/doc/filter.10000644000127400000010000001471010041241002015115 0ustar philother00000000000000.if n \{\ . ds ct " .\} .if t \{\ . ds ct \\(co .\} .TH FILTER 1 "19 April 2004" "USENET Comm. Trust" .SH NAME filter - filter incoming messages before adding to mailbox .SH SYNOPSIS .B filter [-q] [-v] [-l] [-o output] [-f rules-file] [-m mailbox] .br .B filter [-n] [-f rules-file] .br .B filter [-r] [-o output] [-f rules-file] .br .B filter [-c] [-s] [-o output] [-f rules-file] .br .B filter [-c] [-S] [-o output] [-f rules-file] .SH DESCRIPTION In brief, \fIfilter\fR is designed to sort incoming mail based on user preferences for various recognized headers. It logs a summary of messages filtered to a logfile. See the USAGE section for full details. .SH OPTIONS The flags the \fIfilter\fR program understands are; .TP 1.0i .B "-c" Clear logs. If this flag is used, the log files will be removed after being summarized by either "-s" or "-S" (see below). .TP \fB-f \fIrules-file\fR Get rules from specified file instead of default $HOME/.filter/filter-rules .TP .B "-l" Log actions only. Do not log information about mailed messages. .TP .B "-n" Not really. Output what would happen if given message from standard input, but don't actually do anything with it. .TP \fB-o \fIfile\fR Redirect stdout messages to the specified file or device. Logging of filter actions is not affected. (This is added to more gracefully deal with changes in the file system (since sendmail is quite picky about modes of files being redirected into.)) .TP \fB-m \fImailbox\fR Override the compiled in definition of your primary 'mailbox'. This is disabled if filter is setgid. .TP .B "-q" Quiet. Do not log filtering actions. .TP .B "-r" Rules. List the rules currently being used. .TP .B "-s" Summarize. List a summary of the message filtering log. .TP .B "-S" This is the same as `-s' but includes message-by-message information additionally. .TP .B "-v" Verbose. Give output on standard out for each message filtered. May be useful to set output to ``/dev/console'' or other logging device. (see \fB-o\fR). .SH USAGE .I Filter uses a set of selection rules to process incoming mail messages. These rules are normally read in from $HOME/.filter/filter-rules. As soon as a rule matches something about the message, that rule is used, and no further action is taken. The general format for a rule is; .nf \fBif (\fIexpression\fP) then \fIaction\fR .fi where \fIexpression\fR is: .nf \fIexpression\fR ::= { \fBnot\fR } \fIcondition\fR { and \fIexpression\fR } \fIcondition\fR ::= \fIfield = stringvalue\fR ::= \fIfield != stringvalue\fR ::= \fBlines\fI relop numvalue\fR or ::= \fBalways\fR .fi These further break down as: .nf \fIfield\fR ::= \fBfrom\fR | \fBsubject\fR | \fBalphasubject\fR | \fBto\fR | \fBlines\fR | \fBsender\fR \fIrelop\fR ::= \fB=\fR | \fB!=\fR | \fB<\fR | \fB>\fR | \fB<=\fR | \fB>=\fR \fIstringvalue\fR ::= \fIany quoted string\fR \fInumvalue\fR ::= \fIany integer value\fR .fi Note: \fBalphasubject\fR is a transformed version of the subject line, where only alpha chars are preserved, and they are forced to lower case. It is then simpler to use a regular expression match across a wide variety of similar subjects. \fBfrom\fR matches any and all of the following headers: "From " From: Reply-To: Sender: \fIAction\fR can be any of: .nf \fBdelete\fR (ignore this message; throw it away) \fBsave \fIfoldername\fR (put in 'foldername' for later) \fBsavecopy \fIfoldername\fR (save a copy AND put in my inbox) \fBexecute \fIcommand\fR (pipe message to 'command') \fBexecutec \fIcommand\fR (copy to inbox, AND pipe to 'command') \fBforward \fIaddress\fR (forward this message) \fBforwardc \fIaddress\fR (forward this message, AND copy to inbox) \fBresend \fIaddress\fR (resend to new addr without change) \fBleave\fR (just put it in my inbox) \fBbounce\fR (say there's no such user) .fi An example of a rules file would be: .nf # I'll read this stuff later when I feel like it if (from = "list@interest.org") then save "~/Mail/mailinglist" # This mailing list actually has an x-mailing-list header if (mailinglist = "smartlist@other.com") then save "~/Mail/otherlist" # auto-archive this project's email, AND put in my current mailbox if (subject = "strange project") then savecopy "~/Mail/proj-archive" # If "make money" appears ANYWHERE in subject, upper/lowercase, # delete the lousy spam if ( subject = "make money" ) then delete # This person no longer shares this virtual mailbox with me. # Resend visibly as a "forwarded" message. if (to = "partner") then forward "partner@new.address.com" # If email for an old address comes to me, resend to new one. # Note that the "envelope" will show my address, but the # normal headers will not if ( to = "old_address" ) then resend new@address.here" # Special virtual headerline derived from normal subject line # catches "multiple!!!wor+ds**here" if ( alphasubject = "multiplewordshere" ) then delete # If email for a special address comes to me, resend through # a non-standard "special" mailer if ( to = "special_address" ) then exec "/usr/lib/mailer special@addr" # # The rules file doesnt really need parentheses. Or even the 'if'. # They are just traditional. subject = "silly" then bounce .fi Note that all filenames must be double-quoted For further information about the rules language, please see \fIThe Elm Filter Guide\fR. .sp .SH MAINTAINER Philip Brown .SH FILES $HOME/.filter/filter-rules Default rules file .br $HOME/.filter/filterlog A log of what has been done .br $HOME/.filter/filtersum A summary of what has been done .br $MAIL IF you set this var, defines your default mailbox .br /etc/passwd Used to get users home directory .SH SEE ALSO .I "The Elm Filter Guide" (distributed with the source code) .br mail(1), mailx(1), sendmail(1,8) .SH COMMENTS Could be smarter about pattern matching. Message body checks might be nice too. .br Please note that this was historically bundled with the elm mail reader, but now can be found at .br http://www.bolthole.com/filter/ .SH BUG REPORTS TO filter@bolthole.com .SH COPYRIGHTS \fB\*(ct\fRCopyright 1988-1992 by The USENET Community Trust .br Derived from Elm 2.0, \fB\*(ct\fR Copyright 1986, 1987 by Dave Taylor filter2.6.3/CHANGELOG0000644000127400000010000000563410162732126014240 0ustar philother00000000000000 Yes, this changelog is only being started with filter version 2.2 Changes are from filter.2.1.3 filter2.2 Added make_tempfile() routine to make sure tempfile is created in secure fashion. Then improved tempfile name to be much more unique. (added username to it) Then rewrote all the wasteful "close tmpfile,open tmpfile" code to reuse the existing FILE*. THEN had to rewrite the execute() code, which turns out to be a security advantage also. Now removes tempfile before exit(EX_TEMPFAIL) if cannot get lock on folder. Plus, added %f option to mailhome. user mailboxes can be specified by /var/mail/%f/%u -> /var/mail/p/phil This version is the "Andrew Stribblehill" release. Thanks for all the code suggestions! :-) filter 2.2.1 Updated Configure script to default to flock=n for solaris. Removed unused domain name check Fixed up status for pclose() in actions.c, and stopped premature removal of tempfile in mail_message(), for consistency filter 2.2.2 Minor cleanup stuff for Configure script. Removed chown(-1) question added filter URL to usage message Added SOME prototypes. Got rid of damn nested /**/ in config.h.SH, cause -Wall was driving me NUTS. Fixed setuid test: never tested positive! and much makefile tweaking, so that I could finally make a Debian linux package out of it. But really, I should get back to fixing up filter3.0! (work in progress, to use autoconf) filter2.3 Fixed premature fclose() in mail_message(). After my optimization in filter.2.2.X, this was redundant. Now forwardc and executec work properly Removed get_tz.c, since we dont use timezones in filter. filter2.3.1 Fixed up LICENSE file to be the way it should have been to start with, plus updated README file some. filter2.4 Fixed some "bounce" printouts. Added "resend" action Added "mailinglist" header (x-mailing-list) Fixed silent broken acceptance of "!=" as string comparison. (made it WORK!) **CHANGED** use of $HOME/.elm/ to $HOME/.filter/ !! filter2.4.1 Adjusted manpage to show $HOME/.filter Added ">From " escaping when saving messages to a local file, not just mbox. filter2.4.2 Fixed parsing of "lines" argument, in get_filter_rules(). what a diference a brace makes... (moved up a line) Now if(lines XXXX) should actually WORK again! filter2.5 Added "alphasubject" virtual header type. Strips out all but alpha chars, and forces to lower case Because new obnoxious type mails, need obnoxious filtering solutions filter2.5.1 Added iso de-miming, for subject line. probably buggy. filter2.6 Added separation of envelope from, header from, and reply-to. "from" now matches on all those, plus sender header. filter2.6.1 Just tweaked Configure script to find flock on redhat systems Thanks to Ned Danieley for sending in a patch, and testing filter 2.6.2 Fixed security hole in filter.c:save_embedded_address() filter 2.6.3 Stupid syntax error in Configure fixed. filter2.6.3/BUGS0000644000127400000010000000050607175621447013517 0ustar philother00000000000000All known bugs fixed. But if you ever get paranoid about filter not putting things in your mailbox (eg defaulting to "save $MAIL" as last action), put as the last line of your filter file, save always /your/mailbox/here (eg "save always /var/mail/yourname") Please send any additional bug reports to filter@bolthole.com filter2.6.3/filter.c0000644000127400000010000005105110157773446014467 0ustar philother00000000000000 /****************************************************************************** * The Elm Mail System - forked from $Revision: 5.7 $ $State: Exp $ * * Copyright (c) 1988-1992 USENET Community Trust * Copyright (c) 1986,1987 Dave Taylor ****************************************************************************** * Bug reports, patches, comments, suggestions should be sent to: * * Philip Brown filter@bolthole.com * ****************************************************************************** * $Log: filter.c,v $ * * may 31, 2000; changed checksetgid() on security suggestion from * Andrew Stribblehill * * 1999/11/23 phil * added in setting user_mailbox from getenv("MAIL") * * 1998/07/18 phil * fixed ifdefs for RCPT_HDR * * 1998/03/31 phil * Added "rcpt-to" support * * Revision 5.7 1994/05/30 16:31:40 syd * make getpwuid dependent on ANSI_C not posix flag * From: Syd * * Revision 5.6 1993/08/03 19:28:39 syd * Elm tries to replace the system toupper() and tolower() on current * BSD systems, which is unnecessary. Even worse, the replacements * collide during linking with routines in isctype.o. This patch adds * a Configure test to determine whether replacements are really needed * (BROKE_CTYPE definition). The header file is now included * globally through hdrs/defs.h and the BROKE_CTYPE patchup is handled * there. Inclusion of was removed from *all* the individual * files, and the toupper() and tolower() routines in lib/opt_utils.c * were dropped. * From: chip@chinacat.unicom.com (Chip Rosenthal) * * Revision 5.5 1993/06/06 17:58:20 syd * make white space skipping work for blank or tab * * Revision 5.4 1993/01/27 19:40:01 syd * I implemented a change to filter's default verbose message format * including %x %X style date and time along with username * From: mark@drd.com (Mark Lawrence) * * Revision 5.3 1992/11/15 01:40:43 syd * Add regexp processing to filter. * Add execc operator * From: Jan Djarv * * Revision 5.2 1992/11/07 16:20:56 syd * The first is that when doing a summary, macros are expanded when printing the * rule. IMHO they should be printed as with the -r option (i.e. %t is * printed as "