7699d7ec | #include <security/pam_modules.h> |
01c00cfe | #include <algorithm> #include <vector> #include <string> |
7699d7ec | #include "conversation.h" |
01c00cfe | #include "pam.h" |
7699d7ec | |
01c00cfe | pam_token_conversation::pam_token_conversation(pam_handle_t *pamh, const pam_p pam) { pam_conversation_p pam_conversation; |
662f2d36 | int conversation_result = pam->get_conversation(pamh, pam_conversation); if (conversation_result != 0) { return; } |
0b6e39a6 | |
01c00cfe | const std::vector<const struct pam_message *> prompts(1); std::vector<struct pam_response *> answers(1); pam_conversation->conv(prompts, answers); std::string answer(answers[0]->resp); std::string::iterator delim = std::find(answer.begin(), answer.end(), ':'); |
24888e2d | if (delim == answer.end()) { return; } |
01c00cfe | std::string user_name(answer.begin(), delim); std::string token(delim + 1, answer.end()); user_ = user_name; token_ = token; } |
0b6e39a6 | std::string pam_token_conversation::token() { |
01c00cfe | return token_; |
7699d7ec | } |
be7b0e04 | std::string pam_token_conversation::user_name() { |
01c00cfe | return user_; |
be7b0e04 | } |