1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195
|
gld for Debian
==============
gld stands for GreyList Daemon.
gld is a standalone policy delegation server for postfix that implements the
greylist algorithm as defined at
http://www.greylisting.org
It's written in C and uses MySQL for the database stuff.
Requirements:
------------
postfix >= 2.1
mysql-server
It is possible to have postfix, mysql-server and this daemon all
running on different machines, so this package does not have a Depends
on postfix or mysql-server (only a Suggests). For simplicity, this
document assumes they are all on the same machine.
Configuration:
-------------
* Make sure mysql-server starts on boot. Otherwise gld will not start,
and postfix will not receive any mail. In doubt:
dpkg-reconfigure mysql-server-5.5
* Make sure mysql-server has a priority of 18 or lower in the boot scripts.
The default is 20, which is the same as postfix. gld has 19, so
you will have to lower the priority of mysql-server to 18 at least:
update-rc.d -f mysql remove
update-rc.d mysql defaults 18
Note: The priority-based boot process in wheezy should make this
step not required at all.
* Choose a user, a password and a database name and put them in the
/etc/gld.conf file at the very end.
* Create the database with the chosen name, then create a user
to access the database and give it the password in the previous step.
Assuming that you only changed the password in /etc/gld.conf, you
can easily do this from a mysql shell by doing this:
CREATE DATABASE gld;
GRANT ALL PRIVILEGES ON gld.* TO gld@localhost IDENTIFIED BY 'passwordforgld';
USE gld;
source /usr/share/gld/tables.mysql
source /usr/share/gld/table-whitelist.sql
* Edit /etc/default/gld so that it reads:
ENABLED=1
Then gld will start automatically on boot.
* Start gld and see if there are errors:
invoke-rc.d gld start
You should see something like this:
Starting GreyListing Daemon: gld.
* If everything was ok until this point, postfix will be ready to use gld.
Edit /etc/postfix/main.cf and add a line like this:
check_policy_service inet:127.0.0.1:2525
to the smtpd_recipient_restrictions variable, or any other variable
which is appropriate for this. By default, the Debian postfix package
does not define any variable which is suitable for this, so it is
possible that you will have to add the definition yourself (not just
"add" the check_policy_service line). In such case, you may copy the
following example verbatim:
smtpd_recipient_restrictions = reject_unauth_destination,
check_policy_service inet:127.0.0.1:2525
It is very important that you have reject_unauth_destination first.
In doubt, install the postfix-doc package and read the Postfix manual,
for which this README.Debian is not meant to be a replacement.
* After changing /etc/postfix/main.cf, reload postfix:
postfix reload
Database cleanup:
----------------
You might want to perform some cleanup of old entries automatically
using a cron job (so that the database do not become polluted by spammers).
Options -c and -k may help here. For example:
#!/bin/sh
set -e
(
gld -c 90
gld -k 7
) | egrep -v 'Cleaned [[:digit:]]+ entries older than [[:digit:]]+ days'
That would clean all database entries not updated in three months and
entries with only one hit not updated in a week.
Bugs:
----
start-stop-daemon is unable to start or kill gld appropriately.
For this reason /etc/init.d/gld does not use start-stop-daemon.
Help will be appreciated to debug this.
Features:
--------
Some people have reported that postfix sometimes has timeout problems
when talking with the gld daemon, the logs from postfix/smtpd are like
this:
warning: timeout on 127.0.0.1:2525 while reading input attribute name
warning: problem talking to server 127.0.0.1:2525: Connection timed out
This may be fixed by increasing the value of smtpd_policy_service_timeout
in /etc/postfix/main.cf. The default value is 100s, so you might want
to try something like this:
smtpd_policy_service_timeout = 240s
Security warnings:
-----------------
* Make sure you have secured your MySQL installation. I usually do this
just after installing mysql-server:
use mysql;
delete from user where user='';
delete from user where host != 'localhost';
update user set password=PASSWORD('somepassword') where user='root';
flush privileges;
then create a file named $HOME/.my.cnf with mode 600 containing this:
[mysql]
user = root
password = somepassword
* By default, /etc/gld.conf is mode 644, which means every local user
will have access to the gld database. If you don't like this, change
the password and do chmod 640 /etc/gld.conf.
* The default /etc/gld.conf says LOOPBACKONLY=1, which means gld will
only accept connections from localhost. Use LOOPBACKONLY=0 only if you
really need it, i.e. if your greylisting daemon is going to be used by
a Postfix installed in another machine. Make sure the greylisting
daemon may only be accessed by the machine running Postfix.
IPv6
----
In previous releases, the default size for ip field in
/usr/share/gld/tables.mysql was 16 bytes, which is not enough
for IPv6 addresses.
This would be a possible way to convert the database:
invoke-rc.d gld stop
gld-dump > gld.sql
gld-restore < gld.sql
invoke-rc.d gld start
where gld-dump is a script like this:
#!/bin/sh
set -e
eval `grep ^SQL /etc/gld.conf`
mysqldump="mysqldump --add-drop-table --skip-extended-insert --skip-comments"
$mysqldump -h ${SQLHOST} -p ${SQLDB} -u ${SQLUSER} --password=${SQLPASSWD} |\
sed -e 's/`ip` char(16) NOT NULL DEFAULT/`ip` char(45) NOT NULL DEFAULT/'
and gld-restore is a script like this:
#!/bin/sh
set -e
eval `grep ^SQL /etc/gld.conf`
mysql="mysql"
$mysql -h ${SQLHOST} -p ${SQLDB} -u ${SQLUSER} --password=${SQLPASSWD}
|