]> git.ipfire.org Git - thirdparty/suricata.git/commitdiff
Make sure that if not built against libnss, we still compile. Only no md5 for you...
authorVictor Julien <victor@inliniac.net>
Thu, 16 Feb 2012 21:17:15 +0000 (22:17 +0100)
committerVictor Julien <victor@inliniac.net>
Thu, 16 Feb 2012 21:17:15 +0000 (22:17 +0100)
configure.in
src/log-file.c
src/suricata.c
src/util-file.c
src/util-file.h

index 3480ad4c62a5d4c4ba086a2b67e2884dd5c28cd4..9c08f20ce6ec5d810ca00e642ae3c5d6a83708ab 100644 (file)
@@ -1025,22 +1025,23 @@ AC_CHECK_HEADER(pcap.h,,[AC_ERROR(pcap.h not found ...)])
         CPPFLAGS="${CPPFLAGS} -I${with_libnspr_includes}"
     fi
 
-    AC_CHECK_HEADER(nspr.h,,[AC_ERROR(nspr.h not found ...)])
-
-    if test "$with_libnspr_libraries" != "no"; then
-        LDFLAGS="${LDFLAGS}  -L${with_libnspr_libraries}"
-    fi
+    AC_CHECK_HEADER(nspr/nspr.h,NSPR="yes",NSPR="no")
+    if test "$NSPR" = "yes"; then
+        if test "$with_libnspr_libraries" != "no"; then
+            LDFLAGS="${LDFLAGS}  -L${with_libnspr_libraries}"
+        fi
 
-    MAGIC=""
-    AC_CHECK_LIB(nspr4, PR_GetCurrentThread,, NSPR="no")
+        AC_CHECK_LIB(nspr4, PR_GetCurrentThread,, NSPR="no")
 
-    if test "$NSPR" = "no"; then
-        echo
-        echo "   ERROR!  libnspr library not found, go get it"
-        echo "   from Mozilla."
-        echo
-        exit 1
+        if test "$NSPR" = "no"; then
+            echo
+            echo "   ERROR!  libnspr library not found, go get it"
+            echo "   from Mozilla."
+            echo
+            exit 1
+        fi
     fi
+
 #libnss
     AC_ARG_WITH(libnss_includes,
             [  --with-libnss-includes=DIR  libnss include directory],
@@ -1053,21 +1054,23 @@ AC_CHECK_HEADER(pcap.h,,[AC_ERROR(pcap.h not found ...)])
         CPPFLAGS="${CPPFLAGS} -I${with_libnss_includes}"
     fi
 
-    AC_CHECK_HEADER(sechash.h,,[AC_ERROR(sechash.h not found ...)])
+    AC_CHECK_HEADER(sechash.h,NSS="yes",NSS="no")
+    if test "$NSS" = "yes"; then
+        if test "$with_libnss_libraries" != "no"; then
+            LDFLAGS="${LDFLAGS}  -L${with_libnss_libraries}"
+        fi
 
-    if test "$with_libnss_libraries" != "no"; then
-        LDFLAGS="${LDFLAGS}  -L${with_libnss_libraries}"
-    fi
+        AC_CHECK_LIB(nss3, HASH_Begin,, NSS="no")
 
-    MAGIC=""
-    AC_CHECK_LIB(nss3, HASH_Begin,, NSS="no")
+        if test "$NSS" = "no"; then
+            echo
+            echo "   ERROR!  libnss library not found, go get it"
+            echo "   from Mozilla."
+            echo
+            exit 1
+        fi
 
-    if test "$NSS" = "no"; then
-        echo
-        echo "   ERROR!  libnss library not found, go get it"
-        echo "   from Mozilla."
-        echo
-        exit 1
+        AC_DEFINE([HAVE_NSS],[1],[libnss available for md5])
     fi
 
 #libmagic
index 7459531ec63d01fe07459e8c0e31bacf19378525..867287a8222509b61355bccb42b21ceb2ec90048 100644 (file)
@@ -208,6 +208,7 @@ static void LogFileLogCloseMetaFile(File *ff) {
         switch (ff->state) {
             case FILE_STATE_CLOSED:
                 fprintf(fp, "STATE:             CLOSED\n");
+#ifdef HAVE_NSS
                 if (ff->flags & FILE_MD5) {
                     fprintf(fp, "MD5:               ");
                     size_t x;
@@ -216,6 +217,7 @@ static void LogFileLogCloseMetaFile(File *ff) {
                     }
                     fprintf(fp, "\n");
                 }
+#endif
                 break;
             case FILE_STATE_TRUNCATED:
                 fprintf(fp, "STATE:             TRUNCATED\n");
@@ -304,6 +306,7 @@ static void LogFileWriteJsonRecord(LogFileLogThread *aft, Packet *p, File *ff, i
     switch (ff->state) {
         case FILE_STATE_CLOSED:
             fprintf(fp, "\"state\": \"CLOSED\", ");
+#ifdef HAVE_NSS
             if (ff->flags & FILE_MD5) {
                 fprintf(fp, "\"md5\": \"");
                 size_t x;
@@ -312,6 +315,7 @@ static void LogFileWriteJsonRecord(LogFileLogThread *aft, Packet *p, File *ff, i
                 }
                 fprintf(fp, "\", ");
             }
+#endif
             break;
         case FILE_STATE_TRUNCATED:
             fprintf(fp, "\"state\": \"TRUNCATED\", ");
index aa7926fdd0cfe8c1e3669227489c1b18494db373..e1599875900dd2d446470fb64abe6deafc4de00d 100644 (file)
@@ -28,7 +28,9 @@
 #include <signal.h>
 #include <pthread.h>
 
+#ifdef HAVE_NSS
 #include <nss.h>
+#endif
 
 #include "suricata.h"
 #include "decode.h"
@@ -548,6 +550,9 @@ void SCPrintBuildInfo(void) {
 #endif
 #ifdef PCRE_HAVE_JIT
     strlcat(features, "PCRE_JIT ", sizeof(features));
+#endif
+#ifdef HAVE_NSS
+    strlcat(features, "HAVE_NSS ", sizeof(features));
 #endif
     if (strlen(features) == 0) {
         strlcat(features, "none", sizeof(features));
@@ -640,8 +645,10 @@ int main(int argc, char **argv)
 
     SC_ATOMIC_INIT(engine_stage);
 
+#ifdef HAVE_NSS
     /* init NSS for md5 */
     NSS_NoDB_Init(NULL);
+#endif
 
     /* initialize the logging subsys */
     SCLogInitLogModule(NULL);
index c4e3d32bd1a487922127de3752a6266d7a206888..6cf52e78ef2d04a132e0e9477c02298b75e31ba9 100644 (file)
@@ -92,8 +92,10 @@ static int FileAppendFileDataFilePtr(File *ff, FileData *ffd) {
         ff->chunks_cnt_max = ff->chunks_cnt;
 #endif
 
+#ifdef HAVE_NSS
     if (ff->md5_ctx)
         HASH_Update(ff->md5_ctx, ffd->data, ffd->len);
+#endif
     SCReturnInt(0);
 }
 
@@ -287,12 +289,14 @@ static File *FileAlloc(uint8_t *name, uint16_t name_len) {
     new->name_len = name_len;
     memcpy(new->name, name, name_len);
 
+#ifdef HAVE_NSS
     if (g_file_force_md5) {
         new->md5_ctx = HASH_Create(HASH_AlgMD5);
         if (new->md5_ctx != NULL) {
             HASH_Begin(new->md5_ctx);
         }
     }
+#endif
     return new;
 }
 
@@ -317,9 +321,10 @@ static void FileFree(File *ff) {
         }
     }
 
+#ifdef HAVE_NSS
     if (ff->md5_ctx)
         HASH_Destroy(ff->md5_ctx);
-
+#endif
     SCLogDebug("ff chunks_cnt %"PRIu64", chunks_cnt_max %"PRIu64,
             ff->chunks_cnt, ff->chunks_cnt_max);
     SCFree(ff);
@@ -533,11 +538,13 @@ static int FileCloseFilePtr(File *ff, uint8_t *data,
         ff->state = FILE_STATE_CLOSED;
         SCLogDebug("flowfile state transitioned to FILE_STATE_CLOSED");
 
+#ifdef HAVE_NSS
         if (ff->md5_ctx) {
             unsigned int len = 0;
             HASH_End(ff->md5_ctx, ff->md5, &len, sizeof(ff->md5));
             ff->flags |= FILE_MD5;
         }
+#endif
     }
 
     SCReturnInt(0);
index 939f66e3d6b4e874c7584730bfe0396bc8dc68c0..b36f780134c589e68860a4128853b1ff68bc65a4 100644 (file)
@@ -25,7 +25,9 @@
 #ifndef __UTIL_FILE_H__
 #define __UTIL_FILE_H__
 
-#include "nss/sechash.h"
+#ifdef HAVE_NSS
+#include <nss/sechash.h>
+#endif
 
 #define FILE_TRUNCATED  0x01
 #define FILE_NOSTORE    0x02
@@ -66,8 +68,10 @@ typedef struct File_ {
     FileData *chunks_head;
     FileData *chunks_tail;
     struct File_ *next;
+#ifdef HAVE_NSS
     HASHContext *md5_ctx;
     uint8_t md5[MD5_LENGTH];
+#endif
 #ifdef DEBUG
     uint64_t chunks_cnt;
     uint64_t chunks_cnt_max;