diff options
author | emersion <contact@emersion.fr> | 2018-04-13 08:26:55 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-04-13 08:26:55 -0400 |
commit | 517b6dabdfeb9ac6aefa5c255ad6dc73ee65410f (patch) | |
tree | 2e2eea866e21d7f3484ef8efde82b5a6a6a2bfb0 /swaylock/main.c | |
parent | 200d0360ea3fb2c68a6b92ff3cf0249d54457b88 (diff) | |
parent | ad6aa21c43bb87c917e21416f3ba448b634a98f8 (diff) |
Merge pull request #1803 from ggreer/swaylock-secure-password
swaylock: Securely zero-out password.
Diffstat (limited to 'swaylock/main.c')
-rw-r--r-- | swaylock/main.c | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/swaylock/main.c b/swaylock/main.c index 4c6b44c6..200c1b5f 100644 --- a/swaylock/main.c +++ b/swaylock/main.c @@ -8,6 +8,7 @@ #include <stdio.h> #include <stdlib.h> #include <string.h> +#include <sys/mman.h> #include <sys/stat.h> #include <time.h> #include <unistd.h> @@ -18,10 +19,15 @@ #include "background-image.h" #include "pool-buffer.h" #include "cairo.h" +#include "log.h" #include "util.h" #include "wlr-input-inhibitor-unstable-v1-client-protocol.h" #include "wlr-layer-shell-unstable-v1-client-protocol.h" +void sway_terminate(int exit_code) { + exit(exit_code); +} + static void daemonize() { int fds[2]; if (pipe(fds) != 0) { @@ -236,6 +242,13 @@ int main(int argc, char **argv) { } } +#ifdef __linux__ + // Most non-linux platforms require root to mlock() + if (mlock(state.password.buffer, sizeof(state.password.buffer)) != 0) { + sway_abort("Unable to mlock() password memory."); + } +#endif + wl_list_init(&state.surfaces); state.xkb.context = xkb_context_new(XKB_CONTEXT_NO_FLAGS); state.display = wl_display_connect(NULL); |