320 lines · 6.0 KB · Text
RawDownload
.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)