kzswtv# grep clamd /usr/local/bin/mimedefang.pl
$Features{'Virus:CLAMD'} = ('/usr/local/sbin/clamd' ne '/bin/false' ? '/usr/local/sbin/clamd' : 0);
$ClamdSock = "/var/spool/MIMEDefang/clamd";
# %PROCEDURE: entity_contains_virus_clamd
# clamd_sock (optional) -- clamd socket path
# 1 if entity contains a virus as reported by clamd
# Invokes the clamd daemon (http://www.clamav.net/)
sub entity_contains_virus_clamd ($;$) {
my ($clamd_sock) = $ClamdSock;
$clamd_sock = shift if (@_ > 0);
$clamd_sock = "/var/spool/MIMEDefang/clamd.sock" if (!defined($clamd_sock));
my $sock = IO::Socket::UNIX->new(Peer => $clamd_sock);
$VirusScannerMessages .= "clamd found the $1 virus.\n";
md_syslog('info', "$MsgID: Falling back on clamscan --unzip because of Zip module failure in clamd");
md_syslog('err', "$MsgID: Could not connect to clamd Daemon at $clamd_sock");
# %PROCEDURE: message_contains_virus_clamd
# clamd_sock (optional) -- clamd socket path
# Invokes the clamd daemon (http://www.clamav.net/)
sub message_contains_virus_clamd (;$) {
my ($clamd_sock) = $ClamdSock;
$clamd_sock = shift if (@_ > 0);
$clamd_sock = "/var/spool/MIMEDefang/clamd.sock" if (!defined($clamd_sock));
# PING/PONG test to make sure clamd is alive
$sock = IO::Socket::UNIX->new(Peer => $clamd_sock);
md_syslog('err', "$MsgID: Could not connect to clamd daemon at $clamd_sock");
md_syslog('err', "$MsgID: Timeout writing to clamd daemon at $clamd_sock");
md_syslog('err', "$MsgID: Timeout reading from clamd daemon at $clamd_sock");
md_syslog('err', "$MsgID: clamd is not responding");
$sock = IO::Socket::UNIX->new(Peer => $clamd_sock);
$VirusScannerMessages .= "clamd found the $1 virus.\n";
md_syslog('info', "$MsgID: Falling back on clamscan --unzip because of Zip module failure in clamd");
md_syslog('err', "$MsgID: Could not connect to clamd daemon at $clamd_sock");
push @VirusScannerMessageRoutines, \&message_contains_virus_clamd;
push @VirusScannerEntityRoutines, \&entity_contains_virus_clamd;
kzswtv#