[Mimedefang] Blocking unwanted files

Lucas Albers admin at cs.montana.edu
Tue Dec 9 13:24:18 EST 2003


--reposted from my earlier post, cause I want everyone to realize how cool
--I am.

how about this?
This used the perl library for mimetype determination.
install File::MimeInfo::Magic

Then install binary package for your os.

http://freedesktop.org/Software/shared-mime-info

This should be a more generalized solution, as you can just add in the
types to block on the regular expression match after the comparison.

 use File::MimeInfo::Magic;


   sub filter ($$$$) {
     my($entity, $fname, $ext, $type) = @_;
     my $path = $entity->bodyhandle->path;
     my $mimeftype = mimetype($path);
     if ($mimeftype =~ /^application\/x-executable$/) {
     return action_bounce("$fname smells like a Windoze EXE...");
    }
}

--Luke

> Basically they want mimedefang to open the attachement and determine
> if the file type matches the extension. They suspect some users are
> trading mp3 via mail, just changing the extension to .pdf or some other
> valid extension.



More information about the MIMEDefang mailing list