diff options
author | 2018-04-13 08:26:55 -0400 | |
---|---|---|
committer | 2018-04-13 08:26:55 -0400 | |
commit | 517b6dabdfeb9ac6aefa5c255ad6dc73ee65410f (patch) | |
tree | 2e2eea866e21d7f3484ef8efde82b5a6a6a2bfb0 /swaylock/main.c | |
parent | Merge branch 'master' of github.com:swaywm/sway (diff) | |
parent | swaylock: Securely zero-out password. (diff) | |
download | sway-517b6dabdfeb9ac6aefa5c255ad6dc73ee65410f.tar.gz sway-517b6dabdfeb9ac6aefa5c255ad6dc73ee65410f.tar.zst sway-517b6dabdfeb9ac6aefa5c255ad6dc73ee65410f.zip |
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 @@ | |||
8 | #include <stdio.h> | 8 | #include <stdio.h> |
9 | #include <stdlib.h> | 9 | #include <stdlib.h> |
10 | #include <string.h> | 10 | #include <string.h> |
11 | #include <sys/mman.h> | ||
11 | #include <sys/stat.h> | 12 | #include <sys/stat.h> |
12 | #include <time.h> | 13 | #include <time.h> |
13 | #include <unistd.h> | 14 | #include <unistd.h> |
@@ -18,10 +19,15 @@ | |||
18 | #include "background-image.h" | 19 | #include "background-image.h" |
19 | #include "pool-buffer.h" | 20 | #include "pool-buffer.h" |
20 | #include "cairo.h" | 21 | #include "cairo.h" |
22 | #include "log.h" | ||
21 | #include "util.h" | 23 | #include "util.h" |
22 | #include "wlr-input-inhibitor-unstable-v1-client-protocol.h" | 24 | #include "wlr-input-inhibitor-unstable-v1-client-protocol.h" |
23 | #include "wlr-layer-shell-unstable-v1-client-protocol.h" | 25 | #include "wlr-layer-shell-unstable-v1-client-protocol.h" |
24 | 26 | ||
27 | void sway_terminate(int exit_code) { | ||
28 | exit(exit_code); | ||
29 | } | ||
30 | |||
25 | static void daemonize() { | 31 | static void daemonize() { |
26 | int fds[2]; | 32 | int fds[2]; |
27 | if (pipe(fds) != 0) { | 33 | if (pipe(fds) != 0) { |
@@ -236,6 +242,13 @@ int main(int argc, char **argv) { | |||
236 | } | 242 | } |
237 | } | 243 | } |
238 | 244 | ||
245 | #ifdef __linux__ | ||
246 | // Most non-linux platforms require root to mlock() | ||
247 | if (mlock(state.password.buffer, sizeof(state.password.buffer)) != 0) { | ||
248 | sway_abort("Unable to mlock() password memory."); | ||
249 | } | ||
250 | #endif | ||
251 | |||
239 | wl_list_init(&state.surfaces); | 252 | wl_list_init(&state.surfaces); |
240 | state.xkb.context = xkb_context_new(XKB_CONTEXT_NO_FLAGS); | 253 | state.xkb.context = xkb_context_new(XKB_CONTEXT_NO_FLAGS); |
241 | state.display = wl_display_connect(NULL); | 254 | state.display = wl_display_connect(NULL); |