From a92a3aade297309ce24ca2cc2c604673d066abb1 Mon Sep 17 00:00:00 2001 From: Sayafdine Said Date: Sun, 25 Jun 2023 17:13:12 +0200 Subject: [PATCH] feat: add config path to PAM module --- howdy/src/meson.build | 8 ++++++-- howdy/src/pam/main.cc | 2 +- howdy/src/pam/meson.build | 4 +--- howdy/src/pam/paths.hh.in | 3 ++- 4 files changed, 10 insertions(+), 7 deletions(-) diff --git a/howdy/src/meson.build b/howdy/src/meson.build index f068fa9..2fc7ec8 100644 --- a/howdy/src/meson.build +++ b/howdy/src/meson.build @@ -9,6 +9,8 @@ usermodelsdir = get_option('user_models_dir') != '' ? get_option('user_models_di datadir = get_option('data_dir') != '' ? get_option('data_dir') : join_paths(get_option('prefix'), get_option('datadir'), 'howdy') logpath = get_option('log_path') +config_path = join_paths(confdir, 'config.ini') + py_conf = configuration_data({ 'config_dir': confdir, 'dlib_data_dir': dlibdatadir, @@ -57,7 +59,10 @@ else pysourcesinstalldir = get_option('py_sources_dir') != '' ? get_option('py_sources_dir') : join_paths(get_option('prefix'), get_option('libdir'), 'howdy') endif -compare_script_path = join_paths(pysourcesinstalldir, 'compare.py') +pam_module_conf_data = configuration_data({ + 'compare_script_path': join_paths(pysourcesinstalldir, 'compare.py') , + 'config_file_path': config_path, +}) subdir('pam') if get_option('install_in_site_packages') @@ -81,7 +86,6 @@ endif install_data('logo.png', install_tag: 'meta') fs = import('fs') -config_path = join_paths(confdir, 'config.ini') if not fs.exists(config_path) install_data('config.ini', install_dir: confdir, install_mode: 'rwxr--r--', install_tag: 'config') endif diff --git a/howdy/src/pam/main.cc b/howdy/src/pam/main.cc index 2f7a996..05c54d9 100644 --- a/howdy/src/pam/main.cc +++ b/howdy/src/pam/main.cc @@ -197,7 +197,7 @@ auto check_enabled(const INIReader &config) -> int { */ auto identify(pam_handle_t *pamh, int flags, int argc, const char **argv, bool auth_tok) -> int { - INIReader config("/etc/howdy/config.ini"); + INIReader config(CONFIG_FILE_PATH); openlog("pam_howdy", 0, LOG_AUTHPRIV); // Error out if we could not read the config file diff --git a/howdy/src/pam/meson.build b/howdy/src/pam/meson.build index 39959dc..fa04f7b 100644 --- a/howdy/src/pam/meson.build +++ b/howdy/src/pam/meson.build @@ -7,12 +7,10 @@ threads = dependency('threads') subdir('po') # Paths -paths = { 'compare_script_path': compare_script_path } - paths_h = configure_file( input: 'paths.hh.in', output: 'paths.hh', - configuration: paths, + configuration: pam_module_conf_data, install_dir: get_option('pam_dir') ) diff --git a/howdy/src/pam/paths.hh.in b/howdy/src/pam/paths.hh.in index df21928..055e0d4 100644 --- a/howdy/src/pam/paths.hh.in +++ b/howdy/src/pam/paths.hh.in @@ -1 +1,2 @@ -const auto COMPARE_PROCESS_PATH = "@compare_script_path@"; \ No newline at end of file +const auto COMPARE_PROCESS_PATH = "@compare_script_path@"; +const auto CONFIG_FILE_PATH = "@config_file_path@"; \ No newline at end of file