From d13a6b4df2522ffc6e90682bd96a7168fc12d19d Mon Sep 17 00:00:00 2001 From: Peter Hutterer Date: Fri, 17 Apr 2026 15:16:13 +1000 Subject: [PATCH] eis: fix missing file type check on socket path When setting up the EIS socket, the code checked if the socket path already existed and, if so, unlinked it to clean up a stale socket from a previous unclean shutdown. But we didn't actually check whether it's a socket before unlinking. Assisted-by: Claude:claude-opus-4-6 Part-of: --- src/libeis-socket.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/libeis-socket.c b/src/libeis-socket.c index 5ce918b..71fc2aa 100644 --- a/src/libeis-socket.c +++ b/src/libeis-socket.c @@ -165,8 +165,14 @@ eis_setup_backend_socket(struct eis *eis, const char *socketpath) log_error(eis, "Failed to stat socket path %s (%s)", path, strerror(errno)); return -errno; } - } else if (st.st_mode & (S_IWUSR | S_IWGRP)) { + } else if (S_ISSOCK(st.st_mode)) { unlink(path); + } else if (S_ISREG(st.st_mode) || S_ISLNK(st.st_mode) || S_ISDIR(st.st_mode)) { + log_error(eis, + "Socket path %s exists but is not a socket (mode 0%o)", + path, + st.st_mode); + return -EEXIST; } /* Lockfile succeeded and path is unlinked (if it existed), let's set