From 7729f97c187e115a9094c79c3da9179ccfa60410 Mon Sep 17 00:00:00 2001 From: MusiKid Date: Sun, 23 Jan 2022 14:32:35 +0100 Subject: [PATCH] fix: remove absolute path for `posix_spawnp` We also set the file_actions to `nullptr`. --- src/pam/main.cc | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/src/pam/main.cc b/src/pam/main.cc index 15ce574..5dc5b61 100644 --- a/src/pam/main.cc +++ b/src/pam/main.cc @@ -112,7 +112,7 @@ auto howdy_error(int status, * @param conv_function PAM conversation function * @return Returns the conversation function return code */ -auto howdy_msg(char *username, int status, INIReader &reader, + auto howdy_msg(char *username, int status, const INIReader &reader, const std::function &conv_function) -> int { if (status != EXIT_SUCCESS) { @@ -155,12 +155,13 @@ auto identify(pam_handle_t *pamh, int flags, int argc, const char **argv, auth_tok = false; } + // Will contain the responses from PAM functions + int pam_res = PAM_IGNORE; + // Will contain PAM conversation structure struct pam_conv *conv = nullptr; const void **conv_ptr = const_cast(reinterpret_cast(&conv)); - // Will contain the responses from PAM functions - int pam_res = PAM_IGNORE; // Try to get the conversation function and error out if we can't if ((pam_res = pam_get_item(pamh, PAM_CONV, conv_ptr)) != PAM_SUCCESS) { @@ -255,16 +256,13 @@ auto identify(pam_handle_t *pamh, int flags, int argc, const char **argv, return pam_res; } - posix_spawn_file_actions_t file_actions; - posix_spawn_file_actions_init(&file_actions); - - const char *const args[] = {"/usr/bin/python3", // NOLINT + const char *const args[] = {"python3", // NOLINT "/lib/security/howdy/compare.py", username, nullptr}; pid_t child_pid; // Start the python subprocess - if (posix_spawnp(&child_pid, "/usr/bin/python3", &file_actions, nullptr, + if (posix_spawnp(&child_pid, "python3", nullptr, nullptr, const_cast(args), nullptr) > 0) { syslog(LOG_ERR, "Can't spawn the howdy process: %s (%d)", strerror(errno), errno);