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: <https://gitlab.freedesktop.org/libinput/libei/-/merge_requests/389>
This commit is contained in:
Peter Hutterer 2026-04-17 15:16:13 +10:00
parent bca07c3dc0
commit d13a6b4df2

View file

@ -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