- switch(PAM_MSG_MEMBER(msg, i, msg_style)) {
- case PAM_PROMPT_ECHO_ON:
- echo = 1;
- break;
- case PAM_PROMPT_ECHO_OFF:
- echo = 0;
- break;
- default:
- echo = 0;
- break;
- }
- if(text) {
- tmp = xmalloc(strlen(text) + strlen(PAM_MSG_MEMBER(msg, i, msg)) + 2);
- strcpy(tmp, text);
- strcat(tmp, "\n");
- strcat(tmp, PAM_MSG_MEMBER(msg, i, msg));
- xfree(text);
- text = tmp;
- tmp = NULL;
- } else {
- text = xstrdup(PAM_MSG_MEMBER(msg, i, msg));
- }
- if((PAM_MSG_MEMBER(msg, i, msg_style) == PAM_PROMPT_ECHO_ON) ||
- (PAM_MSG_MEMBER(msg, i, msg_style) == PAM_PROMPT_ECHO_OFF) ||
- (i == num_msg - 1)) {
- debug("sending prompt ssh-%d(pam-%d) = \"%s\"",
- j, i, text);
- context_pam2.prompts[j++] = i;
+ int style = PAM_MSG_MEMBER(msg, i, msg_style);
+
+ /* Skip messages which don't need a reply */
+ if (style != PAM_PROMPT_ECHO_ON && style != PAM_PROMPT_ECHO_OFF)
+ continue;
+
+ context_pam2.prompts[j++] = i;
+ if (text) {
+ message_cat(&text, PAM_MSG_MEMBER(msg, i, msg));