Setup clamav with Postfix on Debian Lenny in a chroot

From Andywiki
Jump to: navigation, search

Quick and dirty instructions on setting up Postfix to scan messages using clamav on Debian Lenny.

Install clamav and clamav-milter:

apt-get install clamav
apt-get install clamav-daemon
apt-get install clamav-milter

Edit /etc/default/clamav-milter and uncomment the following lines

USE_POSTFIX='yes'
SOCKET=local:/var/spool/postfix/clamav/clamav-milter.ctl

If you don't want the postmaster and sender to be emailed each time a virus is detected then add the letter q to the OPTIONS line at the beginning of the file as such:

OPTIONS="--max-children=2 -olq"

Create somewhere within the Postfix chroot for the clamav-milter socket to sit. The default location cannot be seen by Postfix when it is in a chroot jail.

mkdir -p /var/spool/postfix/clamav/
chown clamav:postfix /var/spool/postfix/clamav/
chmod g+s /var/spool/postfix/clamav/

Restart the milter:

/etc/init.d/clamav-milter restart

Add the following lines to /etc/postfix/main.cf to enable the milter (assumes you want to accept emails on milter failure):

milter_connect_macros = i b j _ {daemon_name} {if_name} {if_addr}
smtpd_milters = unix:/clamav/clamav-milter.ctl
milter_default_action = accept

Restart Postfix:

/etc/init.d/postfix restart