]> git.ipfire.org Git - thirdparty/suricata.git/commitdiff
detect: make glob.h optional
authorVictor Julien <victor@inliniac.net>
Mon, 17 Jul 2017 09:19:20 +0000 (11:19 +0200)
committerVictor Julien <victor@inliniac.net>
Mon, 27 Nov 2017 07:00:27 +0000 (08:00 +0100)
glob.h is not available on MinGW.

Simply use the input on the rule list as a literal pattern.

configure.ac
src/detect.c

index 54ee1f6d7b495394753ed617969752fceb480df0..3e5dd8ddbf6298ceaa3bc57d1cb3b55ee61e260c 100644 (file)
     AC_CHECK_HEADERS([sys/time.h time.h unistd.h])
     AC_CHECK_HEADERS([sys/ioctl.h linux/if_ether.h linux/if_packet.h linux/filter.h])
     AC_CHECK_HEADERS([linux/ethtool.h linux/sockios.h])
-    AC_CHECK_HEADER(glob.h,,[AC_ERROR(glob.h not found ...)])
+    AC_CHECK_HEADERS([glob.h])
     AC_CHECK_HEADERS([dirent.h fnmatch.h])
     AC_CHECK_HEADERS([sys/resource.h sys/types.h sys/un.h])
     AC_CHECK_HEADERS([sys/random.h])
index 0d88be7fa02b73cf77266c475e03a0a33e6b410f..19e49d0e429fe5bfb3fe3be0730ce670cb29c047 100644 (file)
 #include "util-mpm-ac.h"
 #include "runmodes.h"
 
+#ifdef HAVE_GLOB_H
 #include <glob.h>
+#endif
 
 extern int rule_reload;
 
@@ -389,13 +391,16 @@ static int DetectLoadSigFile(DetectEngineCtx *de_ctx, char *sig_file,
 static int ProcessSigFiles(DetectEngineCtx *de_ctx, char *pattern,
         SigFileLoaderStat *st, int *good_sigs, int *bad_sigs)
 {
+    int r = 0;
+
     if (pattern == NULL) {
         SCLogError(SC_ERR_INVALID_ARGUMENT, "opening rule file null");
         return -1;
     }
 
+#ifdef HAVE_GLOB_H
     glob_t files;
-    int r = glob(pattern, 0, NULL, &files);
+    r = glob(pattern, 0, NULL, &files);
 
     if (r == GLOB_NOMATCH) {
         SCLogWarning(SC_ERR_NO_RULES, "No rule files match the pattern %s", pattern);
@@ -412,6 +417,11 @@ static int ProcessSigFiles(DetectEngineCtx *de_ctx, char *pattern,
         char *fname = files.gl_pathv[i];
         if (strcmp("/dev/null", fname) == 0)
             continue;
+#else
+        char *fname = pattern;
+        if (strcmp("/dev/null", fname) == 0)
+            return 0;
+#endif
 
         SCLogConfig("Loading rule file: %s", fname);
         r = DetectLoadSigFile(de_ctx, fname, good_sigs, bad_sigs);
@@ -423,9 +433,10 @@ static int ProcessSigFiles(DetectEngineCtx *de_ctx, char *pattern,
 
         st->good_sigs_total += *good_sigs;
         st->bad_sigs_total += *bad_sigs;
+#ifdef HAVE_GLOB_H
     }
-
     globfree(&files);
+#endif
     return r;
 }