From 9e14e43bd822bbcfdbaeefc667a4a59127c0ecff Mon Sep 17 00:00:00 2001 From: Uli Schlachter Date: Sun, 6 Dec 2020 09:53:59 +0100 Subject: [PATCH] Fix writing /tmp/.X{}.lock Here is a lock file not created by smithay: $ xxd /tmp/.X0-lock 00000000: 2020 2020 2020 2035 3537 0a 557. And this is a lock file created by smithay: $ xxd /tmp/.X23-lock 00000000: 2020 2020 3130 3733 3332 107332 As you see, the difference is a trailing newline (0x0a). Lock files 1 to 22 where also created by smithay, because I started it a couple of times. Reading these lock files fails, since the code expects a file with at least 11 bytes of content: It uses read_exact() with a buffer of length 11 in the Err()-branch of the match that this commit modifies. Signed-off-by: Uli Schlachter --- src/xwayland/x11_sockets.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/xwayland/x11_sockets.rs b/src/xwayland/x11_sockets.rs index 3a497e3..290a2ff 100644 --- a/src/xwayland/x11_sockets.rs +++ b/src/xwayland/x11_sockets.rs @@ -38,7 +38,7 @@ impl X11Lock { match lockfile { Ok(mut file) => { // we got it, write our PID in it and we're good - let ret = file.write_fmt(format_args!("{:>10}", ::nix::unistd::Pid::this())); + let ret = file.write_fmt(format_args!("{:>10}\n", ::nix::unistd::Pid::this())); if ret.is_err() { // write to the file failed ? we abandon ::std::mem::drop(file);