diff --git a/PAM/ssh/include/rublon/error.hpp b/PAM/ssh/include/rublon/error.hpp index dd85c40..bc3474f 100755 --- a/PAM/ssh/include/rublon/error.hpp +++ b/PAM/ssh/include/rublon/error.hpp @@ -224,6 +224,41 @@ class RublonCheckApplicationException { ErrorClass errorClass; }; + +class RublonRuntimeException { + public: + enum ErrorClass { + CantCreateSocket, + ConnectionFailed, + CantGetSocketName, + CantReadLocalIP + }; + + constexpr static auto errorClassPrettyName = make_array< std::string_view >( // + "CantCreateSocket", + "ConnectionFailed", + "CantGetSocketName", + "CantReadLocalIP"); + constexpr static auto prettyName = "Rublon Runtime Exception"; + + RublonRuntimeException(ErrorClass e = CantReadLocalIP) : errorClass{e} {} + + constexpr const char * what() const { + return errorClassPrettyName[static_cast< int >(errorClass)].data(); + } + + static std::optional< RublonRuntimeException > fromString(std::string_view name) { + for(std::size_t i{}; i < errorClassPrettyName.size(); i++) { + if(errorClassPrettyName.at(i) == name) { + return std::make_optional(RublonRuntimeException{static_cast< ErrorClass >(i)}); + } + } + return std::nullopt; + } + + ErrorClass errorClass; +}; + class Error { using Error_t = std::variant< ConfigurationError, CoreHandlerError, @@ -231,7 +266,8 @@ class Error { WerificationError, MethodError, RublonAuthenticationInterrupt, - RublonCheckApplicationException >; + RublonCheckApplicationException, + RublonRuntimeException >; Error_t _error; public: @@ -242,7 +278,8 @@ class Error { k_WerificationError, k_MethodError, k_RublonAuthenticationInterrupt, - k_RublonCheckApplication + k_RublonCheckApplication, + k_RublonRuntimeException }; Error() = default; @@ -254,6 +291,7 @@ class Error { Error(WerificationError error) : _error{error} {} Error(RublonAuthenticationInterrupt error) : _error{error} {} Error(RublonCheckApplicationException error) : _error{error} {} + Error(RublonRuntimeException error) : _error{error} {} Error(const Error &) = default; Error(Error &&) = default; diff --git a/PAM/ssh/include/rublon/rublon.hpp b/PAM/ssh/include/rublon/rublon.hpp index ba7b748..bc36954 100755 --- a/PAM/ssh/include/rublon/rublon.hpp +++ b/PAM/ssh/include/rublon/rublon.hpp @@ -12,7 +12,7 @@ namespace rublon { class RublonFactory { public: - tl::expected< void, Error > initializeSession(Session & session, int flags, int argc, const char ** argv) { + tl::expected< void, Error > initializeSession(Session & session, [[maybe_unused]]int flags, int argc, const char ** argv) { log(LogLevel::Debug, "Configuration read start"); memory::MonotonicStack_2k_Resource memory_resource; ConfigurationReader reader{&memory_resource, "/etc/rublon.config", argc, argv}; diff --git a/service/helpers/postinst b/service/helpers/postinst index ada7656..df1a9b4 100644 --- a/service/helpers/postinst +++ b/service/helpers/postinst @@ -9,14 +9,14 @@ if [ ! -f $RUBLON_CONFIG ] then cp -a /usr/share/rublon/rublon.config.defaults $RUBLON_CONFIG chown root:root $RUBLON_CONFIG - chmod 640 $RUBLON_CONFIG + chmod 644 $RUBLON_CONFIG fi if [ ! -f $RUBLON_SSH_CONFIG ] then cp -a /usr/share/rublon/01-rublon-ssh.conf.default $RUBLON_SSH_CONFIG chown root:root $RUBLON_SSH_CONFIG - chmod 640 $RUBLON_SSH_CONFIG + chmod 644 $RUBLON_SSH_CONFIG fi if [ -f /etc/os-release ]