Dang. I forgot to append a dummy column to the textfile. Corrected
version is below.
Also added a note that "mv newdatabse realdatabase" is not needed
with cdb and lmdb.
Wietse
Mark Goodge:
> What would be the simplest method in Postfix of implementing an
> equivalent to the exim ACL mentioned in this blog post:
>
> http://blog.hinterlands.org/2013/10/unwanted-email-from-communicado-ltd/
>
> That is, what's the simplest way of rejecting email from a list of
> domains contained within a simple text file that can be updated
> regularly without needing to restart Postfix.
No need to restart Postfix. Use an indexed file and let smtpd(8)
auto-detect that the file has changed.
Run this from cron:
#!/bin/sh
# Configure smtpd(8) to query $TYPE:real-file
TYPE=hash
SUFF=db
URL=http://example.com/file.txt
test -f old-file || touch old-file
wget -O new-file $URL && test -s new-file &&
perl -pi -e 's/$/ x/' new-file && cmp -s old-file new-file || {
postmap $TYPE:new-file && mv new-file.$SUFF real-file.$SUFF
mv new-file old-file
}
In particular, LMDB as of postfix-2.11-20131122 no longer restarts
a daemon and picks up changes immediately. With cdb and hash, the
changes are detected at the start of a new SMTP session and then
smtpd(8) restarts.
The "mv new-file.$SUFF real-file.$SUFF" step is not needed with cdb
or lmdb databases (cdb already renames the result file, and lmdb
uses copy-on-write internally, which for pratical purposes works
like rename).
Wietse