| #!/usr/local/plan9/bin/rc |
| # *discard* - is really bad, refuse the message |
| # *accept* - is really good, leave attachment alone |
| # * - rewrite attachment to have .suspect extension |
| # magic exit statuses known to vf |
| wrap=123 # anything but 10, 13 |
| echo usage: validateattachment mboxfile >[1=2] |
| # cp $file /n/other/upas/tmp/$d.$1 |
| # cp raw /n/other/upas/tmp/$d.$1.raw |
| # whatis x >/n/other/upas/tmp/$d.$1.file |
| x=`{file <$file | sed s/stdin://} |
| case *Ascii* *text* *'c program'* *'rc executable'* |
| # >[2=1] because sometimes we get zip files we can't parse |
| # but the errors look like |
| # unzip: reading data for philw.doc.scr failed: ... |
| # so we can still catch these. |
| if(unzip -tsf $file >[2=1] | grep -si ' |\.(scr|exe|pif|bat|com)$'){ |
| echo executables inside zip file! |
| case jpeg 'PNG image' bmp 'GIF image' *'plan 9 image' |
| case *Microsoft* *Office* |