Browse code

bb12451: Alleviate freshclam mirror sync error

Users have reported that freshclam will fail to download daily.cvd to an
empty database directory shortly after a new database is published due
to a mirror synchronization error. This may occur if the CDN serves up
an older version while a newer version has just been published. Clearing
the CDN cache has not eliminated the issue.

This commit allows freshclam to accept a database 1 version older than
advertised by DNS but will still fail if the database is more than one
version out of date.

Micah Snyder authored on 2019/12/24 06:52:14
Showing 1 changed files
... ...
@@ -1080,15 +1080,25 @@ static fc_error_t getcvd(
1080 1080
     }
1081 1081
 
1082 1082
     if (cvd->version < remoteVersion) {
1083
-        logg("^Mirror %s is not synchronized.\n", server);
1084
-        if (cvd->version < remoteVersion - 1) {
1085
-            logg("!Downloaded database version is more than 1 version older than the version advertised in DNS TXT record.\n");
1083
+        if (cvd->version == remoteVersion - 1) {
1084
+            logg("*The %s database downloaded from %s is one version older than advertised in the DNS TXT record.\n",
1085
+                cvdfile,
1086
+                server);
1087
+
1088
+            /*
1089
+             * Tolerate an off-by-one version mismatch.
1090
+             * Chances are the new version was just published and the CDN is still updating.
1091
+             */
1092
+            status = FC_SUCCESS;
1093
+            goto done;
1094
+        }
1095
+        else {
1096
+            logg("!The %s database downloaded from %s is more than one version older than the version advertised in the DNS TXT record.\n",
1097
+                cvdfile,
1098
+                server);
1086 1099
             status = FC_EMIRRORNOTSYNC;
1087 1100
             goto done;
1088 1101
         }
1089
-
1090
-        status = FC_UPTODATE;
1091
-        goto done;
1092 1102
     }
1093 1103
 
1094 1104
     status = FC_SUCCESS;
... ...
@@ -1999,7 +2009,7 @@ fc_error_t updatedb(
1999 1999
         }
2000 2000
     }
2001 2001
 
2002
-/*
2002
+    /*
2003 2003
      * Replace original database with new database.
2004 2004
      */
2005 2005
 #ifdef _WIN32