mirror of
https://gitlab.freedesktop.org/wlroots/wlroots.git
synced 2026-04-14 08:22:25 -04:00
xwayland: make X11 socket dir world-writable
The X11 socket dir must be world-writable, or else xhost usage is broken [1]. Ensure that the umask doesn't drop some permission bits from the mode we pass to mkdir(). We opt against saving/restoring umask because it's per-process global state. [1]: https://gitlab.gnome.org/GNOME/mutter/-/issues/1468
This commit is contained in:
parent
4c7c9095d9
commit
3acc448dbc
1 changed files with 24 additions and 7 deletions
|
|
@ -63,18 +63,35 @@ static bool check_socket_dir(void) {
|
|||
return true;
|
||||
}
|
||||
|
||||
static int open_socket(int display) {
|
||||
if (mkdir(socket_dir, 0755) == 0) {
|
||||
wlr_log(WLR_INFO, "Created %s ourselves -- other users will "
|
||||
"be unable to create X11 UNIX sockets of their own",
|
||||
socket_dir);
|
||||
} else if (errno != EEXIST) {
|
||||
static bool setup_socket_dir(void) {
|
||||
mode_t dir_mode = 01777;
|
||||
|
||||
if (mkdir(socket_dir, dir_mode) != 0) {
|
||||
if (errno == EEXIST) {
|
||||
return check_socket_dir();
|
||||
}
|
||||
wlr_log_errno(WLR_ERROR, "Unable to mkdir %s", socket_dir);
|
||||
return false;
|
||||
} else if (!check_socket_dir()) {
|
||||
}
|
||||
|
||||
wlr_log(WLR_INFO, "Created %s ourselves -- other users will "
|
||||
"be unable to create X11 UNIX sockets of their own",
|
||||
socket_dir);
|
||||
|
||||
// The mode passed to mkdir() is affected by umask, so set it again
|
||||
if (chmod(socket_dir, dir_mode) != 0) {
|
||||
wlr_log_errno(WLR_ERROR, "Failed to chmod %s", socket_dir);
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
static int open_socket(int display) {
|
||||
if (!setup_socket_dir()) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
struct sockaddr_un addr = { .sun_family = AF_UNIX };
|
||||
size_t path_size = snprintf(addr.sun_path, sizeof(addr.sun_path), socket_fmt, display);
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue