diff options
Diffstat (limited to 'swaylock/main.c')
-rw-r--r-- | swaylock/main.c | 20 |
1 files changed, 15 insertions, 5 deletions
diff --git a/swaylock/main.c b/swaylock/main.c index ca3453ff..e6095d35 100644 --- a/swaylock/main.c +++ b/swaylock/main.c | |||
@@ -48,16 +48,26 @@ int function_conversation(int num_msg, const struct pam_message **msg, | |||
48 | "PAM_TEXT_INFO", | 48 | "PAM_TEXT_INFO", |
49 | }; | 49 | }; |
50 | 50 | ||
51 | /* PAM expects an array of responses, one for each message */ | ||
52 | struct pam_response *pam_reply = calloc(num_msg, sizeof(struct pam_response)); | ||
53 | *resp = pam_reply; | ||
54 | |||
51 | for(int i=0; i<num_msg; ++i) { | 55 | for(int i=0; i<num_msg; ++i) { |
52 | sway_log(L_DEBUG, "msg[%d]: (%s) %s", i, | 56 | sway_log(L_DEBUG, "msg[%d]: (%s) %s", i, |
53 | msg_style_names[msg[i]->msg_style], | 57 | msg_style_names[msg[i]->msg_style], |
54 | msg[i]->msg); | 58 | msg[i]->msg); |
55 | } | ||
56 | 59 | ||
57 | struct pam_response *pam_reply = malloc(sizeof(struct pam_response)); | 60 | switch (msg[i]->msg_style) { |
58 | pam_reply[0].resp = password; | 61 | case PAM_PROMPT_ECHO_OFF: |
59 | pam_reply[0].resp_retcode = 0; | 62 | case PAM_PROMPT_ECHO_ON: |
60 | *resp = pam_reply; | 63 | pam_reply[i].resp = password; |
64 | break; | ||
65 | |||
66 | case PAM_ERROR_MSG: | ||
67 | case PAM_TEXT_INFO: | ||
68 | break; | ||
69 | } | ||
70 | } | ||
61 | 71 | ||
62 | return PAM_SUCCESS; | 72 | return PAM_SUCCESS; |
63 | } | 73 | } |