lib/base: introduce HEIM_BASE_USE_PATH_TOKENS
KRB5_USE_PATH_TOKENS cannot be used within lib/base as its value is declared in lib/krb5/krb5.h. Declare HEIM_BASE_USE_PATH_TOKENS in lib/base/baselocl.h and test for it in heim_config_parse_file_multi(). By conditionalizing heim_config_parse_file_multi() behavior on KRB5_USE_PATH_TOKENS heim_expand_path_tokens() is not executed and open() is called on a path without token substitution. As a result open() always fails with ENOENT. Change-Id: I29dc018bc560519b76314232b2d51f53bde6313c
This commit is contained in:

committed by
Nicolas Williams

parent
f77618ef15
commit
3074561796
@@ -40,6 +40,7 @@
|
|||||||
#define ISTILDE(x) (x == '~')
|
#define ISTILDE(x) (x == '~')
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
# define ISPATHSEP(x) (x == '/' || x =='\\')
|
# define ISPATHSEP(x) (x == '/' || x =='\\')
|
||||||
|
# define HEIM_BASE_USE_PATH_TOKENS 1
|
||||||
#else
|
#else
|
||||||
# define ISPATHSEP(x) (x == '/')
|
# define ISPATHSEP(x) (x == '/')
|
||||||
#endif
|
#endif
|
||||||
|
@@ -572,7 +572,7 @@ heim_config_parse_file_multi(heim_context context,
|
|||||||
* enabled by calling heim_set_home_dir_access().
|
* enabled by calling heim_set_home_dir_access().
|
||||||
*/
|
*/
|
||||||
if (ISTILDE(fname[0]) && ISPATHSEP(fname[1])) {
|
if (ISTILDE(fname[0]) && ISPATHSEP(fname[1])) {
|
||||||
#ifndef KRB5_USE_PATH_TOKENS
|
#ifndef HEIM_BASE_USE_PATH_TOKENS
|
||||||
const char *home = NULL;
|
const char *home = NULL;
|
||||||
char homebuf[MAX_PATH];
|
char homebuf[MAX_PATH];
|
||||||
|
|
||||||
@@ -594,7 +594,7 @@ heim_config_parse_file_multi(heim_context context,
|
|||||||
}
|
}
|
||||||
fname = newfname;
|
fname = newfname;
|
||||||
}
|
}
|
||||||
#else /* KRB5_USE_PATH_TOKENS */
|
#else /* HEIM_BASE_USE_PATH_TOKENS */
|
||||||
/*
|
/*
|
||||||
* Really, this is Windows, and on Windows we'd want to allow homedir
|
* Really, this is Windows, and on Windows we'd want to allow homedir
|
||||||
* access. We could refactor this a bit though.
|
* access. We could refactor this a bit though.
|
||||||
@@ -605,7 +605,7 @@ heim_config_parse_file_multi(heim_context context,
|
|||||||
return heim_enomem(context);
|
return heim_enomem(context);
|
||||||
}
|
}
|
||||||
fname = newfname;
|
fname = newfname;
|
||||||
#endif
|
#endif /* HEIM_BASE_USE_PATH_TOKENS */
|
||||||
}
|
}
|
||||||
|
|
||||||
if (is_plist_file(fname)) {
|
if (is_plist_file(fname)) {
|
||||||
@@ -624,15 +624,8 @@ heim_config_parse_file_multi(heim_context context,
|
|||||||
return ENOENT;
|
return ENOENT;
|
||||||
#endif
|
#endif
|
||||||
} else {
|
} else {
|
||||||
#ifdef KRB5_USE_PATH_TOKENS
|
#ifdef HEIM_BASE_USE_PATH_TOKENS
|
||||||
char * exp_fname = NULL;
|
char *exp_fname; /* newfname might be non-NULL */
|
||||||
|
|
||||||
/*
|
|
||||||
* Note that heim_config_parse_dir_multi() doesn't want tokens
|
|
||||||
* expanded here, but it happens to limit the names of files to
|
|
||||||
* include such that there can be no tokens to expand. Don't
|
|
||||||
* add token expansion for tokens using _, say.
|
|
||||||
*/
|
|
||||||
ret = heim_expand_path_tokens(context, fname, 1, &exp_fname, NULL);
|
ret = heim_expand_path_tokens(context, fname, 1, &exp_fname, NULL);
|
||||||
if (ret) {
|
if (ret) {
|
||||||
config_include_depth--;
|
config_include_depth--;
|
||||||
@@ -642,7 +635,7 @@ heim_config_parse_file_multi(heim_context context,
|
|||||||
|
|
||||||
free(newfname);
|
free(newfname);
|
||||||
fname = newfname = exp_fname;
|
fname = newfname = exp_fname;
|
||||||
#endif
|
#endif /* HEIM_BASE_USE_PATH_TOKENS */
|
||||||
|
|
||||||
f.context = context;
|
f.context = context;
|
||||||
f.f = fopen(fname, "r");
|
f.f = fopen(fname, "r");
|
||||||
|
@@ -35,6 +35,7 @@
|
|||||||
|
|
||||||
#include "baselocl.h"
|
#include "baselocl.h"
|
||||||
#include "heim_threads.h"
|
#include "heim_threads.h"
|
||||||
|
#include "heimbase.h"
|
||||||
#include "heimbase-svc.h"
|
#include "heimbase-svc.h"
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
#include <stdarg.h>
|
#include <stdarg.h>
|
||||||
|
Reference in New Issue
Block a user