diff options
author | Zheng Gu <zhenggu@cisco.com> | 2019-11-22 22:34:16 +0800 |
---|---|---|
committer | dormando <dormando@rydia.net> | 2020-02-14 20:27:32 -0800 |
commit | 6207330c2705fdb5f02de13b99a0d994f7c4f14a (patch) | |
tree | 52976b786790184b2e0f356dc8e2248d98cf317c /sasl_defs.c | |
parent | ecf8e944e54c4f7ca21d8c6af5b2ef110a9e4189 (diff) | |
download | memcached-6207330c2705fdb5f02de13b99a0d994f7c4f14a.tar.gz |
fix bug where sasl will load config the wrong path
/etc/sasl2/memcached.conf/memcached.conf instead of
/etc/sasl2/memcached.conf
Diffstat (limited to 'sasl_defs.c')
-rw-r--r-- | sasl_defs.c | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/sasl_defs.c b/sasl_defs.c index c60d1bf..370f947 100644 --- a/sasl_defs.c +++ b/sasl_defs.c @@ -16,6 +16,23 @@ const char * const locations[] = { "/etc/sasl2/memcached.conf", NULL }; + +/* If the element of locations is file, locations_dir_path stores the + * directory path of these elements */ +const char *const locations_dir_path[] = { + "/etc/sasl", + "/etc/sasl2", + NULL +}; + +/* If the element of locations is directory, locations_file_path stores + * the actual configue file which used by sasl, when GETCONFPATH is + * enabled */ +const char *const locations_file_path[] = { + "/etc/sasl/memcached.conf/memcached.conf", + "/etc/sasl2/memcached.conf/memcached.conf", + NULL +}; #endif #ifndef HAVE_SASL_CALLBACK_FT @@ -88,12 +105,24 @@ static int sasl_getconf(void *context, const char **path) *path = getenv("SASL_CONF_PATH"); if (*path == NULL) { +#if defined(HAVE_SASL_CB_GETCONF) for (int i = 0; locations[i] != NULL; ++i) { if (access(locations[i], F_OK) == 0) { *path = locations[i]; break; } } +#elif defined(HAVE_SASL_CB_GETCONFPATH) + for (int i = 0; locations[i] != NULL; ++i) { + if (access(locations_file_path[i], F_OK) == 0) { + *path = locations[i]; + break; + } else if (access(locations[i], F_OK) == 0) { + *path = locations_dir_path[i]; + break; + } + } +#endif } if (settings.verbose) { |