1 #!/usr/local/plan9/bin/rc
6 # exit status matching:
8 # $discard - is really bad, refuse the message
9 # $accept - is really good, leave attachment alone
10 # anything else - rewrite attachment to have .suspect extension
13 # magic exit statuses known to vf
17 wrap=123 # anything but 10, 13
20 echo usage: validateattachment mboxfile >[1=2]
24 # some idiot virus is sending around attachments marked as .zip
25 # that are completely bogus and just say %TS_ZIP_ATTACH%
26 # as the base64 encoding of the zip file. gmail rejects all zip
27 # attachments when we forward them, so nip this one here.
28 if(grep -s '^%TS_ZIP_ATTACH%$' $1 && ~ `{wc -l <$1} 1 2 3 4 5 6 7 8 9 10){
33 upas/unvf < $1 >$1.unvf
35 fn sigexit { rm $file }
39 # cp $file /n/other/upas/tmp/$d.$1
40 # cp raw /n/other/upas/tmp/$d.$1.raw
41 # whatis x >/n/other/upas/tmp/$d.$1.file
44 x=`{file <$file | sed s/stdin://}
47 case *Ascii* *text* *'c program'* *'rc executable'*
53 # >[2=1] because sometimes we get zip files we can't parse
54 # but the errors look like
55 # unzip: reading data for philw.doc.scr failed: ...
56 # so we can still catch these.
57 if(unzip -tsf $file >[2=1] | grep -si ' |\.(scr|exe|pif|bat|com)$'){
58 echo executables inside zip file!
62 case jpeg 'PNG image' bmp 'GIF image' *'plan 9 image'
66 case *Microsoft* *Office*