aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorTobias Brunner <tobias@strongswan.org>2011-10-11 12:35:22 +0200
committerTobias Brunner <tobias@strongswan.org>2011-10-11 16:30:20 +0200
commitd3bd67239ff23c2dee180a1d14220ad1cf639614 (patch)
tree12dfe57f6df008223f94bc7ec9f0f75091f31915 /src
parentdc299da8e54765a1f4783b0f5ffa1c06e670b9d3 (diff)
downloadstrongswan-d3bd67239ff23c2dee180a1d14220ad1cf639614.tar.bz2
strongswan-d3bd67239ff23c2dee180a1d14220ad1cf639614.tar.xz
Added fallback to ipsec.secrets parser if glob(3) is not available.
Diffstat (limited to 'src')
-rw-r--r--src/libcharon/plugins/stroke/stroke_cred.c33
1 files changed, 22 insertions, 11 deletions
diff --git a/src/libcharon/plugins/stroke/stroke_cred.c b/src/libcharon/plugins/stroke/stroke_cred.c
index 1bb3d016b..47381b75e 100644
--- a/src/libcharon/plugins/stroke/stroke_cred.c
+++ b/src/libcharon/plugins/stroke/stroke_cred.c
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2008-2010 Tobias Brunner
+ * Copyright (C) 2008-2011 Tobias Brunner
* Copyright (C) 2008 Martin Willi
* Hochschule fuer Technik Rapperswil
*
@@ -17,13 +17,16 @@
#include <sys/types.h>
#include <sys/stat.h>
#include <limits.h>
-#include <glob.h>
#include <libgen.h>
#include <sys/mman.h>
#include <fcntl.h>
#include <errno.h>
#include <unistd.h>
+#ifdef HAVE_GLOB_H
+#include <glob.h>
+#endif
+
#include "stroke_cred.h"
#include <credentials/certificates/x509.h>
@@ -844,7 +847,6 @@ static void load_secrets(private_stroke_cred_t *this, char *file, int level,
if (line.len > strlen("include ") &&
strneq(line.ptr, "include ", strlen("include ")))
{
- glob_t buf;
char **expanded, *dir, pattern[PATH_MAX];
u_char *pos;
@@ -886,18 +888,27 @@ static void load_secrets(private_stroke_cred_t *this, char *file, int level,
dir, (int)line.len, line.ptr);
free(dir);
}
- if (glob(pattern, GLOB_ERR, NULL, &buf) != 0)
- {
- DBG1(DBG_CFG, "expanding file expression '%s' failed", pattern);
- }
- else
+#ifdef HAVE_GLOB_H
{
- for (expanded = buf.gl_pathv; *expanded != NULL; expanded++)
+ glob_t buf;
+ if (glob(pattern, GLOB_ERR, NULL, &buf) != 0)
{
- load_secrets(this, *expanded, level + 1, prompt);
+ DBG1(DBG_CFG, "expanding file expression '%s' failed",
+ pattern);
+ }
+ else
+ {
+ for (expanded = buf.gl_pathv; *expanded != NULL; expanded++)
+ {
+ load_secrets(this, *expanded, level + 1, prompt);
+ }
}
+ globfree(&buf);
}
- globfree(&buf);
+#else /* HAVE_GLOB_H */
+ /* if glob(3) is not available, try to load pattern directly */
+ load_secrets(this, pattern, level + 1, prompt);
+#endif /* HAVE_GLOB_H */
continue;
}