Installing Postfwd on CentOS/Fedora/Redhat 0
Download and unpack Postfwd archive to /usr/local/postfwd:
cd /usr/local/ wget http://postfwd.org/postfwd-1.10pre7c.tar.gz tar -xf postfwd-1.10pre7c.tar.gz mv postfwd-1.10pre7c postfwd
Copy the configuration file at its place, and copy the startup script to its place
cp /usr/local/postfwd/etc/postfwd.cf /etc/postfix/ cp /usr/local/postfwd/bin/postfwd-script.sh /etc/init.d/postfwd
Then, if I try to set a daemon to be startet at boot time, with:
chkconfig --add postfwd
But I got an error saying: “service postfwd does not support chkconfig”? Ok. There is a statement in a init script that tells the chkconfig command how to add or delete this daemon to the boot process. This statement looks like this:
# chkconfig: 2345 78 32 # description: Postfwd Policy Server
This means that a script should be started in levels 2,3,4,5 and that its start priority should be 78, and stop pririty 32. Priorities present the order / sequence in which the services are either started and stopped. So if you for instance have Postfix starting and a postfwd application, it is essential that the postfwd is started before Postfix. Having Postfix start value of 80 you need a lower value for the Postfwd (78 for example).
After we added this line to /etc/init.d/postfwd file, lets repeat:
chkconfig –add postfwd
Ok. This worked. But, I had a lot of problems in a supplied default init script of policyfwd. I had to change a startup script a lot. After faunding out that init script is somehow strange, I had to rewrite a script based on postgrey’s init script. Here it is ready to download. So copy this one to /etc/init.d.
Now, start it with:
service postfwd start
It should work. Now to make Postfix aware of it. Open your postfix /etc/postfix/main.cf and insert or edit the following.
127.0.0.1:10040_time_limit = 3600 smtpd_recipient_restrictions = ... ... check_policy_service inet:127.0.0.1:10040, permit smtpd_end_of_data_restrictions = check_policy_service inet:127.0.0.1:10040
The last one is needed because you have to call postfwd at end_of_data state for reliable size checks.
Testing it up
If you want to list the rules, just type:
/usr/local/postfwd/sbin/postfwd -f /etc/postfix/postfwd.cf -C
Finally, if you are satisfied, start postfwd and reload postfix. Then, monitor the log file for lines mentioning postfwd with:
tail -f /var/log/maillog | grep postfwd
There is an example policy request distributed with postfwd, called ‘request.sample’. Simply change it to meet your requirements:
nano /usr/local/postfwd/tools/request.sample /usr/local/postfwd/sbin/postfwd -f /etc/postfix/postfwd.cf </usr/local/postfwd/tools/request.sample
Thats it.
No - it is not!
Really a bug not counted as one
I spent at least an hour just to find out the bug. No! It is not a bug. I just need to read very, very carefully:
From the Doc’s: “Multiple use of the same item is allowed and will compared as logical OR ”
So macro with this content:
&&LIMITEDS { sender=.*@onedomain.com ; sender~=user@seconddomain.com; };
will work, and the following one will not (only first rule will be accounted):
&&LIMITEDS { sender_domain=onedomain.com ; sender~=user@seconddomain.com; };