rublon-ssh/PAM/ssh/include/rublon/pam_stub.hpp
rublon-bwi 351964199a
Bwi/v2.3.2 (#19)
* Prevent printing in noninteractive mode

* Allow PAM modules to be configurated directly in pam.d

* Configuration should be redable by everybody

* Add a way to read ip address in when no IP is awailable

* Enable read ip from pam

* Fix veritas BUG
2025-09-11 10:35:22 +02:00

51 lines
1.2 KiB
C++

#pragma once
#include <iostream>
#include <rublon/non_owning_ptr.hpp>
#include <rublon/utils.hpp>
namespace rublon {
class PamStub {
public:
rublon::NonOwningPtr< const char > ip() const {
const void * ip = "127.0.0.1";
return ( const char * ) ip;
}
rublon::NonOwningPtr< const char > username() const {
const char * user = "bwi";
return user;
}
template < typename... Ti >
void print(const char * fmt, Ti... ti) const noexcept {
char buf[256] = {};
sprintf(buf, fmt, std::forward< Ti >(ti)...);
log(LogLevel::Debug, "pam_print: '%s'", buf);
printf(fmt, std::forward< Ti >(ti)...);
printf("\n");
}
template < typename Fun, typename... Ti >
auto scan(Fun && f, const char * fmt, Ti... ti) const noexcept {
std::string response;
char buf[256] = {};
sprintf(buf, fmt, std::forward< Ti >(ti)...);
std::getline(std::cin, response);
if(!response.empty()) {
auto ret = f(response.c_str());
return ret;
}
return std::result_of_t< Fun(char *) >();
}
void enableNoninteractive(){
}
};
} // namespace rublon