* Add phone call authentication method * Remove dynamic mem allocation from error handler * Add more error handling code * Move error handling to different file * Remove Socket IO dependency * cleanup in websocket code * Add rapidjson as cmake dependency * Added Dockerfiles as primary build system for packages * Changed policy in CMakeList to work with lower version of CMake * Fix opensuse builds * Link filesystem library in gcc 8.5 or older
47 lines
1.2 KiB
C++
47 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 *) >();
|
|
}
|
|
};
|
|
} // namespace rublon
|