NAME
Mail::MtPolicyd::Plugin::SqlList - mtpolicyd plugin for accessing a SQL white/black/access list
VERSION
version 2.05
SYNOPSIS
<Plugin whitelist>
module="SqlList"
sql_query="SELECT client_ip FROM whitelist WHERE client_ip=?"
match_action=dunno
</Plugin>
<Plugin blacklist>
module="SqlList"
sql_query="SELECT client_ip FROM blacklist WHERE client_ip=?"
match_action="reject you are blacklisted!"
</Plugin>
DESCRIPTION
Plugin checks a field against a SQL table/query.
Depending on whether a supplied SQL query matched actions can be taken.
PARAMETERS
The module takes the following parameters:
- (uc_)enabled (default: "on")
-
Could be set to 'off' to deactivate check. Could be used to activate/deactivate check per user.
- sql_query (default: "SELECT client_ip FROM whitelist WHERE client_ip=INET_ATON(?)")
-
Prepared SQL statement to use for checking an IP address.
? will be replaced by the IP address.
The module will match if the statement returns one or more rows.
By default the plugin will do nothing. One of the following actions should be specified:
- match_action (default: empty)
-
If given this action will be returned to the MTA if the SQL query matched.
- not_match_action (default: empty)
-
If given this action will be returned to the MTA if the SQL query DID NOT matched.
- score (default: empty)
-
If given this score will be applied to the session.
- field (default: client_address)
-
The field the query parameter will be taken from.
EXAMPLE WITH A MYSQL TABLE
You may use the following table for storing IPv4 addresses in MySQL:
CREATE TABLE `whitelist` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`client_ip` INT UNSIGNED NOT NULL,
PRIMARY KEY (`id`),
UNIQUE KEY `client_ip` (`client_ip`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1
INSERT INTO whitelist VALUES(NULL, INET_ATON('127.0.0.1'));
And use it as a whitelist in mtpolicyd:
<VirtualHost 12345>
name="reputation"
<Plugin whitelist>
module="SqlList"
sql_query="SELECT client_ip FROM whitelist WHERE client_ip=INET_ATON(?)"
match_action="dunno"
</Plugin>
<Plugin trigger-greylisting>
...
</VirtualHost>
AUTHOR
Markus Benning <ich@markusbenning.de>
COPYRIGHT AND LICENSE
This software is Copyright (c) 2014 by Markus Benning <ich@markusbenning.de>.
This is free software, licensed under:
The GNU General Public License, Version 2, June 1991