1 (edited by RafaelMass 2012-03-22 03:09:27)

Topic: docx,xlsx,pptx attachments block error

I'm using iRedMail 0.5.1 postfix mysql in a debian 5.0.4 x64.
we have a problem, the amavis are blocking docx, xlsx ... files in attachments (and we are having "some problems" with that). I look the config file but I don't know wath is the problem in configuration.

message in mail.log:

Mar 21 08:43:23 localhost amavis[28300]: (28300-16) Blocked BANNED (multipart/mixed | application/vnd.openxmlformats-officedocument.presentationml.presentation,.zip,=?iso-8859-1?Q?Proposta_Processo_de_Devolu=E7=E3o_e_Canhotos.__(8).pptx?=,Proposta Processo de Devolu\347\343o e Canhotos.  (8).pptx | .doc,ppt/embeddings/oleObject2.bin), LOCAL [216.82.242.179] [200.142.207.241] <francieli.baby@brf.com> -> <andreia@transardo.com.br>, quarantine: T/banned-TaaxZcYICDWC, Message-ID: <3DA0413F5D17CD46A3E56CD1B4B000E607486F18@HOR63.perdigao.com.br>, mail_id: TaaxZcYICDWC, Hits: -, size: 890924, 350 ms

I try this:
http://www.clearfoundation.com/componen … /id,15627/
but doesn't work.

my /etc/amavis/50-user file:

use strict;

#
# Place your configuration directives here.  They will override those in
# earlier files.
#
# See /usr/share/doc/amavisd-new/ for documentation and examples of
# the directives you can use in this file
#


#------------ Do not modify anything below this line -------------
#{1}


chomp($mydomain = "www.transardo.com.br");
@local_domains_maps = ['www.transardo.com.br', 'transardo.com.br'];
@mynetworks = qw( 127.0.0.0/8 [::1] [FE80::]/10 [FEC0::]/10
                  10.0.0.0/8 172.16.0.0/12 192.168.0.0/16 );

# Enable virus check.
@bypass_virus_checks_maps = (
   \%bypass_virus_checks,
   \@bypass_virus_checks_acl,
   $bypass_virus_checks_re,
   );

# Enable spam check.
@bypass_spam_checks_maps = (
    \%bypass_spam_checks,
    \@bypass_spam_checks_acl,
    $bypass_spam_checks_re,
    );

$banned_filename_re = new_RE(
    qr'.\.(bat|exe|scr|bin|com|cmd|avi|divx|xvid|mpg|mpeg|mp3|mp4|ogg|mid|midi|wav|wmv)$'i,
    qr'^\.(exe)$'i,
    );

$virus_admin = "root\@$mydomain"; # due to D_DISCARD default
$mailfrom_notify_admin = "root\@$mydomain";
$mailfrom_notify_recip = "root\@$mydomain";
$mailfrom_notify_spamadmin = "root\@$mydomain";

# Mail notify.
$mailfrom_notify_admin     = "root\@$mydomain";  # notifications sender
$mailfrom_notify_recip     = "root\@$mydomain";  # notifications sender
$mailfrom_notify_spamadmin = "root\@$mydomain"; # notifications sender
$mailfrom_to_quarantine = ''; # null return path; uses original sender if undef

# Disable defang banned mail.
$defang_banned = 0;  # MIME-wrap passed mail containing banned name

$policy_bank{'MYNETS'} = {   # mail originating from @mynetworks
  originating => 1,  # is true in MYNETS by default, but let's make it explicit
  os_fingerprint_method => undef,  # don't query p0f for internal clients
  allow_disclaimers => 1,  # enables disclaimer insertion if available
};

$policy_bank{'ORIGINATING'} = {  # mail supposedly originating from our users
  originating => 1,  # declare that mail was submitted by our smtp client
  allow_disclaimers => 1,  # enables disclaimer insertion if available
  # notify administrator of locally originating malware
  virus_admin_maps => ["root\@$mydomain"],
  spam_admin_maps  => ["root\@transardo.com"],
  warnbadhsender   => 1,
  # forward to a smtpd service providing DKIM signing service
  #forward_method => 'smtp:[127.0.0.1]:10027',
  # force MTA conversion to 7-bit (e.g. before DKIM signing)
  smtpd_discard_ehlo_keywords => ['8BITMIME'],
  bypass_banned_checks_maps => [1],  # allow sending any file names and types
  terminate_dsn_on_notify_success => 0,  # don't remove NOTIFY=SUCCESS option
};

# Set listen IP/PORT.
$notify_method  = 'smtp:[127.0.0.1]:10025';
$forward_method = 'smtp:[127.0.0.1]:10025';

# Set default action.
$final_virus_destiny      = D_DISCARD;
$final_banned_destiny     = D_REJECT;
$final_spam_destiny       = D_PASS;
$final_bad_header_destiny = D_PASS;

@av_scanners = (

    #### http://www.clamav.net/
    ['ClamAV-clamd',
    \&ask_daemon, ["CONTSCAN {}\n", "/tmp/clamd.socket"],
    qr/\bOK$/, qr/\bFOUND$/,
    qr/^.*?: (?!Infected Archive)(.*) FOUND$/ ],
);


@av_scanners_backup = (

    ### http://www.clamav.net/   - backs up clamd or Mail::ClamAV
    ['ClamAV-clamscan', 'clamscan',
    "--stdout --disable-summary -r --tempdir= {}", [0], [1],
    qr/^.*?: (?!Infected Archive)(.*) FOUND$/ ],
);

# This policy will perform virus checks only.
#$interface_policy{'10026'} = 'VIRUSONLY';
#$policy_bank{'VIRUSONLY'} = { # mail from the pickup daemon
#    bypass_spam_checks_maps   => [1],  # don't spam-check this mail
#    bypass_banned_checks_maps => [1],  # don't banned-check this mail
#    bypass_header_checks_maps => [1],  # don't header-check this mail
#};

# Allow SASL authenticated users to bypass scanning. Typically SASL
# users already submit messages to the submission port (587) or the
# smtps port (465):
#$interface_policy{'10026'} = 'SASLBYPASS';
#$policy_bank{'SASLBYPASS'} = {  # mail from submission and smtps ports
#    bypass_spam_checks_maps   => [1],  # don't spam-check this mail
#    bypass_banned_checks_maps => [1],  # don't banned-check this mail
#    bypass_header_checks_maps => [1],  # don't header-check this mail
#};

# SpamAssassin debugging. Default if off(0).
# Note: '$log_level' variable above is required for SA debug.
$log_level = 0;              # verbosity 0..5, -d
$sa_debug = 0;

# Modify email subject, add '$sa_spam_subject_tag'.
#   0:  disable
#   1:  enable
$sa_spam_modifies_subj = 1;

# remove existing headers
#$remove_existing_x_scanned_headers= 0;
#$remove_existing_spam_headers = 0;

# Leave empty (undef) to add no header.
# Modify /usr/sbin/amavisd or /usr/sbin/amavisd-new file to add customize header in:
#
#   sub add_forwarding_header_edits_per_recip
#
#$X_HEADER_TAG = 'X-Virus-Scanned';
#$X_HEADER_LINE = "by amavisd at $myhostname";

# Notify virus sender?
$warnvirussender = 1;

# Notify spam sender?
$warnspamsender = 0;

# Notify sender of banned files?
$warnbannedsender = 0;

# Notify sender of syntactically invalid header containing non-ASCII characters?
$warnbadhsender = 0;

# Notify virus (or banned files) RECIPIENT?
#  (not very useful, but some policies demand it)
$warnvirusrecip = 0;
$warnbannedrecip = 0;

# Notify also non-local virus/banned recipients if $warn*recip is true?
#  (including those not matching local_domains*)
$warn_offsite = 1;

#$notify_sender_templ      = read_text('/var/amavis/notify_sender.txt');
#$notify_virus_sender_templ= read_text('/var/amavis/notify_virus_sender.txt');
#$notify_virus_admin_templ = read_text('/var/amavis/notify_virus_admin.txt');
#$notify_virus_recips_templ= read_text('/var/amavis/notify_virus_recips.txt');
#$notify_spam_sender_templ = read_text('/var/amavis/notify_spam_sender.txt');
#$notify_spam_admin_templ  = read_text('/var/amavis/notify_spam_admin.txt');
# The default set of header fields to be signed can be controlled
# by setting %signed_header_fields elements to true (to sign) or
# to false (not to sign). Keys must be in lowercase, e.g.:
# 0 -> off
# 1 -> on
$signed_header_fields{'received'} = 0;
$signed_header_fields{'to'} = 1;

# Make sure it sings all inbound mails, avoid error log like this:
# 'dkim: not signing inbound mail'.
$originating = 1;

# Add dkim_key here.
dkim_key("transardo.com.br", "dkim", "/var/lib/dkim/transardo.com.br.pem");

# Note that signing mail for subdomains with a key of a parent
# domain is treated by recipients as a third-party key, which
# may 'hold less merit' in their eyes. If one has a choice,
# it is better to publish a key for each domain (e.g. host1.a.cn)
# if mail is really coming from it. Sharing a pem file
# for multiple domains may be acceptable, so you don't need
# to generate a different key for each subdomain, but you
# do need to publish it in each subdomain. It is probably
# easier to avoid sending addresses like host1.a.cn and
# always use a parent domain (a.cn) in 'From:', thus
# avoiding the issue altogether.
#dkim_key("host1.transardo.com.br", "dkim", "/var/lib/dkim/transardo.com.br.pem");
#dkim_key("host3.transardo.com.br", "dkim", "/var/lib/dkim/transardo.com.br.pem");

# Add new dkim_key for other domain.
#dkim_key('Your_New_Domain_Name', 'dkim', 'Your_New_Pem_File');

@dkim_signature_options_bysender_maps = ( {
    # ------------------------------------
    # For domain: transardo.com.br.
    # ------------------------------------
    # 'd' defaults to a domain of an author/sender address,
    # 's' defaults to whatever selector is offered by a matching key 

    'postmaster@transardo.com.br'    => { d => "transardo.com.br", a => 'rsa-sha256', ttl =>  7*24*3600 },
    #"spam-reporter@transardo.com.br"    => { d => "transardo.com.br", a => 'rsa-sha256', ttl =>  7*24*3600 },

    # explicit 'd' forces a third-party signature on foreign (hosted) domains
    "transardo.com.br"  => { d => "transardo.com.br", a => 'rsa-sha256', ttl => 10*24*3600 },
    #"host1.transardo.com.br"  => { d => "host1.transardo.com.br", a => 'rsa-sha256', ttl => 10*24*3600 },
    #"host2.transardo.com.br"  => { d => "host2.transardo.com.br", a => 'rsa-sha256', ttl => 10*24*3600 },
    # ---- End domain: transardo.com.br ----

    # catchall defaults
    '.' => { a => 'rsa-sha256', c => 'relaxed/simple', ttl => 30*24*3600 },
} );
$enable_dkim_verification = 1;  # enable DKIM signatures verification
$enable_dkim_signing = 1;    # load DKIM signing code, keys defined by dkim_key
# ------------ Disclaimer Setting ---------------
# Uncomment this line to enable singing disclaimer in outgoing mails.
$defang_maps_by_ccat{+CC_CATCHALL} = [ 'disclaimer' ];

# Program used to signing disclaimer in outgoing mails.
$altermime = '/usr/bin/altermime';

# Disclaimer in plain text formart.
@altermime_args_disclaimer = qw(--disclaimer=/etc/postfix/disclaimer/_OPTION_.txt);

@disclaimer_options_bysender_maps = ({
    # Per-domain disclaimer setting: /etc/postfix/disclaimer/host1.iredmail.org.txt
    #'host1.iredmail.org' => 'host1.iredmail.org',

    # Sub-domain disclaimer setting: /etc/postfix/disclaimer/iredmail.org.txt
    #'.iredmail.org'      => 'iredmail.org',

    # Per-user disclaimer setting: /etc/postfix/disclaimer/boss.iredmail.org.txt
    #'boss@iredmail.org'  => 'boss.iredmail.org',

    # Catch-all disclaimer setting: /etc/postfix/disclaimer/default.txt
    '.' => 'default',
},);
# ------------ End Disclaimer Setting ---------------

1;  # insure a defined return

/etc/amavis/conf.d/override.conf

$banned_filename_re = new_RE(
    [qr'(\.xlsx|\.docx|\.pptx)$' => 0],
);

If someone can help me ...
tks

----

Spider Email Archiver: On-Premises, lightweight email archiving software developed by iRedMail team. Supports Amazon S3 compatible storage and custom branding.

2

Re: docx,xlsx,pptx attachments block error

- Is '$banned_filename_re' also defined in other Amavisd config files (/etc/amavis/conf.d/*)?
- Why not simply add your '$banned_filename_re' in /etc/amavis/conf.d/50-user? Are you sure Amavisd on Debian 5 will read /etc/amavis/conf.d/override.conf?

3

Re: docx,xlsx,pptx attachments block error

I look the other files, only in 50-user have  a banned_filename_r

$banned_filename_re = new_RE(
    qr'.\.(bat|exe|scr|bin|com|cmd|avi|divx|xvid|mpg|mpeg|mp3|mp4|ogg|mid|midi|wav|wmv)$'i,
    qr'^\.(exe)$'i,
    );

but i don't like block the MsOffice files, but accept  this files.

4

Re: docx,xlsx,pptx attachments block error

Did you try to add '[qr'(\.xlsx|\.docx|\.pptx)$' => 0],' in '$banned_filename_re' in 50-user?

5

Re: docx,xlsx,pptx attachments block error

ZhangHuangbin wrote:

Did you try to add '[qr'(\.xlsx|\.docx|\.pptx)$' => 0],' in '$banned_filename_re' in 50-user?

But, if do that, I don't will block MsOffice files?

I need accept this files

6

Re: docx,xlsx,pptx attachments block error

'=> 0' means allow these files.

If you don't want to block them, please try these settings in a testing machine first, e.g. a VMware/Xen/Virtualbox machine.

7

Re: docx,xlsx,pptx attachments block error

ZhangHuangbin wrote:

'=> 0' means allow these files.

If you don't want to block them, please try these settings in a testing machine first, e.g. a VMware/Xen/Virtualbox machine.


I Will change the 50-users to

$banned_filename_re = new_RE(
    qr'.\.(bat|exe|scr|bin|com|cmd|avi|divx|xvid|mpg|mpeg|mp3|mp4|ogg|mid|midi|wav|wmv)$'i,
    qr'^\.(exe)$'i,
    [qr'(\.xlsx|\.docx|\.pptx|\.ppsx)$' => 0],
    );

and test......

8 (edited by RafaelMass 2012-03-23 01:04:57)

Re: docx,xlsx,pptx attachments block error

Doesn't work

Reporting-MTA: dns; www.MYSITE.com.br
X-iRedMail-Queue-ID: 92AF9332282
X-iRedMail-Sender: rfc822; soriane@live.com
Arrival-Date: Thu, 22 Mar 2012 13:53:14 -0300 (BRT)

Final-Recipient: rfc822; cpd@MYSITE.com.br
Original-Recipient: rfc822;cpd@MYSITE.com.br
Action: failed
Status: 5.7.0
Remote-MTA: dns; 127.0.0.1
Diagnostic-Code: smtp; 554 5.7.0 Reject, id=04357-06 - BANNED: multipart/mixed
    |
    application/vnd.openxmlformats-officedocument.presentationml.presentation,...

9

Re: docx,xlsx,pptx attachments block error

Below setting works for me, tested with Debian 6 (x86_64), Amavisd-new-2.6.4.

With setting:

$banned_filename_re = new_RE(
    [qr'.\.(doc|chm)$'i => 1],    # <-- '1': block
);

Microsoft Word document is blocked:

Mar 22 21:38:36 d6 amavis[3207]: (03207-01) Blocked BANNED (application/msword,.dat,Resume.doc), LOCAL [172.16.122.1] [172.16.122.1] <www@a.cn> -> <www@a.cn>, quarantine: Z/banned-ZDMguJ9GTfbp, Message-ID: <4F6BFE4B.1050906@a.cn>, mail_id: ZDMguJ9GTfbp, Hits: -, size: 46807, 311 ms

With setting:

$banned_filename_re = new_RE(
    [qr'.\.(doc|chm)$'i => 0],    # <-- '0': allow
);

File is bypassed:

Mar 22 21:38:19 d6 amavis[3183]: (03183-01) Passed CLEAN, LOCAL [172.16.122.1] [172.16.122.1] <www@a.cn> -> <www@a.cn>, Message-ID: <4F6BFE39.3060409@a.cn>, mail_id: oTjLv8t6V263, Hits: -8.821, size: 46805, queued_as: B81168664, 1515 ms