Wazir,

> Has anyone configured amavisd to use the banned_rulenames field in
> mysql?  I need a set of instructions on how to make this work.  The
> documentation talks about rules and stuff, but I can't figure it out.
> If anyone has some examples, I would greatly appreciated it.  TIA

amavisd.conf-sample gives a small example:

%banned_rules = (
  'MYNETS-DEFAULT' => new_RE(   # permissive set of rules for internal hosts
    [ qr'^\.(rpm|cpio|tar)$' => 0 ],  # allow any name/type in Unix archives
    qr'.\.(vbs|pif|scr)$'i,     # banned extension - rudimentary
  ),
  'DEFAULT' => $banned_filename_re,
);

Here is a larger example:

%banned_rules = (
  'NO-MS-EXEC'=> new_RE( qr'^\.(exe-ms)$' ),
  'PASSALL'   => new_RE( [qr'^' => 0] ),
  'ALLOW_EXE' =>  # pass executables except if name ends in .vbs .pif .scr .bat
    new_RE( qr'.\.(vbs|pif|scr|bat)$'i, [qr'^\.exe$' => 0] ),
  'ALLOW_VBS' =>  # allow names ending in .vbs
    new_RE( [qr'.\.vbs$' => 0] ),
  'NO-VIDEO' => new_RE( qr'^\.movie$',
    qr'.\.(asf|asx|mpg|mpe|mpeg|avi|mp3|wav|wma|wmf|wmv|mov|vob)$'i, ),
  'NO-MOVIES' => new_RE( qr'^\.movie$', qr'.\.(mpg|avi|mov)$'i, ),
  'MYNETS-DEFAULT' => new_RE(
    [ qr'^\.(rpm|cpio|tar)$' => 0 ],  # allow any in Unix-type archives
    qr'.\.(vbs|pif|scr)$'i,           # banned extension - rudimentary
    qr'.\.(exe|vbs|pif|scr|bat|cmd|com|cpl)$'i, # banned extension - basic
    qr'^\.(exe-ms)$',                 # banned file(1) types
  ),
  'DEFAULT' => $banned_filename_re,
);

The %banned_rules makes possible to have more than one banned_filename
lookup table, and gives names (hash keys) to each. These names may
be used in @banned_filename_maps or in a SQL field policy.banned_rulenames.

Here is a default setting:

%banned_rules = ('DEFAULT' => $banned_filename_re);
@banned_filename_maps = ( {'.' => 'DEFAULT'} );


A more complex example:

@banned_filename_maps = (
  { '[EMAIL PROTECTED]' => 'NO-MS-EXEC,PASSALL',
    '[EMAIL PROTECTED]' => 'ALLOW_EXE',
    '.subdomain.example.com' => 'ALLOW_VBS',
    '[EMAIL PROTECTED]' => 'ALLOW_VBS,ALLOW_EXE',
    '.' => 'DEFAULT',
  },
);

and another one, some rules are given directly, some by names:

@banned_filename_maps = (
  { '[EMAIL PROTECTED]' => 'NO-MS-EXEC,PASSALL',
    '[EMAIL PROTECTED]' =>
      [ new_RE( qr'.\.(vbs|pif|scr|bat)$'i, [qr'^\.exe$' => 0] ) ],
    '[EMAIL PROTECTED]'  =>
      [ new_RE( [qr'.\.vbs$' => 0] ) ],
    '.' => [ $banned_filename_re ],
  },
);

The policy.banned_rulenames field may contain a string
such as 'NO-MS-EXEC,PASSALL', with same semantics as
when directly given in the rhs of the @banned_filename_maps
lookup tables.

Here is a text from RELEASE_NOTES:

- banned filename/filetype rules can now be specified on a per-recipient basis

  Structure of @banned_filename_maps config variable has changed in
  incompatible way to allow per-recipient banned rules: it is now a
  two level map, similar to the structure of @score_sender_maps.

  Lookup keys used at the first level are recipient addresses, results from
  this lookup can be either a ref to a list of second-level lookup tables, or
  a string which is interpreted as a comma-separated (or whitespace-separated)
  list of _names_ of second-level lookup tables. These names are mapped to
  actual second-level lookup tables through an associative array %banned_rules.
  The indirection by names through %banned_rules is primarily intended for
  SQL and LDAP lookups, which can not return complex data structures and
  Perl code (and should not do so for security reasons), but names may just
  as well be used by static lookups.

  The resulting list of second-level lookup tables (which in most cases is
  a list containing a single element $banned_filename_re, which makes it
  compatible with existing setups) is looked up by using keys such as part
  file name and part file type, exactly like in previous versions.

  The previous default assignment:
    @banned_filename_maps = ( \$banned_filename_re );
  is now incorrect, it can be rewritten (if explicit assignment is desired) as:
    @banned_filename_maps = ( {'.' => [$banned_filename_re]} );
  or (by giving a name to a lookup table):
    @banned_filename_maps = ( {'.' => 'MYRULES'} );
    %banned_rules = ('MYRULES' => $banned_filename_re);
  which is equivalent to the default setting of both variables:
    @banned_filename_maps = ( {'.' => 'DEFAULT'} ); # proper two-level struct.
    @banned_filename_maps = ( 'DEFAULT' );     # same as previous, but shorter
    %banned_rules = ('DEFAULT' => $banned_filename_re);

  The SQL table 'policy' may now contain an optional field 'banned_rulenames',
  which is a comma-separated (or whitespace-separated) list of _names_ of
  second-level lookup tables, with semantics as described above for static
  lookups.

  The configuration variable @banned_filename_maps is a member of policy banks
  as before. The associative array %banned_rules is global and is not a member
  of policy banks.

  The alternative 'banned file' mechanism $banned_namepath_re hasn't changed
  and is still not merged into @banned_filename_maps, which means it can not
  be used when per-recipient banned rules are needed.


Mark

-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
AMaViS-user mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/amavis-user
AMaViS-FAQ:http://www.amavis.org/amavis-faq.php3
AMaViS-HowTos:http://www.amavis.org/howto/

Reply via email to