detect: make glob.h optional

glob.h is not available on MinGW.

Simply use the input on the rule list as a literal pattern.
pull/3017/head
Victor Julien 7 years ago
parent e1d1a7f2ac
commit 2a237bdfca

@ -127,7 +127,7 @@
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])

@ -230,7 +230,9 @@
#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;
}

Loading…
Cancel
Save