From 0f19e0c1450de1e72a8d3779d8bbf2a9ec2f2801 Mon Sep 17 00:00:00 2001 From: Bartosz Wieczorek Date: Wed, 15 Jan 2025 13:05:47 +0100 Subject: [PATCH] Add nonInteractiveMode option --- PAM/ssh/include/rublon/configuration.hpp | 7 +++++-- PAM/ssh/include/rublon/rublon.hpp | 2 +- PAM/ssh/include/rublon/session.hpp | 8 +++----- 3 files changed, 9 insertions(+), 8 deletions(-) diff --git a/PAM/ssh/include/rublon/configuration.hpp b/PAM/ssh/include/rublon/configuration.hpp index 6404f92..6e8ae4a 100644 --- a/PAM/ssh/include/rublon/configuration.hpp +++ b/PAM/ssh/include/rublon/configuration.hpp @@ -27,6 +27,7 @@ class Configuration { bool logging{}; bool autopushPrompt{}; FailMode failMode{}; + bool nonInteractiveMode{}; }; namespace { @@ -138,7 +139,7 @@ constexpr auto make_entry(const char * name, const char * defaultValue) { return Entry{name, defaultValue, Entry::make_read_function< member >()}; } -constexpr static inline std::array< Entry, 8 > configurationVariables = { // +constexpr static inline std::array< Entry, 9 > configurationVariables = { // make_entry< &Configuration::logging >("logging", "true"), make_entry< &Configuration::systemToken >("systemToken", nullptr), make_entry< &Configuration::secretKey >("secretKey", nullptr), @@ -146,7 +147,9 @@ constexpr static inline std::array< Entry, 8 > configurationVariables = { // make_entry< &Configuration::prompt >("prompt", "1"), make_entry< &Configuration::enablePasswdEmail >("enablePasswdEmail", "true"), make_entry< &Configuration::autopushPrompt >("autopushPrompt", "false"), - make_entry< &Configuration::failMode >("failMode", "deny")}; + make_entry< &Configuration::failMode >("failMode", "deny"), + make_entry< &Configuration::nonInteractiveMode >("nonInteractiveMode", "false") +}; class ConfigurationFactory { public: diff --git a/PAM/ssh/include/rublon/rublon.hpp b/PAM/ssh/include/rublon/rublon.hpp index ddd9e19..d30ab1d 100755 --- a/PAM/ssh/include/rublon/rublon.hpp +++ b/PAM/ssh/include/rublon/rublon.hpp @@ -21,7 +21,7 @@ class RublonFactory { return tl::unexpected{ConfigurationError{}}; } - return Session{pam, config.value(), true}; + return Session{pam, config.value()}; } }; diff --git a/PAM/ssh/include/rublon/session.hpp b/PAM/ssh/include/rublon/session.hpp index afd13ca..bf22e19 100644 --- a/PAM/ssh/include/rublon/session.hpp +++ b/PAM/ssh/include/rublon/session.hpp @@ -17,14 +17,12 @@ class Session { std::pmr::string _tid; std::pmr::string _accessToken; - bool _interactiveMode; - CoreHandler_t _coreHandler; /// TODO log /// TODO momory resource public: - Session(const Pam_t & pam, const Configuration & config, bool interactive = true) - : _pam{pam}, _config{config}, _interactiveMode{interactive}, _coreHandler{_config} { + Session(const Pam_t & pam, const Configuration & config) + : _pam{pam}, _config{config}, _coreHandler{_config} { log(LogLevel::Debug, __PRETTY_FUNCTION__); } @@ -52,7 +50,7 @@ class Session { } bool inInteractiveMode() const { - return _interactiveMode; + return _config.nonInteractiveMode == false; } void updateTransactionId(const Value * tid) {