From bdeb891378bfcb2dc79de41cfeb6a62807d09b20 Mon Sep 17 00:00:00 2001 From: Robin Ebert Date: Mon, 30 May 2022 11:50:30 +0200 Subject: Use mlock for password buffer --- pam.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) (limited to 'pam.c') diff --git a/pam.c b/pam.c index 0adc9c6..0e48fcc 100644 --- a/pam.c +++ b/pam.c @@ -7,6 +7,7 @@ #include #include "comm.h" #include "log.h" +#include "password-buffer.h" #include "swaylock.h" static char *pw_buf = NULL; @@ -96,6 +97,9 @@ void run_pw_backend_child(void) { } int pam_status = pam_authenticate(auth_handle, 0); + password_buffer_destroy(pw_buf, size); + pw_buf = NULL; + bool success = pam_status == PAM_SUCCESS; if (!success) { swaylock_log(LOG_ERROR, "pam_authenticate failed: %s", @@ -103,13 +107,8 @@ void run_pw_backend_child(void) { } if (!write_comm_reply(success)) { - clear_buffer(pw_buf, size); exit(EXIT_FAILURE); } - - clear_buffer(pw_buf, size); - free(pw_buf); - pw_buf = NULL; } pam_setcred(auth_handle, PAM_REFRESH_CRED); -- cgit v1.2.3