[Mimedefang] Block specified mime type

Steffen Kaiser skmimedefang at smail.inf.fh-bonn-rhein-sieg.de
Fri Dec 14 09:54:23 EST 2012


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On Fri, 14 Dec 2012, Zoltán Gyula Beck wrote:

> block/remove (remove the attachement but the mail is passed with a
> notification, that the <file.ext> was removed and contanct the sender
> if you really need that file) some type of attachements, .exe, .bat,
> etc ... I tried with $bad_exts but if I rename an .exe to .pdf then
> mimedefang passes. Is there a way to check the file type and not only
> the extension?

first, make yourself comfortable with the fact, that the mimedefang config 
file is a Perl script.

Second, in sub filter() the first parameter is the item currently found 
and ready to check, see man mimedefang-filter

        $entity
               The MIME::Entity object.  (See the MIME::tools Perl module 
documentation.)

In  perldoc MIME::Entity you'll find the doc to access the object:

There you'll see:

        bodyhandle [VALUE]
            Instance method.  Get or set an abstract object representing 
the body of the message.  The body holds the
            decoded message data.

            Note that not all entities have bodies!  An entity will have 
either a body or parts: not both.  This
            method will only return an object if this entity can have a 
body; otherwise, it will return undefined.
            Whether-or-not a given entity can have a body is determined by 
(1) its content type, and (2) whether-or-
            not the parser was told to extract nested messages:

When you have access to the file content, you could for instance use the 
Perl modul File::MMagic to guess file type.

Regards,

- -- 
Steffen Kaiser
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.11 (GNU/Linux)

iQEVAwUBUMs9n/41+pMevzVSAQIqCQgAvSAuKO7C29hhZ6okPVrvcseFgoNdesFp
Lc7hJ9vz1nJzMFpqPhTpUcynqfmt913KipRYb8Ya5auLGXLXHrE+o7DQrqyJI177
y/LmpFCB8WD83qXnSzsEvGvbO2K9gQsQRAj9dBe6VAcQ3ey+qWlCIAg2Ewvwi5na
C/HX3RdkirubEr7e0NcL9sVHUl49UvAAXDRqYugdC7DdEBKqOnKq2AwQ/CSKiMvY
sGEGHpcg+RrXbEGO9HLAsbufZvcq7X7rEQaCqY9BvpwVX2DMB6xpKMMMMvE/vFIG
Guw7X5jt3iIXkPv9bWwunqmv2SIN901V0zpJRkyk8gpC1qhZFMoCaA==
=vCne
-----END PGP SIGNATURE-----


More information about the MIMEDefang mailing list