summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMartin Carpenter <mcarpenter@free.fr>2012-11-27 09:35:48 +0100
committerRainer Gerhards <rgerhards@adiscon.com>2013-03-21 16:03:46 +0100
commit5e6ba49ef3ae3bc79c2dc1aa160900a5f776c72a (patch)
tree6a3fc109a86692b26fa80bbf717c8afa702b9ca2
parent8cc6969c732c1d26cc699983d201124004a6526f (diff)
downloadrsyslog-5e6ba49ef3ae3bc79c2dc1aa160900a5f776c72a.tar.gz
rsyslog-5e6ba49ef3ae3bc79c2dc1aa160900a5f776c72a.tar.bz2
rsyslog-5e6ba49ef3ae3bc79c2dc1aa160900a5f776c72a.zip
Fix for glob(3)s that lack GLOB_NOMAGIC
Conflicts: configure.ac
-rw-r--r--ChangeLog1
-rw-r--r--configure.ac1
-rw-r--r--grammar/rainerscript.c12
-rw-r--r--runtime/srUtils.h1
-rw-r--r--runtime/srutils.c22
5 files changed, 33 insertions, 4 deletions
diff --git a/ChangeLog b/ChangeLog
index c3445a66..4705b985 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -13,6 +13,7 @@ Version 7.3.9 [devel] 2013-03-??
is now detected and the new file being forwarded right from the
beginning.
closes: http://bugzilla.adiscon.com/show_bug.cgi?id=228
+- bugfix: build problem on platforms without GLOB_NOMAGIC
- bugfix: build problems on non-Linux platforms
- bugfix: stdout/stderr were not closed on forking
but were closed when running in the forground - this was just reversed
diff --git a/configure.ac b/configure.ac
index 526244fe..a6d1b8e7 100644
--- a/configure.ac
+++ b/configure.ac
@@ -124,6 +124,7 @@ AC_CHECK_DECL([SO_TIMESTAMP], [AC_DEFINE(HAVE_SO_TIMESTAMP, [1], [set define])],
#include <sys/socket.h>])
AC_CHECK_DECL([SYS_gettid], [AC_DEFINE(HAVE_SYS_gettid, [1], [set define])], [], [#include <sys/syscall.h>])
AC_CHECK_MEMBER([struct sysinfo.uptime], [AC_DEFINE(HAVE_SYSINFO_UPTIME, [1], [set define])], [], [#include <sys/sysinfo.h>])
+AC_CHECK_DECL([GLOB_NOMAGIC], [AC_DEFINE(HAVE_GLOB_NOMAGIC, [1], [set define])], [], [#include <glob.h>])
# Check for MAXHOSTNAMELEN
AC_MSG_CHECKING(for MAXHOSTNAMELEN)
diff --git a/grammar/rainerscript.c b/grammar/rainerscript.c
index 065e815a..8ef7429d 100644
--- a/grammar/rainerscript.c
+++ b/grammar/rainerscript.c
@@ -3256,12 +3256,16 @@ cnfDoInclude(char *name)
/* Use GLOB_MARK to append a trailing slash for directories. */
/* Use GLOB_NOMAGIC to detect wildcards that match nothing. */
- result = glob(finalName, GLOB_MARK | GLOB_NOMAGIC, NULL, &cfgFiles);
-
+#ifdef HAVE_GLOB_NOMAGIC
/* Silently ignore wildcards that match nothing */
+ result = glob(finalName, GLOB_MARK | GLOB_NOMAGIC, NULL, &cfgFiles);
if(result == GLOB_NOMATCH) {
- return 0;
- }
+#else
+ result = glob(finalName, GLOB_MARK, NULL, &cfgFiles);
+ if(result == GLOB_NOMATCH && containsGlobWildcard(finalName)) {
+#endif /* HAVE_GLOB_NOMAGIC */
+ return 0;
+ }
if(result == GLOB_NOSPACE || result == GLOB_ABORTED) {
char errStr[1024];
diff --git a/runtime/srUtils.h b/runtime/srUtils.h
index 3169fd94..8626a4bb 100644
--- a/runtime/srUtils.h
+++ b/runtime/srUtils.h
@@ -91,6 +91,7 @@ char *rs_strerror_r(int errnum, char *buf, size_t buflen);
int decodeSyslogName(uchar *name, syslogName_t *codetab);
int getSubString(uchar **ppSrc, char *pDst, size_t DstSize, char cSep);
rsRetVal getFileSize(uchar *pszName, off_t *pSize);
+int containsGlobWildcard(char *str);
/* mutex operations */
/* some useful constants */
diff --git a/runtime/srutils.c b/runtime/srutils.c
index 7b485b23..6a509b4a 100644
--- a/runtime/srutils.c
+++ b/runtime/srutils.c
@@ -630,6 +630,28 @@ finalize_it:
RETiRet;
}
+/* Returns 1 if the given string contains a non-escaped glob(3)
+ * wildcard character and 0 otherwise (or if the string is empty).
+ */
+int
+containsGlobWildcard(char *str)
+{
+ char *p;
+ if(!str) {
+ return 0;
+ }
+ /* From Linux Programmer's Guide:
+ * "A string is a wildcard pattern if it contains one of the characters '?', '*' or '['"
+ * "One can remove the special meaning of '?', '*' and '[' by preceding them by a backslash"
+ */
+ for(p = str; *p != '\0'; p++) {
+ if((*p == '?' || *p == '*' || *p == '[') &&
+ (p == str || *(p-1) != '\\')) {
+ return 1;
+ }
+ }
+ return 0;
+}
/* vim:set ai:
*/