]> git.ipfire.org Git - thirdparty/suricata.git/commitdiff
hashing: remove remaining HAVE_NSS guards
authorJason Ish <jason.ish@oisf.net>
Wed, 23 Dec 2020 22:50:07 +0000 (16:50 -0600)
committerVictor Julien <victor@inliniac.net>
Wed, 13 Jan 2021 08:01:04 +0000 (09:01 +0100)
For features, we pretend to HAVE_NSS so scripts, external tests
continue to work.

src/detect.c
src/output-json-email-common.c
src/runmode-unittests.c
src/suricata.c
src/util-lua-common.c

index 7a0b52d91fff36be3b6976cf4314a4b16d5d02f5..63a97d893942978162616d67ad6529ca9b9aba42 100644 (file)
@@ -411,7 +411,6 @@ DetectPostInspectFileFlagsUpdate(Flow *f, const SigGroupHead *sgh, uint8_t direc
             flow_file_flags |= (FLOWFILE_NO_MAGIC_TS|FLOWFILE_NO_MAGIC_TC);
         }
 #endif
-#ifdef HAVE_NSS
         if (!(sgh->flags & SIG_GROUP_HEAD_HAVEFILEMD5)) {
             SCLogDebug("requesting disabling md5 for flow");
             flow_file_flags |= (FLOWFILE_NO_MD5_TS|FLOWFILE_NO_MD5_TC);
@@ -424,7 +423,6 @@ DetectPostInspectFileFlagsUpdate(Flow *f, const SigGroupHead *sgh, uint8_t direc
             SCLogDebug("requesting disabling sha256 for flow");
             flow_file_flags |= (FLOWFILE_NO_SHA256_TS|FLOWFILE_NO_SHA256_TC);
         }
-#endif
         if (!(sgh->flags & SIG_GROUP_HEAD_HAVEFILESIZE)) {
             SCLogDebug("requesting disabling filesize for flow");
             flow_file_flags |= (FLOWFILE_NO_SIZE_TS|FLOWFILE_NO_SIZE_TC);
index bcfcf0d1a7e4069de1a611c960c71e329dae0470..4fd79859d488c0110b67e7923a581a945308f0f0 100644 (file)
 #include "output-json.h"
 #include "output-json-email-common.h"
 
-#ifdef HAVE_NSS
-#include <sechash.h>
-#endif
-
 #define LOG_EMAIL_DEFAULT       0
 #define LOG_EMAIL_EXTENDED      (1<<0)
 #define LOG_EMAIL_ARRAY         (1<<1) /* require array handling */
index 0a631a59b537306f9874322ae40717ea381b1221..6c6111a3b8b65a913a8026cdb0d3fa37a0b3097c 100644 (file)
 #include "source-windivert.h"
 #endif
 
-#ifdef HAVE_NSS
-#include <prinit.h>
-#include <nss.h>
-#endif
-
 #endif /* UNITTESTS */
 
 void TmqhSetup (void);
@@ -264,13 +259,6 @@ void RunUnittests(int list_unittests, const char *regex_arg)
         UtRunSelftest(regex_arg); /* inits and cleans up again */
     }
 
-#ifdef HAVE_NSS
-    /* init NSS for hashing */
-    PR_Init(PR_USER_THREAD, PR_PRIORITY_NORMAL, 0);
-    NSS_NoDB_Init(NULL);
-#endif
-
-
     AppLayerHtpEnableRequestBodyCallback();
     AppLayerHtpNeedFileInspection();
 
index 16d648ece628a7d7f1dd39971606d5096f9c6618..0d3e8a67ea34eb31b0007a7678bd79faf2362600 100644 (file)
 #include <signal.h>
 #endif
 
-#ifdef HAVE_NSS
-#include <prinit.h>
-#include <nss.h>
-#endif
-
 #include "suricata.h"
 #include "decode.h"
 #include "feature.h"
@@ -357,12 +352,6 @@ static void GlobalsDestroy(SCInstance *suri)
     TmqhCleanup();
     TmModuleRunDeInit();
     ParseSizeDeinit();
-#ifdef HAVE_NSS
-    if (NSS_IsInitialized()) {
-        NSS_Shutdown();
-        PR_Cleanup();
-    }
-#endif
 
 #ifdef HAVE_AF_PACKET
     AFPPeersListClean();
@@ -703,9 +692,8 @@ static void PrintBuildInfo(void)
 #ifdef PCRE_HAVE_JIT
     strlcat(features, "PCRE_JIT ", sizeof(features));
 #endif
-#ifdef HAVE_NSS
+    /* For compatibility, just say we have HAVE_NSS. */
     strlcat(features, "HAVE_NSS ", sizeof(features));
-#endif
 #ifdef HAVE_LUA
     strlcat(features, "HAVE_LUA ", sizeof(features));
 #endif
@@ -2594,15 +2582,6 @@ int PostConfLoadedSetup(SCInstance *suri)
         SCReturnInt(TM_ECODE_FAILED);
     }
 
-
-#ifdef HAVE_NSS
-    if (suri->run_mode != RUNMODE_CONF_TEST) {
-        /* init NSS for hashing */
-        PR_Init(PR_USER_THREAD, PR_PRIORITY_NORMAL, 0);
-        NSS_NoDB_Init(NULL);
-    }
-#endif
-
     if (suri->disabled_detect) {
         SCLogConfig("detection engine disabled");
         /* disable raw reassembly */
index 5ae952501f43889a6c2301e55bbb35c8c740ddf1..ecc93dcb6d8514bd042e754b8fdfa057f4cfe9b4 100644 (file)
@@ -754,42 +754,41 @@ static int LuaCallbackLogError(lua_State *luastate)
  */
 static int LuaCallbackFileInfoPushToStackFromFile(lua_State *luastate, const File *file)
 {
-#ifdef HAVE_NSS
-    char md5[33] = "";
-    char *md5ptr = md5;
-    if (file->flags & FILE_MD5) {
-        size_t x;
-        for (x = 0; x < sizeof(file->md5); x++) {
-            char one[3] = "";
-            snprintf(one, sizeof(one), "%02x", file->md5[x]);
-            strlcat(md5, one, sizeof(md5));
+    char *md5ptr = NULL;
+    char *sha1ptr = NULL;
+    char *sha256ptr = NULL;
+    if (!g_disable_hashing) {
+        char md5[33] = "";
+        md5ptr = md5;
+        if (file->flags & FILE_MD5) {
+            size_t x;
+            for (x = 0; x < sizeof(file->md5); x++) {
+                char one[3] = "";
+                snprintf(one, sizeof(one), "%02x", file->md5[x]);
+                strlcat(md5, one, sizeof(md5));
+            }
         }
-    }
-    char sha1[41] = "";
-    char *sha1ptr = sha1;
-    if (file->flags & FILE_SHA1) {
-        size_t x;
-        for (x = 0; x < sizeof(file->sha1); x++) {
-            char one[3] = "";
-            snprintf(one, sizeof(one), "%02x", file->sha1[x]);
-            strlcat(sha1, one, sizeof(sha1));
+        char sha1[41] = "";
+        sha1ptr = sha1;
+        if (file->flags & FILE_SHA1) {
+            size_t x;
+            for (x = 0; x < sizeof(file->sha1); x++) {
+                char one[3] = "";
+                snprintf(one, sizeof(one), "%02x", file->sha1[x]);
+                strlcat(sha1, one, sizeof(sha1));
+            }
         }
-    }
-    char sha256[65] = "";
-    char *sha256ptr = sha256;
-    if (file->flags & FILE_SHA256) {
-        size_t x;
-        for (x = 0; x < sizeof(file->sha256); x++) {
-            char one[3] = "";
-            snprintf(one, sizeof(one), "%02x", file->sha256[x]);
-            strlcat(sha256, one, sizeof(sha256));
+        char sha256[65] = "";
+        sha256ptr = sha256;
+        if (file->flags & FILE_SHA256) {
+            size_t x;
+            for (x = 0; x < sizeof(file->sha256); x++) {
+                char one[3] = "";
+                snprintf(one, sizeof(one), "%02x", file->sha256[x]);
+                strlcat(sha256, one, sizeof(sha256));
+            }
         }
     }
-#else
-    char *md5ptr = NULL;
-    char *sha1ptr = NULL;
-    char *sha256ptr = NULL;
-#endif
 
     lua_pushnumber(luastate, file->file_store_id);
     lua_pushnumber(luastate, file->txid);