[Mimedefang] action_replace_with_url

bart bartoszx at euro26.pl
Fri Mar 4 15:13:33 EST 2005


Witaj Kevin,

W Twoim liœcie datowanym 4 marca 2005 (20:04:07) mo¿na przeczytaæ:

> I don't want to lead you down a primrose path as I don't use
> action_replace_with_url however I edited the code snippet below to indicate
> where the logic should go assuming the file size logic was the issue.

I tried this but dosn not work

Mar  4 20:55:22 tx2 sm-mta-tx[3983]: j24JtM0P003983: from=<>, size=127506, class=0, nrcpts=1, msgid=<592531395.20050304210847@>, proto=ESMTP, daemon=MTA-TX, relay=localhost [127.0.0.1]
Mar  4 20:55:22 tx2 mimedefang-multiplexor[29939]: Slave 0 died prematurely -- check your filter rules and use the '-l' flag on mimedefang-multiplexor to see Perl error messages
Mar  4 20:55:22 tx2 mimedefang[29955]: Error from multiplexor: ERR No response from slave
Mar  4 20:55:22 tx2 sm-mta-tx[3983]: j24JtM0P003983: Milter: data, reject=451 4.7.1 Please try again later
Mar  4 20:55:22 tx2 sm-mta-tx[3983]: j24JtM0P003983: to=<bartoszx@[127.0.0.1]>, delay=00:00:00, pri=157506, stat=Please try again later
Mar  4 20:55:22 tx2 amavis[28210]: (28210-04) mail_via_smtp: 451 4.6.0 Failed, id=28210-04, from MTA: 451 4.7.1 Please try again later

mimedefang-filter


sub filter ($$$$) {
    my($entity, $fname, $ext, $type) = @_;

    return if message_rejected(); # Avoid unnecessary work

    # Block message/partial parts
    if (lc($type) eq "message/partial") {
        md_graphdefang_log('message/partial');
        action_bounce("MIME type message/partial not accepted here");
        return action_discard();
    }

    if (filter_bad_filename($entity)) {
        md_graphdefang_log('bad_filename', $fname, $type);
        return action_drop_with_warning("An attachment named $fname was removed from this document as it\nconstituted a security hazard.  If you require this document, please contact\nthe sender a
    }

    # eml is bad if it's not multipart
    if (re_match($entity, '\.eml')) {
        md_graphdefang_log('non_multipart');
        return action_drop_with_warning("A non-multipart attachment named $fname was removed from this document as it\nconstituted a security hazard.  If you require this document, please contact\
    }
    # Clean up HTML if Anomy::HTMLCleaner is installed.
    if ($Features{"HTMLCleaner"}) {
        if ($type eq "text/html") {
            return anomy_clean_html($entity);
        }
    }

 #Added section for dealing with large attachments
        #**********************************************************************

   my($sizelimit, $bh, $path);

      $sizelimit = 10485; #1MB #max size of an email you want to check in bytes

      $bh = $entity->bodyhandle();
      if (defined($bh)) {
        $path = $bh->path();
      }
      if (defined($path)) {
        if (-s $path <= $sizelimit) {
         return action_replace_with_url($entity,
        "/home/www",
        "http://www.euro26.pl/",
        "The attachment $fname was larger than 10,000,000 bytes.\n" .
        "It was removed, but may be accessed at this URL:\n\n" .
        "\t_URL_\n");

        }
      }
}


    return action_accept();
}





More information about the MIMEDefang mailing list