[imp] Virus scanning: hooks.php code try
Daniel Luttermann
daniel.luttermann at t-online.de
Fri Jan 9 08:37:03 PST 2004
Hello,
I want to scan for spam and viruses in mails they get fetched through
IMP 4.0 CVS/fetchmail.
No I try to extend the hooks.php with a function for av scanning.
Here are my snippet:
// Also, we remove the file ourselves; this hook may be called
// hundreds of times per run depending on how many messages we fetch
$file = Util::getTempFile('Horde', false);
--- Begin modified section ---
// Scan for viruses
$av = popen("/opt/kav/bin/aveclient -p /var/run/aveserver -s $file", 'r');
pclose($av);
// Scan result
$filename = "/var/log/kav/aveserver.log";
$handle = fopen($filename, "r");
$contents = fread($handle, filesize($filename));
fclose ($handle);
if (ereg ("Scan result: $file OK", $contents)) {
$fp = popen("$cmd -u $username > $file", 'w');
fwrite($fp, $message);
pclose($fp);
//debug message
echo "Message OK";
} else {
// debug message
echo "Message not OK";
unlink($file);
exit;
}
--- End modified section ---
// Read the new message from the temporary file
$fp = fopen($file, 'r');
$message = fread($fp, filesize($file));
fclose($fp);
unlink($file);
return $message;
At this time if the message is clean the user will get it.
But my question is how to handle infected messages with IMP/fetchmail.
Further processing should be terminated. I've no bad email for testing
but it is good enough to exit the fetchmail function only with "exit"?
Is there a better possibilty to exit the fetchmail function?
Thanks.
--
Best Regards
Daniel Luttermann
More information about the imp
mailing list