diff options
author | Stefan Schubert <schubi@suse.de> | 2024-06-05 12:13:05 +0200 |
---|---|---|
committer | Dmitry V. Levin <ldv@strace.io> | 2024-07-02 08:00:00 +0000 |
commit | fa3295e079dbbc241906f29bde5fb71bc4172771 (patch) | |
tree | 77b6560f234c4234fade4e7a23908c492b30d05d /libpam_internal | |
parent | bc461898448a1bf306fc094cdf6a5a197c4e2753 (diff) | |
download | pam-fa3295e079dbbc241906f29bde5fb71bc4172771.tar.gz pam-fa3295e079dbbc241906f29bde5fb71bc4172771.tar.bz2 pam-fa3295e079dbbc241906f29bde5fb71bc4172771.zip |
pam_econf_readconfig: add econf_readConfigWithCallback support
Check for econf_readConfigWithCallback() and use it if available.
Co-authored-by: Dmitry V. Levin <ldv@strace.io>
Diffstat (limited to 'libpam_internal')
-rw-r--r-- | libpam_internal/pam_econf.c | 28 |
1 files changed, 27 insertions, 1 deletions
diff --git a/libpam_internal/pam_econf.c b/libpam_internal/pam_econf.c index 595c122a..b3b9874d 100644 --- a/libpam_internal/pam_econf.c +++ b/libpam_internal/pam_econf.c @@ -18,8 +18,31 @@ econf_err pam_econf_readconfig(econf_file **key_file, bool (*callback)(const char *filename, const void *data), const void *callback_data) { - econf_err ret; + econf_err ret = ECONF_SUCCESS; D(("Read configuration from directory %s and %s", etc_conf_dir, usr_conf_dir)); + +#ifdef HAVE_ECONF_READCONFIG + + char *parsing_dirs = NULL; + if (asprintf(&parsing_dirs, "PARSING_DIRS=%s:%s", usr_conf_dir, etc_conf_dir) < 0) { + ret = ECONF_NOMEM; + parsing_dirs = NULL; + } + if (ret == ECONF_SUCCESS) + ret = econf_newKeyFile_with_options(key_file, parsing_dirs); + if (ret == ECONF_SUCCESS) + ret = econf_readConfigWithCallback(key_file, + NULL, + usr_conf_dir, + config_name, + config_suffix, + delim, + comment, + callback, callback_data); + free(parsing_dirs); + +#else + ret = econf_readDirsWithCallback(key_file, usr_conf_dir, etc_conf_dir, @@ -28,6 +51,9 @@ econf_err pam_econf_readconfig(econf_file **key_file, delim, comment, callback, callback_data); + +#endif + return ret; } |