upgrading sendmail to berkeley db 4 on openbsd for snert milters
I’m very much a fan of blocking spam as early in the transaction as possible. To this end I use a variety of sendmail tweaks, milters, greylisting etc to keep spam from even being accepted. Recently I ran into the problem that my favorite set of milters required Berkeley DB4 to work… though OpenBSD ships with Berkeley DB1 installed and Sendmail compiles to use DB1 as well. Here’s my adventure through installing DB4, recompiling sendmail to use it, and then reinstalling the milters. Here’s the text file to make using the scripts easier. Good luck.
## install bdb4 from ports ##
cd /usr/ports/databases/db/v4/ && make install
## recompile sendmail to use bdb4 (berkeley db 4) ##
vi /root/downloads/sendmail-8.13.6/devtools/Site/site.config.m4
dnl
#########################################################
APPENDDEF(`confMAPDEF’, `-DFAST_PID_RECYCLE’)dnl
APPENDDEF(`confMAPDEF’, `-D_FFR_USE_SETLOGIN’)dnl
APPENDDEF(`confMAPDEF’, `-DMILTER’)dnl
APPENDDEF(`confMAPDEF’, `-DNEWDB’)dnl
APPENDDEF(`confLIBDIRS’, `-L/usr/local/lib/db4 -R/usr/local/lib’)dnl
APPENDDEF(`confINCDIRS’, `-I/usr/local/include/db4′)dnl
#########################################################
cd /root/downloads/sendmail-8.13.6 && rm obj.OpenBSD.*
sh Build && sh Build install
## build the snert milters ##
cd /root/downloads/snert && for i in *.tar.gz ;do tar zxvf ${i} ;done
cd /root/downloads/snert/com/snert/src/lib &&
make clean
cd /root/downloads/snert/com/snert/src/lib &&
./configure –with-db=/usr/local && make && make build && make install
cd /root/downloads/snert/com/snert/src/milter-gris && \
sed -e s/450/451/g < milter-gris.c > milter-gris.451.c && \
mv milter-gris.451.c milter-gris.c
cd /root/downloads/snert/com/snert/src/milter-limit && \
sed -e s/450/451/g < milter-limit.c > milter-limit.451.c && \
mv milter-limit.451.c milter-limit.c
function pimp {
cd /root/downloads/snert/com/snert/src/milter-${1} &&
make clean
cd /root/downloads/snert/com/snert/src/milter-${1} &&
./configure –enable-run-user=_vilter –enable-run-group=_vilter
–enable-pid=/var/ram/milter-${1}.pid
–enable-cache-type=bdb –enable-socket=/var/ram/milter-${1}.sock
–enable-cache-file=/var/ram/milter-${1}.cache &&
make && make build && make install
}
pimp limit
pimp gris
pimp error
pimp date
## put the proper settings in your mc file, note that order here is important ##
INPUT_MAIL_FILTER(`milter-gris’,`S=unix:/var/ram/milter-gris.sock, T=C:1m;S:30s;R:30s;E:1m’)dnl
INPUT_MAIL_FILTER(`milter-limit’,`S=unix:/var/ram/milter-limit.sock, T=C:1m;S:30s;R:30s;E:1m’)dnl
INPUT_MAIL_FILTER(`milter-date’,`S=unix:/var/ram/milter-date.sock, T=C:1m;S:30s;R:30s;E:1m’)dnl
INPUT_MAIL_FILTER(`milter-error’,`S=unix:/var/ram/milter-error.sock, T=C:1m;S:30s;R:30s;E:1m’)dnl
INPUT_MAIL_FILTER(`smtp-vilter’,`S=unix:/var/smtp-vilter/smtp-vilter.sock, T=C:1m;S:30s;R:30s;E:1m’)dnl
## rebuild the sendmail databases with the new makemap ##
cd /etc/mail/ && newaliases
for i in access genericstable mailertable virtusertable ;do makemap hash $i < $i ;done
m4 /usr/src/gnu/usr.sbin/sendmail/cf/m4/cf.m4 /etc/mail/openbsd-proto-skip.mc > /etc/mail/sendmail.cf
if [[ `ps aux|grep -vi grep |grep -i sendmail` ]]
then kill `head -1 /var/run/sendmail.pid`
else echo “no sendmail found to kill”
fi
rm /etc/mail/helpfile 1>/dev/null 2>/dev/null
touch /etc/mail/helpfile 1>/dev/null 2>/dev/null
/usr/sbin/sendmail -L sm-mta -bd -q15m
## start the milters ##
/usr/local/libexec/milter-limit -f /etc/mail/sendmail.cf -n -t 60 -z bdb,/var/ram/milter-limit.cache -H /var/ram/milter-limit.sock
/usr/local/libexec/milter-date -A 90000 -r -f /etc/mail/sendmail.cf /var/ram/milter-date.sock
/usr/local/libexec/milter-gris -b 300 -C 1209600 -f /etc/mail/sendmail.cf -H -g 100 -I 120 -k ip,helo,mail,rcpt -n -r 75 -t 60 -z bdb,/var/ram/milter-gris.cache /var/ram/milter-gris.sock
/usr/local/libexec/milter-error -a tag -c 600 -e 12 -f /etc/mail/sendmail.cf -H -v all -z bdb,/var/ram/milter-error.cache /var/ram/milter-error.sock
## done ##