123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320 |
- .TH FILTER 1
- .SH NAME
- filter, list, deliver, token, vf \- filtering mail
- .SH SYNOPSIS
- .PP
- .B upas/filter
- [
- .B -bh
- ]
- .I rcvr
- .I mailbox
- [
- .I "regexp file
- ] ...
- .PP
- .B upas/list
- [
- .B -d
- ]
- .B add|check
- .I patternfile
- .I addressfile ...
- .PP
- .B upas/deliver
- .I recipient
- .I fromfile
- .I mbox
- .PP
- .B upas/token
- .I key
- [
- .I tokenfile
- ]
- .PP
- .B upas/vf
- [
- .B -r
- ]
- [
- .B -s
- .I savefile
- ]
- .SH DESCRIPTION
- .PP
- A user may filter all incoming mail by creating
- a world readable/executable file
- .BI /mail/box/ username /pipeto.
- If the file is a shell script, it can use the
- commands described here to implement a filter.
- .PP
- .I Filter
- provides simple mail filtering.
- The first two arguments are the recipient's address and mailbox, that is,
- the same arguments provided to
- .BR pipeto .
- The remaining arguments are all pairs of a regular expression and a file name.
- With no flags, the sender's address is matched against each
- regular expression starting with the first. If the expression
- matches, then the message is delivered to the file whose name
- follows the expression. The file must be world writable and should
- be append only.
- A message that matches none of the expressions is delivered into
- the user's standard mail box.
- .PP
- By default,
- .I filter
- matches each regular expression against the message's sender.
- The
- .B -h
- flag causes
- .I filter
- to match against the entire header,
- and the
- .B -b
- flag causes
- .I filter
- to match against the entire message (header and body).
- .PP
- For example, to delete any messages of precedence bulk, place in
- your
- .B pipeto
- file:
- .EX
- /bin/upas/filter -h $1 $2 'Precedence: bulk' /dev/null
- .EE
- .PP
- Three other commands exist which, combined by an
- .IR rc (1)
- script, allow you to build your own filter.
- .PP
- .I List
- takes two verbs;
- .B check
- and
- .BR add .
- .B Check
- directs
- .I list
- to check each address contained in the
- .IR addressfile s
- against a list of patterns in
- .IR patternfile .
- Patterns come in four forms:
- .TP
- .B ~\fIregular-expression\fP
- If any address matches the regular expression,
- .I list
- returns successfully.
- .TP
- .BR =\fIstring\fP .
- If any address exactly matches
- .IR string ,
- .I list
- returns successfully.
- .TP
- .B !~\fIregular-expression\fP
- If any address matches the regular expression
- and no other address matches a non `!' rule,
- .I list
- returns error status "!match".
- .TP
- .B !=\fIstring\fP
- If any address exactly matches
- .I string
- and no other address matches a non `!' rule,
- .I list
- returns error status "!match".
- .PP
- If no addresses match a pattern,
- .I list
- returns "no match".
- .PP
- The pattern file may also contain lines of the form
- .EX
- #include filename
- .EE
- This allows pattern files to include other pattern
- files.
- All pattern matches are case insensitive.
- .I List
- searches the pattern file (and its includes) in order.
- The first matching pattern determines the action.
- .PP
- .I List
- .B add
- directs
- .I list
- to add a pattern to
- .I patternfile
- for each address in the
- .I addressfiles
- that doesh't already match a pattern.
- .PP
- .IR Token ,
- with only one argument, prints to standard output a unique token
- created from the current date and
- .IR key .
- With two arguments, it checks
- .I token
- against tokens created over the last 10 days with
- .IR key .
- If a match is found, it returns successfully.
- .PP
- .I Deliver
- delivers into mail box
- .I mbox
- the message read from standard input.
- It obeys standard mail file locking and logging
- conventions.
- .PP
- A sample
- .B pipeto
- using the filter kit can be found in
- .BR /sys/src/cmd/upas/filterkit/pipeto.sample .
- .PP
- A sample
- .BR pipefrom ,
- .BR /sys/src/cmd/upas/filterkit/pipefrom.sample ,
- is provided which adds all addresses of your outgoing
- mail to your pattern file.
- You should copy it into a directory that normally gets
- bound by your profile onto
- .BR /bin .
- .PP
- .I Vf
- (virus filter)
- takes a mail message as standard input
- and searches for executable MIME attachments,
- either rewriting them to be non-executable or
- rejecting the message.
- The behavior depends on the attachment's file name
- extension and MIME content type.
- .B /sys/lib/mimetype
- contains the list of known extensions and MIME content types.
- The fifth field of each line specifies the
- safety of a particular file type:
- .B y
- (yes),
- .B m
- (maybe; treated same as yes),
- .B n
- (no),
- .B p
- (previous),
- or
- .B r
- (reject).
- .I Vf
- allows attachments with safety
- .B y
- or
- .B m
- to pass through unaltered.
- Attachments with safety
- .B n
- both are wrapped in extra MIME headers
- and have
- .B .suspect
- appended to their file names, to avoid
- automatic execution by mail readers.
- Attachments with safety
- .B r
- (currently,
- .BR .bat ,
- .BR .com ,
- .BR .exe ,
- and
- .BR .scr ,
- all Microsoft executable extensions)
- are taken as
- cause for the entire message to be rejected.
- A safety of
- .B p
- (used for the
- .B x-gunzip
- mime type)
- causes the previous extension to be tested,
- so that
- .B x.tar.gz
- is treated the same as
- .BR x.tar .
- .PP
- If
- .B /mail/lib/validateattachment
- exists and is executable,
- .B vf
- runs it on all attachments with safety
- .B n
- (attachments it would normally sanitize).
- If
- .IR validateattachment 's
- exit status contains the string
- .L discard ,
- .I vf
- rejects the entire message.
- If the status contains the string
- .L accept ,
- .I vf
- does not sanitize the attachment.
- Otherwise,
- .I vf
- sanitizes the attachment as before.
- The standard
- .I validateattachment
- uses
- .IR file (1)
- to determine the file type.
- It accepts text and image files
- and discards messages containing
- executables or
- .I zip
- (see
- .IR gzip (1))
- archives of executables.
- .PP
- The
- .B -r
- option causes
- .I vf
- not to sanitize MIME attachments, only to
- reject messages it determines to be viruses.
- The
- .B -s
- option causes
- .I vf
- to log all attachments of safety
- .B r
- in the mail box
- .IR savefile .
- .SH FILES
- .TF /mail/box/*/dead.letter
- .TP
- .B /mail/box/*/pipeto
- mail filter
- .TP
- .B /sys/lib/mimetype
- MIME content types
- .TP
- .B /mail/lib/validateattachment
- attachment checker
- .SH SOURCE
- .TP
- .B /sys/src/cmd/upas/send
- .TP
- .B /sys/src/cmd/upas/filterkit
- .TP
- .B /sys/src/cmd/upas/vf
- .SH "SEE ALSO"
- .IR aliasmail (8),
- .IR faces (1),
- .IR mail (1),
- .IR marshal (1),
- .IR mlmgr (1),
- .IR nedmail (1),
- .IR qer (8),
- .IR rewrite (6),
- .IR send (8),
- .IR smtp (8),
- .IR upasfs (4)
|