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 --- main.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'main.c') diff --git a/main.c b/main.c index f289b5e..a4279e0 100644 --- a/main.c +++ b/main.c @@ -20,6 +20,7 @@ #include "comm.h" #include "log.h" #include "loop.h" +#include "password-buffer.h" #include "pool-buffer.h" #include "seat.h" #include "swaylock.h" @@ -1187,13 +1188,12 @@ int main(int argc, char **argv) { state.args.colors.line = state.args.colors.ring; } -#ifdef __linux__ - // Most non-linux platforms require root to mlock() - if (mlock(state.password.buffer, sizeof(state.password.buffer)) != 0) { - swaylock_log(LOG_ERROR, "Unable to mlock() password memory."); + state.password.len = 0; + state.password.buffer_len = 1024; + state.password.buffer = password_buffer_create(state.password.buffer_len); + if (!state.password.buffer) { return EXIT_FAILURE; } -#endif wl_list_init(&state.surfaces); state.xkb.context = xkb_context_new(XKB_CONTEXT_NO_FLAGS); -- cgit v1.2.3