summaryrefslogtreecommitdiff
path: root/pam.c
diff options
context:
space:
mode:
authorRobin Ebert <ebertrobin2002@gmail.com>2022-05-30 11:50:30 +0200
committerSimon Ser <contact@emersion.fr>2022-06-15 10:49:32 +0200
commitbdeb891378bfcb2dc79de41cfeb6a62807d09b20 (patch)
treea9eef0cdb2d2fba56404291ab25a0ce48402b79b /pam.c
parentfad5bc2f615bcee37b653887af0aebb334ec94b5 (diff)
Use mlock for password buffer
Diffstat (limited to 'pam.c')
-rw-r--r--pam.c9
1 files changed, 4 insertions, 5 deletions
diff --git a/pam.c b/pam.c
index 0adc9c6..0e48fcc 100644
--- a/pam.c
+++ b/pam.c
@@ -7,6 +7,7 @@
#include <unistd.h>
#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);