Make sure that if not built against libnss, we still compile. Only no md5 for you then\!

remotes/origin/master
Victor Julien 14 years ago
parent 6752ccae2a
commit 337f7861a4

@ -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

@ -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\", ");

@ -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);

@ -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);

@ -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;

Loading…
Cancel
Save