procmail
[Top] [All Lists]

Re: allow only *.zip

2001-01-05 10:51:33
Jo o Paulo Andrade wrote:
I am trying to configure the procmail to allow only archives
with extensions *.zip.  which are the rules that I must add?

This is kinda hard.

If an attachment is there and the filename doesn't end with '.zip',
what do you want to do with the mail?  Bounce it?  

Where do you want to test the ".zip" thing?  In content-type 'name='
or content-disposition 'filename='?

Here is my 5-minute attempt, which may give a starting point

    :0
    * ^mime-version:
    * ^content-type:.*multipart
    * B ?? ^content-type:
    * B ?? ^content-disposition:.*attachment
    {
        LOCKFILE=/tmp/munpack.$LOGNAME

        :0c
        | ( T=/tmp/$LOGNAME/munpack; rm -rf $T; mkdir -p $T; | \
            ( munpack -C $T 2>/dev/null; rm -rf $T; )        | \
            grep -iv -e '\.desc (' -e '\.zip (' )

        LOCKFILE

        # If previous action line executed SUCCESSFULLY, i.e., if
        # there were files other than '.zip' and '.desc' then message
        # is BAD!
        :0 a
        IllegalAttachment

        # If we get here, then the "grep" must have failed, so the
        # only attachments were .desc and .zip -- hence msg is OK
        :0
        $DEFAULT

    }

OK, that took longer than 5 minutes, it's completely untested, use at
own risk, etc.
-- 
Neither I nor my employer will accept any liability for any problems
or consequential loss caused by relying on this information.  Sorry.
Collin Park                         Not a statement of my employer.
_______________________________________________
procmail mailing list
procmail(_at_)lists(_dot_)RWTH-Aachen(_dot_)DE
http://MailMan.RWTH-Aachen.DE/mailman/listinfo/procmail

<Prev in Thread] Current Thread [Next in Thread>