Patch for ClamAV updates

Peter Bonivart bonivart at opencsw.org
Wed Mar 2 10:34:39 GMT 2011


I noticed that MailScanner always logged an update for ClamAV. I think
the Clam team have changed the exit codes since the script was written
and they now use 0 for a successful update regardless if an actual
update occured or not. This can be manipulated when calling freshclam,
my patch below exits with 1 if an update occured and 0 if was already
up to date, still exiting with higher codes for problems.

Now I get the expected logs:

Mar  1 21:45:08 localhost ClamAV-autoupdate[13564]: ClamAV did not need updating
Mar  1 22:23:40 localhost ClamAV-autoupdate[15759]: ClamAV did not need updating
Mar  1 22:54:44 localhost ClamAV-autoupdate[17316]: ClamAV updated
Mar  1 23:24:39 localhost ClamAV-autoupdate[18822]: ClamAV did not need updating
Mar  1 23:49:44 localhost ClamAV-autoupdate[19911]: ClamAV did not need updating

/peter

--- clamav-autoupdate.110301    Tue Mar  1 16:43:49 2011
+++ clamav-autoupdate   Tue Mar  1 16:44:35 2011
@@ -35,7 +35,7 @@
   eval {
     alarm 300;
     unlink $LogFile;
-    $Command = "$ClamUpdateCommand --quiet -l $LogFile";
+    $Command = "$ClamUpdateCommand --on-update-execute=EXIT_1 --quiet
-l $LogFile";
     $Command .= " --http-proxy $HTTPproxy" if $HTTPproxy;
     $retval = &UpdateClam($Command); # system($Command)>>8;
     &UnlockClamAV();
@@ -51,9 +51,9 @@
     }
   } else {
     alarm 0;
-    if ($retval == 0 ) {
+    if ($retval == 1 ) {
       Sys::Syslog::syslog('info', "ClamAV updated");
-    } elsif ($retval == 1 ) {
+    } elsif ($retval == 0 ) {
       Sys::Syslog::syslog('info', "ClamAV did not need updating");
     } else {
       Sys::Syslog::syslog('err', "ClamAV updater failed");


More information about the MailScanner mailing list