From 30745617960c85586d1b8a067c89d4abecf6f465 Mon Sep 17 00:00:00 2001 From: Jeffrey Altman Date: Mon, 25 May 2020 14:16:35 -0400 Subject: [PATCH] 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 --- lib/base/baselocl.h | 1 + lib/base/config_file.c | 19 ++++++------------- lib/base/log.c | 1 + 3 files changed, 8 insertions(+), 13 deletions(-) diff --git a/lib/base/baselocl.h b/lib/base/baselocl.h index 7ca6439b3..71fc2b3f2 100644 --- a/lib/base/baselocl.h +++ b/lib/base/baselocl.h @@ -40,6 +40,7 @@ #define ISTILDE(x) (x == '~') #ifdef _WIN32 # define ISPATHSEP(x) (x == '/' || x =='\\') +# define HEIM_BASE_USE_PATH_TOKENS 1 #else # define ISPATHSEP(x) (x == '/') #endif diff --git a/lib/base/config_file.c b/lib/base/config_file.c index c41f4d624..b759c717f 100644 --- a/lib/base/config_file.c +++ b/lib/base/config_file.c @@ -572,7 +572,7 @@ heim_config_parse_file_multi(heim_context context, * enabled by calling heim_set_home_dir_access(). */ if (ISTILDE(fname[0]) && ISPATHSEP(fname[1])) { -#ifndef KRB5_USE_PATH_TOKENS +#ifndef HEIM_BASE_USE_PATH_TOKENS const char *home = NULL; char homebuf[MAX_PATH]; @@ -594,7 +594,7 @@ heim_config_parse_file_multi(heim_context context, } 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 * access. We could refactor this a bit though. @@ -605,7 +605,7 @@ heim_config_parse_file_multi(heim_context context, return heim_enomem(context); } fname = newfname; -#endif +#endif /* HEIM_BASE_USE_PATH_TOKENS */ } if (is_plist_file(fname)) { @@ -624,15 +624,8 @@ heim_config_parse_file_multi(heim_context context, return ENOENT; #endif } else { -#ifdef KRB5_USE_PATH_TOKENS - char * exp_fname = 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. - */ +#ifdef HEIM_BASE_USE_PATH_TOKENS + char *exp_fname; /* newfname might be non-NULL */ ret = heim_expand_path_tokens(context, fname, 1, &exp_fname, NULL); if (ret) { config_include_depth--; @@ -642,7 +635,7 @@ heim_config_parse_file_multi(heim_context context, free(newfname); fname = newfname = exp_fname; -#endif +#endif /* HEIM_BASE_USE_PATH_TOKENS */ f.context = context; f.f = fopen(fname, "r"); diff --git a/lib/base/log.c b/lib/base/log.c index 5954716a1..69cb79b96 100644 --- a/lib/base/log.c +++ b/lib/base/log.c @@ -35,6 +35,7 @@ #include "baselocl.h" #include "heim_threads.h" +#include "heimbase.h" #include "heimbase-svc.h" #include #include