Single PAM conversation with multiple messages

Viewed 324

I'm helping build a pluggable access module. Our module initially implemented a PAM conversation with only one message, and it worked fine. We then had a need to add a second message to the conversation, and thought it would be simple enough to increment num_msg by one and pass in the necessary pointers.

However, with the below code, PAM now returns an error after the user responds to the first prompt. (The error is a pam session error, oddly enough, even though that isn't listed as a response type for the conv function.)

Splitting the prompts into two different conversation objects works fine, but I'd like to be able to add multiple prompts into the same conversation. Googling reveals that bad behavior may be expected with multiple messages in one conversation, though I could not find anything concrete. Any thoughts on what's going on here or what I am missing?

pam_message first_message;
first_message.msg = const_cast<char *> ("First prompt: ");
first.msg_style = PAM_PROMPT_ECHO_OFF;
pam_message second_message;
second_message.msg = const_cast<char *> ("Second prompt: ");
second_message.msg_style = PAM_PROMPT_ECHO_OFF;

std::vector<const pam_message *> messages;
messages.push_back (&first_message);
messages.push_back (&second_message);
std::vector<pam_response *> responses (2);

int conv_result = conv->conv (2, messages.data(), responses.data(),
                              conv->appdata_ptr);
0 Answers
Related