bitdefender-autoupdate improvements

Achim J. Latz achim+mailscanner at qustodium.net
Mon Oct 27 22:15:56 GMT 2008


Good evening:

The bitdefender-autoupdate script seems to cause quite a bit of load
when run in its current version.

I checked the code, and it appears that the signature updates are
downloaded, compared with the current signatures, and then some
statistics are printed out. HOWEVER, the comparison seems rather
inefficient as it requires a lot of CPU and I/O capacity, probably
because the signature files have grown rapidly since this script was
last updated on 21/10/2003 [1].

While running the original version, I saw the machine load spike to 4 or
5 for a couple of minutes (AMD64, 1GB RAM) every time
bitdefender-autoupdate was active (basically once every hour).

The (ugly, hacked) updated version is not even noticable on the load --
the resulting unified diff is attached. Perhaps my ugly hack could serve
as a starting point for somebody better versed in Perl to review the
script completely?

As Julian already states in his comments for that particular file:

# Note from Jules: This looks awfully complicated, but it is because the
# old version of the --update flag didn't work in bdc.
# This code detects what version of bdc you are running
# and uses the appropriate code for each version.
#
# YOU DON'T HAVE TO TWEAK IT!!! Please don't modify this file.

Naturally, I do not agree with the last line (-:

Best regards,

		Achim

[1] "At the start of 2007, computer security firm F-Secure had about
250,000 malware signatures in its database, the result of almost 20
years of antivirus research. Now, near the end of 2007, the company has
about 500,000 malware signatures." Source:
<http://www.informationweek.com/news/mobility/showArticle.jhtml?articleID=204701370>
-------------- next part --------------
--- bitdefender-autoupdate.orig	2008-08-14 14:03:30.000000000 +0200
+++ bitdefender-autoupdate	2008-10-04 10:03:10.000000000 +0200
@@ -144,7 +144,8 @@
 $sendmailPath = "/usr/sbin/sendmail";                         # full sendmail path
 ######## LOGFILE SIZE LIMIT ##############
 $logFileLimit = 5120;                                         # logfile limit size in bytes - 0 = no limit - 5120 = 5 kb
-#JKF This is now calculated $useBDCUpdate = 0;                # select the method to use for updating
+#JKF This is now calculated 
+#$useBDCUpdate = 1;                # select the method to use for updating
                                                                         # 1 = user bdc --update method,
                                                                         # 0 = download file, unzip and test it
 #######################################################################
@@ -182,21 +183,23 @@
 # JKF Set $useBDCUpdate according to which version is installed
 if (-e $bitDefenderPath . "shared/$bitDefBinary") {
   # JKF Old version. --update is broken and bdc is in "shared" directory
+  &updateLog("Old version. --update is broken and bdc is in shared directory");
   $useBDCUpdate = 0;
   $bdcBinary = $bitDefenderPath . "shared/$bitDefBinary";
 }
 if (-e "$bitDefenderPath$bitDefBinary") {
   # JKF New version. --update works and bdc is in main package directory
+  &updateLog("New version. --update works and bdc is in main package directory");
   $useBDCUpdate = 1;
   $bdcBinary = $bitDefenderPath . $bitDefBinary;
 }
 
 # calcolo il numero di virus su cui siamo inizialmente protetti e restituisco il numero direttamente nel log
-my $bitDCmd = $bdcBinary . " --vlist";
-my $origFile = $bitDefenderPath  .  $beforeFile;
-system  "$bitDCmd > $origFile ";
+#my $bitDCmd = $bdcBinary . " --vlist";
+#my $origFile = $bitDefenderPath  .  $beforeFile;
+#system  "$bitDCmd > $origFile ";
 
-&countViruses($origFile);
+#&countViruses($origFile);
 
 if ( $useBDCUpdate == 1)
 {
@@ -280,26 +283,26 @@
 my $destFile = $bitDefenderPath  .  $afterFile;
 
 # calcolo il numero di virus su cui siamo protetti e restituisco il numero direttamente nel log
-system  "$bitDCmd > $destFile ";
+# system  "$bitDCmd > $destFile ";
 
-&updateLog ("Following the changes:");
+# &updateLog ("Following the changes:");
 
-COMPARE:
-my $newsFile = $bitDefenderPath . "news.txt";
+#COMPARE:
+#my $newsFile = $bitDefenderPath . "news.txt";
 
-$afterFile  = $bitDefenderPath . $afterFile;
-$beforeFile = $bitDefenderPath . $beforeFile;
+#$afterFile  = $bitDefenderPath . $afterFile;
+#$beforeFile = $bitDefenderPath . $beforeFile;
 
-system  "diff $beforeFile $afterFile > $newsFile";
+#system  "diff $beforeFile $afterFile > $newsFile";
 
 # include bdc report fr reporting families
-my $bitDCmd = $bdcBinary . " --info";
-system  "$bitDCmd >> $newsFile ";
+#my $bitDCmd = $bdcBinary . " --info";
+#system  "$bitDCmd >> $newsFile ";
 
 # get the file and print it in the log...
-my $fh = new IO::File  "< $newsFile" || &updateLog( "no news file found!");
-my @lines = $fh->getlines;
-$fh->close;
+#my $fh = new IO::File  "< $newsFile" || &updateLog( "no news file found!");
+#my @lines = $fh->getlines;
+#$fh->close;
 
 
 my $lines = @lines;
@@ -323,7 +326,7 @@
  $useSMTP = 0;                               # avoid mail
 }
 
-&countViruses($destFile);
+#&countViruses($destFile);
 if ( $useBDCUpdate == 0 )
 {
 	&determineRotation (1);                   # update rotation status


More information about the MailScanner mailing list