diff options
| author | Furkan Sahin <furkan-dev@proton.me> | 2016-01-24 14:35:28 +0200 |
|---|---|---|
| committer | Furkan Sahin <furkan-dev@proton.me> | 2016-01-24 14:35:28 +0200 |
| commit | 46e91c8082c08212559508a14e3ce68a1fbbdb54 (patch) | |
| tree | fe21fd722249bfc0ee9c8dbe4cdfcf93d763f211 /swaylock | |
| parent | 4a20c4f03cb365699fbf3ab7232686a15c0de3a3 (diff) | |
swaylock: fix pam conversation
Diffstat (limited to 'swaylock')
| -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, "PAM_TEXT_INFO", }; + /* PAM expects an array of responses, one for each message */ + struct pam_response *pam_reply = calloc(num_msg, sizeof(struct pam_response)); + *resp = pam_reply; + for(int i=0; i<num_msg; ++i) { sway_log(L_DEBUG, "msg[%d]: (%s) %s", i, msg_style_names[msg[i]->msg_style], msg[i]->msg); - } - struct pam_response *pam_reply = malloc(sizeof(struct pam_response)); - pam_reply[0].resp = password; - pam_reply[0].resp_retcode = 0; - *resp = pam_reply; + switch (msg[i]->msg_style) { + case PAM_PROMPT_ECHO_OFF: + case PAM_PROMPT_ECHO_ON: + pam_reply[i].resp = password; + break; + + case PAM_ERROR_MSG: + case PAM_TEXT_INFO: + break; + } + } return PAM_SUCCESS; } |
