eis: restrict our socket to owner-only

Depending on the umask our socket may be group/world-accessible, let's
not do that because if the current state of the world tells us anything
it is that we can't trust it.

Assisted-by: Claude:claude-opus-4-6
Part-of: <https://gitlab.freedesktop.org/libinput/libei/-/merge_requests/388>
This commit is contained in:
Peter Hutterer 2026-04-17 18:55:43 +10:00 committed by Marge Bot
parent 2b9b001db9
commit c352f16b4a

View file

@ -181,6 +181,10 @@ eis_setup_backend_socket(struct eis *eis, const char *socketpath)
if (bind(sockfd, (struct sockaddr *)&addr, sizeof(addr)) == -1)
return -errno;
/* Restrict socket to owner-only access regardless of umask */
if (fchmod(sockfd, S_IRUSR | S_IWUSR) == -1)
return -errno;
if (listen(sockfd, 2) == -1)
return -errno;