]> git.ipfire.org Git - thirdparty/suricata.git/commitdiff
filestore: respect g_disable_hashing
authorJason Ish <jason.ish@oisf.net>
Mon, 28 Dec 2020 22:08:30 +0000 (16:08 -0600)
committerVictor Julien <victor@inliniac.net>
Wed, 13 Jan 2021 08:01:05 +0000 (09:01 +0100)
If g_disable_hashing is set, behave like libnss wasn't compiled
in.

src/util-file.c

index ea9fe2a456f8d621abf2c0b8ebb3ff78ad948a60..6e1b73087098676a90038b3ce30ac1165b515dca 100644 (file)
@@ -181,8 +181,13 @@ void FileForceHashParseCfg(ConfNode *conf)
                 "found. Please use 'force-hash: [md5]' instead");
 
         if (ConfValIsTrue(force_md5)) {
-            FileForceMd5Enable();
-            SCLogInfo("forcing md5 calculation for logged files");
+            if (g_disable_hashing) {
+                SCLogInfo(
+                        "not forcing md5 calculation for logged files: hashing globally disabled");
+            } else {
+                FileForceMd5Enable();
+                SCLogInfo("forcing md5 calculation for logged files");
+            }
         }
     }
 
@@ -194,18 +199,33 @@ void FileForceHashParseCfg(ConfNode *conf)
 
         TAILQ_FOREACH(field, &forcehash_node->head, next) {
             if (strcasecmp("md5", field->val) == 0) {
-                FileForceMd5Enable();
-                SCLogConfig("forcing md5 calculation for logged or stored files");
+                if (g_disable_hashing) {
+                    SCLogInfo("not forcing md5 calculation for logged files: hashing globally "
+                              "disabled");
+                } else {
+                    FileForceMd5Enable();
+                    SCLogConfig("forcing md5 calculation for logged or stored files");
+                }
             }
 
             if (strcasecmp("sha1", field->val) == 0) {
-                FileForceSha1Enable();
-                SCLogConfig("forcing sha1 calculation for logged or stored files");
+                if (g_disable_hashing) {
+                    SCLogInfo("not forcing sha1 calculation for logged files: hashing globally "
+                              "disabled");
+                } else {
+                    FileForceSha1Enable();
+                    SCLogConfig("forcing sha1 calculation for logged or stored files");
+                }
             }
 
             if (strcasecmp("sha256", field->val) == 0) {
-                FileForceSha256Enable();
-                SCLogConfig("forcing sha256 calculation for logged or stored files");
+                if (g_disable_hashing) {
+                    SCLogInfo("not forcing sha256 calculation for logged files: hashing globally "
+                              "disabled");
+                } else {
+                    FileForceSha256Enable();
+                    SCLogConfig("forcing sha256 calculation for logged or stored files");
+                }
             }
         }
     }