From 4e6763a5914c6e61b7e05adf49e70106d8e93183 Mon Sep 17 00:00:00 2001 From: Olivier Certner Date: Mon, 8 Feb 2021 18:22:16 +0100 Subject: [PATCH] UNIX sockets: Don't unlink an existing socket before binding a new one Running the X server as root makes the unlink operation always succeed, as well as the subsequent socket binding (socket creation in the file system). But success in binding a new socket is used to detect in-use displays when specifying "-displayfd". So, when running as root, :0 is never detected as been used and its socket is systematically crushed, rendering the existing :0 session stale. Moreover, sockets are cleaned up by the X server, even in case of abnormal termination. Signed-off-by: Olivier Certner --- Xtranssock.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/Xtranssock.c b/Xtranssock.c index 632c1b5..cdddd7d 100644 --- a/Xtranssock.c +++ b/Xtranssock.c @@ -1004,8 +1004,6 @@ TRANS(SocketUNIXCreateListener) (XtransConnInfo ciptr, const char *port, sockname.sun_path[0] = '\0'; namelen = offsetof(struct sockaddr_un, sun_path) + 1 + strlen(&sockname.sun_path[1]); } - else - unlink (sockname.sun_path); if ((status = TRANS(SocketCreateListener) (ciptr, (struct sockaddr *) &sockname, namelen, flags)) < 0) -- GitLab