aboutsummaryrefslogtreecommitdiff
path: root/libpam_internal
diff options
context:
space:
mode:
authorStefan Schubert <schubi@suse.de>2024-06-27 16:06:36 +0200
committerDmitry V. Levin <ldv@strace.io>2024-07-02 08:00:00 +0000
commitbc461898448a1bf306fc094cdf6a5a197c4e2753 (patch)
tree03a14e47e3cbdfbe55e15aee53a2183700dd9737 /libpam_internal
parentefa6e33b1da594f2a2c4c2c8871416a3d5011015 (diff)
downloadpam-bc461898448a1bf306fc094cdf6a5a197c4e2753.tar.gz
pam-bc461898448a1bf306fc094cdf6a5a197c4e2753.tar.bz2
pam-bc461898448a1bf306fc094cdf6a5a197c4e2753.zip
libpam_internal: introduce pam_econf_readconfig
Use this new function instead of econf_readDirs() and econf_readDirsWithCallback(). Co-authored-by: Dmitry V. Levin <ldv@strace.io>
Diffstat (limited to 'libpam_internal')
-rw-r--r--libpam_internal/Makefile.am8
-rw-r--r--libpam_internal/include/pam_econf.h22
-rw-r--r--libpam_internal/pam_econf.c34
3 files changed, 61 insertions, 3 deletions
diff --git a/libpam_internal/Makefile.am b/libpam_internal/Makefile.am
index 1078cf0f..b368ebc8 100644
--- a/libpam_internal/Makefile.am
+++ b/libpam_internal/Makefile.am
@@ -1,10 +1,12 @@
noinst_LTLIBRARIES = libpam_internal.la
-noinst_HEADERS = include/pam_line.h
+noinst_HEADERS = include/pam_line.h include/pam_econf.h
AM_CFLAGS = -I$(top_srcdir)/libpam_internal/include \
- -I$(top_srcdir)/libpam/include $(WARN_CFLAGS)
+ -I$(top_srcdir)/libpam/include $(WARN_CFLAGS) \
+ $(ECONF_CFLAGS)
libpam_internal_la_SOURCES = \
pam_debug.c \
- pam_line.c
+ pam_line.c \
+ pam_econf.c
diff --git a/libpam_internal/include/pam_econf.h b/libpam_internal/include/pam_econf.h
new file mode 100644
index 00000000..ebba659d
--- /dev/null
+++ b/libpam_internal/include/pam_econf.h
@@ -0,0 +1,22 @@
+/* pam_econf.h -- routines to parse configuration files with libeconf */
+
+#ifndef PAM_ECONF_H
+#define PAM_ECONF_H
+
+#ifdef USE_ECONF
+
+#include <libeconf.h>
+
+econf_err pam_econf_readconfig(econf_file **key_file,
+ const char *usr_conf_dir,
+ const char *etc_conf_dir,
+ const char *config_name,
+ const char *config_suffix,
+ const char *delim,
+ const char *comment,
+ bool (*callback)(const char *filename, const void *data),
+ const void *callback_data);
+
+#endif /* USE_ECONF */
+
+#endif /* PAM_ECONF_H */
diff --git a/libpam_internal/pam_econf.c b/libpam_internal/pam_econf.c
new file mode 100644
index 00000000..595c122a
--- /dev/null
+++ b/libpam_internal/pam_econf.c
@@ -0,0 +1,34 @@
+/* pam_econf.c -- routines to parse configuration files with libeconf */
+
+#include "config.h"
+
+#ifdef USE_ECONF
+
+#include <stdio.h>
+#include <security/_pam_macros.h>
+#include "pam_econf.h"
+
+econf_err pam_econf_readconfig(econf_file **key_file,
+ const char *usr_conf_dir,
+ const char *etc_conf_dir,
+ const char *config_name,
+ const char *config_suffix,
+ const char *delim,
+ const char *comment,
+ bool (*callback)(const char *filename, const void *data),
+ const void *callback_data)
+{
+ econf_err ret;
+ D(("Read configuration from directory %s and %s", etc_conf_dir, usr_conf_dir));
+ ret = econf_readDirsWithCallback(key_file,
+ usr_conf_dir,
+ etc_conf_dir,
+ config_name,
+ config_suffix,
+ delim,
+ comment,
+ callback, callback_data);
+ return ret;
+}
+
+#endif /* USE_ECONF */