]> git.ipfire.org Git - thirdparty/bacula.git/commitdiff
Adjust malware error codes
authorEric Bollengier <eric@baculasystems.com>
Tue, 22 Nov 2022 15:29:15 +0000 (16:29 +0100)
committerEric Bollengier <eric@baculasystems.com>
Thu, 14 Sep 2023 11:57:00 +0000 (13:57 +0200)
bacula/src/dird/malware.c

index 69fd8f47a936e6b7b20c935aed3a2f9970f59312..328a0e77ffa7e9f2cee5739b63a481ea51577df6 100644 (file)
@@ -72,7 +72,7 @@ static bool load_malware_db(JCR *jcr, BDB *db, int mode, const char *source, con
    fp = fopen(fname, "r");
    if (!fp) {
       berrno be;
-      Mmsg(errmsg, _("[DE0003] Unable to open the Malware Database export %s ERR=%s\n"),
+      Mmsg(errmsg, _("[DE0053] Unable to open the Malware Database export %s ERR=%s\n"),
            fname, be.bstrerror());
       goto bail_out;
    }
@@ -128,7 +128,7 @@ static bool load_malware_db(JCR *jcr, BDB *db, int mode, const char *source, con
             }
             Mmsg(tmp, "INSERT INTO Malware%s (MD5) VALUES %s", type, line.c_str());
             if (!db_sql_query(db, tmp.c_str(), NULL, NULL)) {
-               Mmsg(errmsg, "[DE0008] SQL Error %s\n", db->errmsg);
+               Mmsg(errmsg, "[DE0028] SQL Error %s\n", db->errmsg);
                db_unlock(db);
                goto bail_out;
             }
@@ -141,7 +141,7 @@ static bool load_malware_db(JCR *jcr, BDB *db, int mode, const char *source, con
       if (line.c_str()[0]) {
          Mmsg(tmp, "INSERT INTO Malware%s (MD5) VALUES %s", type, line.c_str());
          if (!db_sql_query(db, tmp.c_str(), NULL, NULL)) {
-            Mmsg(errmsg, "[DE0008] SQL Error %s\n", db->errmsg);
+            Mmsg(errmsg, "[DE0028] SQL Error %s\n", db->errmsg);
             db_unlock(db);
             goto bail_out;
          }
@@ -196,7 +196,7 @@ static int update_malware_db(JCR *jcr, char *update_cmd, POOLMEM **fname, POOLME
       }
    }
    pm_strcpy(fname, "");
-   Mmsg(errmsg, _("[DE0001] Unable to update the Malware Database ret=%d\n"), ret);
+   Mmsg(errmsg, _("[DE051] Unable to update the Malware Database ret=%d\n"), ret);
    return -1;
 }
 
@@ -235,12 +235,12 @@ int check_malware(JCR *jcr, const char *jobids, POOLMEM **errmsg)
    /* We fetch the first checksum for the set of jobs to determine the hash type */   
    Mmsg(q, "SELECT SUM(JobFiles) FROM Job WHERE JobId IN (%s)", jobids);
    if (!db_sql_query(jcr->db, q.c_str(), db_int_handler, &i)) {
-      Mmsg(errmsg, "[DE0008] SQL Error %s\n", jcr->db->errmsg);
+      Mmsg(errmsg, "[DE0028] SQL Error %s\n", jcr->db->errmsg);
       return -1;
    }
    /* We need at least one checksum to determine the hash type */
    if (i == 0) {
-      Mmsg(errmsg, "[DI0002] Nothing to check for JobIds %s [%s]\n", jobids, q.c_str());
+      Mmsg(errmsg, "[DI0052] Nothing to check for JobIds %s [%s]\n", jobids, q.c_str());
       Dmsg1(dbglvl, "%s", *errmsg);
       return 0;
    }
@@ -251,19 +251,19 @@ int check_malware(JCR *jcr, const char *jobids, POOLMEM **errmsg)
         "WHERE Filename <> '' AND MD5 <> '0' AND MD5 <> '' AND JobId IN (%s) LIMIT 1", jobids);
 
    if (!db_sql_query(jcr->db, q.c_str(), db_string_list_handler, &l)) {
-      Mmsg(errmsg, "[DE0008] SQL Error %s\n", jcr->db->errmsg);
+      Mmsg(errmsg, "[DE0028] SQL Error %s\n", jcr->db->errmsg);
       return -1;
    }
 
    /* We need at least one checksum to determine the hash type */
    if (lst.size() != 1) {
-      Mmsg(errmsg, "[DE0005] Unable to find a checksum for JobIds %s. Use Signature = MD5/SHA256 FileSet option\n", jobids);
+      Mmsg(errmsg, "[DE0054] Unable to find a checksum for JobIds %s. Use Signature = MD5/SHA256 FileSet option\n", jobids);
       return -1;
    }
 
    type = hash_get_type(strlen((char *)lst[0]));
    if (!type) {
-      Mmsg(errmsg, "[DE0006] Unable to find a valid checksum database for JobIds %s\n", jobids);
+      Mmsg(errmsg, "[DE0055] Unable to find a valid checksum database for JobIds %s\n", jobids);
       return -1;
    }
 
@@ -306,7 +306,7 @@ int check_malware(JCR *jcr, const char *jobids, POOLMEM **errmsg)
 
    db_lock(jcr->db);
    if (!db_sql_query(jcr->db, "BEGIN", NULL, NULL)) {
-      Mmsg(errmsg, "[DE0008] SQL Error %s\n", jcr->db->errmsg);
+      Mmsg(errmsg, "[DE0028] SQL Error %s\n", jcr->db->errmsg);
       db_unlock(jcr->db);
       return -1;
    }
@@ -352,7 +352,7 @@ int check_malware(JCR *jcr, const char *jobids, POOLMEM **errmsg)
         "WHERE JobId IN (%s)", jcr->JobId, source_esc.c_str(), type, jobids);
 
    if (!db_sql_query(jcr->db, q.c_str(), NULL, NULL)) {
-      Mmsg(errmsg, "[DE0008] SQL Error %s\n", jcr->db->errmsg);
+      Mmsg(errmsg, "[DE0028] SQL Error %s\n", jcr->db->errmsg);
       return -1;
    }
 
@@ -361,16 +361,16 @@ int check_malware(JCR *jcr, const char *jobids, POOLMEM **errmsg)
         "WHERE FileEvents.JobId IN (%s) AND Type = 'M' LIMIT 1\n", jobids);
 
    if (!db_sql_query(jcr->db, q.c_str(), db_int_handler, &nb)) {
-      Mmsg(errmsg, "[DE0006] Unable to check malware for JobIds %s\n", jobids);
+      Mmsg(errmsg, "[DE0056] Unable to check malware for JobIds %s\n", jobids);
       return -1;
    }
 
    if (nb > 0) {
-      Mmsg(errmsg, _("[DE0007] Found Malware(s) on JobIds %s"), jobids);
+      Mmsg(errmsg, _("[DE0056] Found Malware(s) on JobIds %s"), jobids);
       return 1;
    }
    /* Leave a message */
-   Mmsg(errmsg, _("[DI0001] No known Malware reported by \"%s\"\n"), source);
+   Mmsg(errmsg, _("[DI0050] No known Malware reported by \"%s\"\n"), source);
    return 0;
 }
 
@@ -379,7 +379,7 @@ int check_malware(JCR *jcr, const char *jobids, POOLMEM **errmsg)
    lst.destroy();
    Mmsg(q, "SELECT Filename FROM SecurityEvents JOIN File USING (JobId, FileIndex) WHERE SecurityEvents.JobId IN (%s) LIMIT 1000\n", jobids);
    if (!db_sql_query(jcr->db, q.c_str(), db_string_list_handler, &l)) {
-      Mmsg(errmsg, "[DE0006] Unable to check malware for JobIds %s\n", jobids);
+      Mmsg(errmsg, "[DE0056] Unable to check malware for JobIds %s\n", jobids);
       return false;
    }   
    if (lst.size() > 0) {