diff --git a/PAM/ssh/include/rublon/curl.hpp b/PAM/ssh/include/rublon/curl.hpp index b42b2fe..458a0c6 100644 --- a/PAM/ssh/include/rublon/curl.hpp +++ b/PAM/ssh/include/rublon/curl.hpp @@ -104,7 +104,7 @@ class CURL { curl_easy_setopt(curl.get(), CURLOPT_HTTPHEADER, curl_headers.get()); curl_easy_setopt(curl.get(), CURLOPT_POST, 1); curl_easy_setopt(curl.get(), CURLOPT_POSTFIELDS, request.body.data()); - curl_easy_setopt(curl.get(), CURLOPT_POSTFIELDSIZE, static_cast< u_int32_t >(request.body.size())); + curl_easy_setopt(curl.get(), CURLOPT_POSTFIELDSIZE, static_cast< uint32_t >(request.body.size())); curl_easy_setopt(curl.get(), CURLOPT_HEADER, 1); curl_easy_setopt(curl.get(), CURLOPT_WRITEFUNCTION, WriteMemoryCallback); curl_easy_setopt(curl.get(), CURLOPT_WRITEDATA, &response_data); diff --git a/PAM/ssh/include/rublon/method/passcode_based_auth.hpp b/PAM/ssh/include/rublon/method/passcode_based_auth.hpp index ce1c7a5..1d04c40 100644 --- a/PAM/ssh/include/rublon/method/passcode_based_auth.hpp +++ b/PAM/ssh/include/rublon/method/passcode_based_auth.hpp @@ -30,7 +30,7 @@ class PasscodeBasedAuth : public AuthenticationStep { const bool _onlyDigits; int _prompts; - constexpr static bool isdigit(char ch) { + static bool isdigit(char ch) { return std::isdigit(static_cast< unsigned char >(ch)); } diff --git a/PAM/ssh/include/rublon/pam.hpp b/PAM/ssh/include/rublon/pam.hpp index e53dbbd..9ca0d6e 100644 --- a/PAM/ssh/include/rublon/pam.hpp +++ b/PAM/ssh/include/rublon/pam.hpp @@ -1,7 +1,47 @@ #pragma once +#ifdef __sun +#include +#include +#include +#include +#include +static int pam_vprompt_compat(pam_handle_t *pamh, int style, char **out, + const char *fmt, va_list ap) { + const struct pam_conv *conv = NULL; + if (pam_get_item(pamh, PAM_CONV, (void **)&conv) != PAM_SUCCESS || !conv || !conv->conv) + return PAM_SYSTEM_ERR; + + char buf[1024]; + vsnprintf(buf, sizeof(buf), fmt, ap); + + struct pam_message msg = { .msg_style = style, .msg = buf }; + struct pam_message *pmsg[1] = { &msg }; + struct pam_response *resp = NULL; + + int r = conv->conv(1, pmsg, &resp, conv->appdata_ptr); + if (r != PAM_SUCCESS) return r; + + if (out) { + if (resp && resp[0].resp) *out = resp[0].resp; else *out = NULL; + } + if (resp) free(resp); // NIE zwalniaj *out; zwolni to wywołujący + return PAM_SUCCESS; +} + +static int pam_prompt_compat(pam_handle_t *pamh, int style, char **out, const char *fmt, ...) { + va_list ap; va_start(ap, fmt); + int r = pam_vprompt_compat(pamh, style, out, fmt, ap); + va_end(ap); + return r; +} + +#define pam_prompt pam_prompt_compat + +#else #include #include +#endif #include #include @@ -20,21 +60,29 @@ class LinuxPam { } rublon::NonOwningPtr< const char > ip() const { +#ifdef __sun + void * ip = NULL; +#else const void * ip = NULL; +#endif pam_get_item(pamh, PAM_RHOST, &ip); if(ip == NULL) { rublon::log(rublon::LogLevel::Warning, "Cant read ip from linux PAM"); - ip = ""; + return ""; } return ( const char * ) ip; } rublon::NonOwningPtr< const char > username() const { +#ifdef __sun + char * user = NULL; +#else const char * user = NULL; +#endif pam_get_user(pamh, &user, nullptr); if(user == NULL) { rublon::log(rublon::LogLevel::Warning, "Cant read user from linux PAM"); - user = ""; + return ""; } return user; }