.TH FILTER 1.SH NAMEfilter, list, deliver, token, vf \- filtering mail.SH SYNOPSIS.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 DESCRIPTIONA user may filter all incoming mail by creatinga world readable/executable file.BI /mail/box/ username /pipeto.If the file is a shell script, it can use thecommands described here to implement a filter..PP.I Filterprovides 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 eachregular expression starting with the first. If the expressionmatches, then the message is delivered to the file whose namefollows the expression. The file must be world writable and shouldbe append only.A message that matches none of the expressions is delivered intothe user's standard mail box..PPBy default,.I filtermatches each regular expression against the message's sender.The.B -hflag causes.I filterto match against the entire header,and the.B -bflag causes.I filterto match against the entire message (header and body)..PPFor example, to delete any messages of precedence bulk, place inyour.B pipetofile:.IP.EX/bin/upas/filter -h $1 $2 'Precedence: bulk' /dev/null.EE.PPThree other commands exist which, combined by an.IR rc (1)script, allow you to build your own filter..PP.I Listtakes two verbs;.B checkand.BR add ..B Checkdirects.I listto check each address contained in the.IR addressfile sagainst a list of patterns in.IR patternfile .Patterns come in four forms:.TF ~\fIregular-expression\fP.PD.TP.B ~\fIregular-expression\fPIf any address matches the regular expression,.I listreturns successfully..TP.BR =\fIstring\fP .If any address exactly matches.IR string ,.I listreturns successfully..TP.B !~\fIregular-expression\fPIf any address matches the regular expressionand no other address matches a non `!' rule,.I listreturns error status "!match"..TP.B !=\fIstring\fPIf any address exactly matches.I stringand no other address matches a non `!' rule,.I listreturns error status "!match"..PPIf no addresses match a pattern,.I listreturns "no match"..PPThe pattern file may also contain lines of the form.IP.EX#include filename.EE.LPto allow pattern files to include other pattern files.All pattern matches are case insensitive..I Listsearches the pattern file (and its includes) in order.The first matching pattern determines the action..PP.I List.B adddirects.I listto add a pattern to.I patternfilefor each address in the.I addressfilesthat doesh't already match a pattern..PP.IR Token ,with only one argument, prints to standard output a unique tokencreated from the current date and.IR key .With two arguments, it checks.I tokenagainst tokens created over the last 10 days with.IR key .If a match is found, it returns successfully..PP.I Deliverdelivers into mail box.I mboxthe message read from standard input.It obeys standard mail file locking and loggingconventions..PP.B /sys/src/cmd/upas/filterkit/pipeto.sampleis a sample.B pipetousing the filter kit..PPA sample.BR pipefrom ,.BR /sys/src/cmd/upas/filterkit/pipefrom.sample ,is provided which adds all addresses of your outgoingmail to your pattern file.You should copy it into a directory that normally getsbound by your profile onto.BR /bin ..PP.I Vf(virus filter)takes a mail message as standard inputand searches for executable MIME attachments,either rewriting them to be non-executable orrejecting the message.The behavior depends on the attachment's file nameextension and MIME content type..B /sys/lib/mimetypecontains the list of known extensions and MIME content types.The fifth field of each line specifies thesafety 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 Vfallows attachments with safety.B yor.B mto pass through unaltered.Attachments with safety.B nboth are wrapped in extra MIME headersand have.B .suspectappended to their file names, to avoidautomatic 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 ascause for the entire message to be rejected.A safety of.B p(used for the.B x-gunzipmime type)causes the previous extension to be tested,so that.B x.tar.gzis treated the same as.BR x.tar ..PPIf.B /mail/lib/validateattachmentexists and is executable,.B vfruns it on all attachments with safety.B n(attachments it would normally sanitize).If.IR validateattachment 'sexit status contains the string.LR discard ,.I vfrejects the entire message.If the status contains the string.LR accept ,.I vfdoes not sanitize the attachment.Otherwise,.I vfsanitizes the attachment as before.The standard.I validateattachmentuses.IR file (1)to determine the file type.It accepts text and image filesand discards messages containingexecutables or.I zip(see.IR gzip (1))archives of executables..PPThe.B -roption causes.I vfnot to sanitize MIME attachments, but instead toreject messages it determines to be viruses.The.B -soption causes.I vfto log all attachments of safety.B rin the mail box.IR savefile ..SH FILES.TF /mail/lib/validateattachment.TP.B /mail/box/*/pipetomail filter.TP.B /sys/lib/mimetypeMIME content types.TP.B /mail/lib/validateattachmentattachment checker.SH SOURCE.B /sys/src/cmd/upas/send.br.B /sys/src/cmd/upas/filterkit.br.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)
.TH FILTER 1
.SH NAME
filter, list, deliver, token, vf \- filtering mail
.SH SYNOPSIS
.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
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:
.IP
.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:
.TF ~\fIregular-expression\fP
.PD
.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
.IP
.EX
#include filename
.EE
.LP
to allow 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
.B /sys/src/cmd/upas/filterkit/pipeto.sample
is a sample
.B pipeto
using the filter kit.
.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
.LR discard ,
.I vf
rejects the entire message.
If the status contains the string
.LR 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, but instead 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/lib/validateattachment
.TP
.B /mail/box/*/pipeto
mail filter
.TP
.B /sys/lib/mimetype
MIME content types
.TP
.B /mail/lib/validateattachment
attachment checker
.SH SOURCE
.B /sys/src/cmd/upas/send
.br
.B /sys/src/cmd/upas/filterkit
.br
.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)