pluto: Added fallback to ipsec.secrets parser if glob(3) is not available.
This commit is contained in:
+24
-12
@@ -27,10 +27,12 @@
|
|||||||
#include <arpa/nameser.h> /* missing from <resolv.h> on old systems */
|
#include <arpa/nameser.h> /* missing from <resolv.h> on old systems */
|
||||||
#include <sys/queue.h>
|
#include <sys/queue.h>
|
||||||
|
|
||||||
|
#ifdef HAVE_GLOB_H
|
||||||
#include <glob.h>
|
#include <glob.h>
|
||||||
#ifndef GLOB_ABORTED
|
#ifndef GLOB_ABORTED
|
||||||
# define GLOB_ABORTED GLOB_ABEND /* fix for old versions */
|
# define GLOB_ABORTED GLOB_ABEND /* fix for old versions */
|
||||||
#endif
|
#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
#include <freeswan.h>
|
#include <freeswan.h>
|
||||||
|
|
||||||
@@ -1033,7 +1035,6 @@ static void process_secrets_file(const char *file_pat, int whackfd)
|
|||||||
{
|
{
|
||||||
struct file_lex_position pos;
|
struct file_lex_position pos;
|
||||||
char **fnp;
|
char **fnp;
|
||||||
glob_t globbuf;
|
|
||||||
|
|
||||||
pos.depth = flp == NULL? 0 : flp->depth + 1;
|
pos.depth = flp == NULL? 0 : flp->depth + 1;
|
||||||
|
|
||||||
@@ -1043,8 +1044,10 @@ static void process_secrets_file(const char *file_pat, int whackfd)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef HAVE_GLOB_H
|
||||||
/* do globbing */
|
/* do globbing */
|
||||||
{
|
{
|
||||||
|
glob_t globbuf;
|
||||||
int r = glob(file_pat, GLOB_ERR, globugh, &globbuf);
|
int r = glob(file_pat, GLOB_ERR, globugh, &globbuf);
|
||||||
|
|
||||||
if (r != 0)
|
if (r != 0)
|
||||||
@@ -1066,21 +1069,30 @@ static void process_secrets_file(const char *file_pat, int whackfd)
|
|||||||
globfree(&globbuf);
|
globfree(&globbuf);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
/* for each file... */
|
/* for each file... */
|
||||||
for (fnp = globbuf.gl_pathv; *fnp != NULL; fnp++)
|
for (fnp = globbuf.gl_pathv; *fnp != NULL; fnp++)
|
||||||
{
|
|
||||||
if (lexopen(&pos, *fnp, FALSE))
|
|
||||||
{
|
{
|
||||||
plog("loading secrets from \"%s\"", *fnp);
|
if (lexopen(&pos, *fnp, FALSE))
|
||||||
(void) flushline("file starts with indentation (continuation notation)");
|
{
|
||||||
process_secret_records(whackfd);
|
plog("loading secrets from \"%s\"", *fnp);
|
||||||
lexclose();
|
(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)
|
void free_preshared_secrets(void)
|
||||||
|
|||||||
Reference in New Issue
Block a user