Since I had many problems to create this, I would like to share my 6 hours of agony-ectsasy in order to make amavis use clamd as antivirus.
Assuming you have installed clamd and amavis:
Open /etc/clamd.conf
Comment Out the lines
Code:
#TCPAddr 127.0.0.1
#TCPSocket 3310
Enable LocalSocket /var/run/clamav/clamd.sock
My configuration is
Code:
LogFile /var/log/clamav/clamd.log
LogFileMaxSize 0
LogTime
PidFile /var/run/clamav/clamd.pid
TemporaryDirectory /var/tmp
DatabaseDirectory /var/clamav
LocalSocket /var/run/clamav/clamd.sock
FixStaleSocket
MaxConnectionQueueLength 30
ReadTimeout 180
SelfCheck 3600
User amavis
AllowSupplementaryGroups
ScanPE
DetectBrokenExecutables
ScanOLE2
ScanMail
ScanHTML
ScanArchive
ArchiveMaxFileSize 10M
ArchiveMaxRecursion 5
ArchiveMaxFiles 1000
ArchiveMaxCompressionRatio 300
ArchiveBlockEncrypted
ArchiveBlockMax
Note

ou have to change anyway the User from clamav to amavis
Open /etc/freshclam.conf
My configuration is
Code:
UpdateLogFile /var/log/clamav/freshclam.log
DatabaseDirectory /var/clamav
PidFile /var/run/clamav/freshclam.pid
DatabaseOwner amavis
DNSDatabaseInfo current.cvd.clamav.net
DatabaseMirror db.gr.clamav.net
MaxAttempts 5
NotifyClamd
DatabaseMirror db.local.clamav.net
Note

ou have to change anyway the DatabaseOwner from clamav to amavis
Go to Users and Groups
Find Clamav user and add him to amavis Group. amavis sould be the primary group for clamav.
You can do that with command line as well
Open /etc/amavis.conf
Go to ClaMav section
replace /var/run/clamav/clamd with /var/run/clamav/clamd.sock
OR whatever value is on LocalSocket in clamd.conf
Now pay attention to this:
In our case we have 2 directories used for clamav one is
/var/clamav for the database and /var/log/clamav for logs
then you must do a
chown -R amavis:amavis /var/clamav
chown -R amavis:amavis /var/log/clamav
Amavis needs to be the owner in order to work properly
And the last thing
Open /etc/logrotate.d/clamav
you see something like
Code:
/var/log/clamav/clamav.log {
create 644 clamav clamav
}
change the first clamav to amavis
Open /etc/logrotate.d/freshclam.log
you see something like
Code:
/var/log/clamav/freshclam.log {
create 644 clamav clamav
}
change the first clamav to amavis
Now do a
/sbin/service clamd restart
/sbin/service amavisd restart
Test the setup
My Mail Server is postfix
Everything should be working
The only thing I am not sure of is whether clamd does antivirus update or not
because freshclam can't write to log file because of the permissions.
Any input is very welcomed!
Cheers