summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristoph Gysin <christoph.gysin@gmail.com>2016-01-24 13:33:24 +0200
committerChristoph Gysin <christoph.gysin@gmail.com>2016-01-25 19:43:51 +0200
commita17033fdd2acba9772d27ad858e801c63703b7c3 (patch)
tree9f54b089247a2fb5c2f39088fdb52104049cc6a9
parent7b74002576d4ca31c20698e729cba29deb8f65b1 (diff)
swaylock: remove global variable pam_reply
-rw-r--r--main.c9
1 files changed, 5 insertions, 4 deletions
diff --git a/main.c b/main.c
index c01445e..e04d0d6 100644
--- a/main.c
+++ b/main.c
@@ -36,11 +36,15 @@ void sway_terminate(void) {
}
char *password;
-struct pam_response *pam_reply;
int function_conversation(int num_msg, const struct pam_message **msg,
struct pam_response **resp, void *appdata_ptr) {
+
+ struct pam_response *pam_reply = malloc(sizeof(struct pam_response));
+ pam_reply[0].resp = password;
+ pam_reply[0].resp_retcode = 0;
*resp = pam_reply;
+
return PAM_SUCCESS;
}
@@ -57,9 +61,6 @@ bool verify_password(char *password) {
if ((pam_err = pam_start("swaylock", username, &local_conversation, &local_auth_handle)) != PAM_SUCCESS) {
sway_abort("PAM returned %d\n", pam_err);
}
- pam_reply = (struct pam_response *)malloc(sizeof(struct pam_response));
- pam_reply[0].resp = password;
- pam_reply[0].resp_retcode = 0;
if ((pam_err = pam_authenticate(local_auth_handle, 0)) != PAM_SUCCESS) {
memset(password, 0, strlen(password));
return false;