From: Tobias Brunner Date: Fri, 14 Oct 2011 13:09:56 +0000 (+0200) Subject: pluto: Added fallback to ipsec.secrets parser if glob(3) is not available. X-Git-Tag: 4.6.0~128 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=345e5330b5ebfd356a03b293e1fca069d52f17ea;p=thirdparty%2Fstrongswan.git pluto: Added fallback to ipsec.secrets parser if glob(3) is not available. --- diff --git a/src/pluto/keys.c b/src/pluto/keys.c index 4b0e08791b..dfdc6bb341 100644 --- a/src/pluto/keys.c +++ b/src/pluto/keys.c @@ -27,10 +27,12 @@ #include /* missing from on old systems */ #include +#ifdef HAVE_GLOB_H #include #ifndef GLOB_ABORTED # define GLOB_ABORTED GLOB_ABEND /* fix for old versions */ #endif +#endif #include @@ -1033,7 +1035,6 @@ static void process_secrets_file(const char *file_pat, int whackfd) { struct file_lex_position pos; char **fnp; - glob_t globbuf; pos.depth = flp == NULL? 0 : flp->depth + 1; @@ -1043,8 +1044,10 @@ static void process_secrets_file(const char *file_pat, int whackfd) return; } +#ifdef HAVE_GLOB_H /* do globbing */ { + glob_t globbuf; int r = glob(file_pat, GLOB_ERR, globugh, &globbuf); if (r != 0) @@ -1066,21 +1069,30 @@ static void process_secrets_file(const char *file_pat, int whackfd) globfree(&globbuf); return; } - } - /* for each file... */ - for (fnp = globbuf.gl_pathv; *fnp != NULL; fnp++) - { - if (lexopen(&pos, *fnp, FALSE)) + /* for each file... */ + for (fnp = globbuf.gl_pathv; *fnp != NULL; fnp++) { - plog("loading secrets from \"%s\"", *fnp); - (void) flushline("file starts with indentation (continuation notation)"); - process_secret_records(whackfd); - lexclose(); + if (lexopen(&pos, *fnp, FALSE)) + { + plog("loading secrets from \"%s\"", *fnp); + (void) flushline("file starts with indentation (continuation notation)"); + process_secret_records(whackfd); + lexclose(); + } } - } - globfree(&globbuf); + globfree(&globbuf); + } +#else /* HAVE_GLOB_H */ + /* if glob(3) is not available, try to load pattern directly */ + if (lexopen(&pos, file_pat, FALSE)) + { + plog("loading secrets from \"%s\"", file_pat); + process_secret_records(whackfd); + lexclose(); + } +#endif /* HAVE_GLOB_H */ } void free_preshared_secrets(void)