Re: effacer un attachement avec procmail

Pàgina inicial

Reply to this message
Autor: Edgar Bonet
Data:  
A: Liste Guilde
Assumpte: Re: effacer un attachement avec procmail
Le lundi 19 avril, Stephane Driussi a écrit :
> j'ai une regle dans mon procmailrc qui parse le mail entrant et s'il
> contient un virus, depose cet email dans la poubelle. Je voudrais
> ameliorer mon systeme en effacant l'attachement car si sous windows on
> ouvre le dossier trash on se retrouve expose aux virus.
>
> Comment effacer l'attachement d'un email avec procmail ?


Avec procmail tout seul je ne sais pas, mais avec l'aide de Perl je fais
ça :

Dans .procmailrc :
------------------

:0 f
| single-part


Dans ~/bin/single-part :
------------------------

#!/usr/bin/perl

# single-part: keep only first part of multipart/* e-mail.

# Read headers
while (<>) {
    last if /^$/;
    $headers .= $_;
}


# Check for multipart
if ($headers =~ /^Content-Type:\s+multipart\/.*?boundary="(.*?)"/smi ||
    $headers =~
    /^Content-Type:\s+multipart\/.*?boundary=([-\w!#\$\%&'*+\.^_`{|}~]*)/smi)
{
    $boundary = $1;
}


# Print message
print "$headers\n";
while (<>) {
    if ($boundary) {
        $part++ if /^--$boundary$/;
        $part = 1 if /^--$boundary--$/;
        next if $part != 1;
    }
    print;
}


-- 
Edgar Bonet           Maison : 04 76 21 29 16    Bureau : 04 76 88 10 96
3 rue Jean Prévost    Mobile : 06 77 19 79 39    Fax    : 04 76 88 11 91
38000 Grenoble        guilde@???     www.edgar-bonet.org