mutter/SOURCES/0002-xwayland-Make-sure-tmp-.X11-unix-exists.patch

91 lines
2.7 KiB
Diff
Raw Normal View History

2021-05-18 06:37:53 +00:00
From 56c2e4efdcef14531dcf752e89117d22a21ec8ad Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Jonas=20=C3=85dahl?= <jadahl@gmail.com>
Date: Wed, 9 Dec 2020 15:18:29 +0100
Subject: [PATCH 2/2] xwayland: Make sure /tmp/.X11-unix/ exists
When we're running under a polyinstantiated SELinux environment, we'll
likely start with an isolated and empty /tmp, meannig no /tmp/.X11-unix
directory to add things to. To make it possible to still function in
this kind of setup, make sure said directory exists.
---
src/wayland/meta-xwayland.c | 30 ++++++++++++++++++++++++++++--
1 file changed, 28 insertions(+), 2 deletions(-)
diff --git a/src/wayland/meta-xwayland.c b/src/wayland/meta-xwayland.c
index 699d5561c..f3df9766e 100644
--- a/src/wayland/meta-xwayland.c
+++ b/src/wayland/meta-xwayland.c
@@ -30,6 +30,7 @@
#include <glib-unix.h>
#include <glib.h>
#include <sys/socket.h>
+#include <sys/stat.h>
#include <sys/un.h>
#include "compositor/meta-surface-actor-wayland.h"
@@ -436,9 +437,27 @@ meta_xwayland_override_display_number (int number)
display_number_override = number;
}
+static gboolean
+ensure_x11_unix_dir (GError **error)
+{
+ if (mkdir ("/tmp/.X11-unix", 01777) != 0)
+ {
+ if (errno == EEXIST)
+ return TRUE;
+
+ g_set_error (error, G_IO_ERROR, g_io_error_from_errno (errno),
+ "Failed to create directory \"/tmp/.X11-unix\": %s",
+ g_strerror (errno));
+ return FALSE;
+ }
+
+ return TRUE;
+}
+
static gboolean
choose_xdisplay (MetaXWaylandManager *manager)
{
+ g_autoptr (GError) error = NULL;
int display = 0;
char *lock_file = NULL;
@@ -447,10 +466,15 @@ choose_xdisplay (MetaXWaylandManager *manager)
else if (g_getenv ("RUNNING_UNDER_GDM"))
display = 1024;
- do
+ if (!ensure_x11_unix_dir (&error))
{
- g_autoptr (GError) error = NULL;
+ g_warning ("Failed to ensure X11 socket directory: %s",
+ error->message);
+ return FALSE;
+ }
+ do
+ {
lock_file = create_lock_file (display, &display, &error);
if (!lock_file)
{
@@ -466,6 +490,7 @@ choose_xdisplay (MetaXWaylandManager *manager)
if (g_error_matches (error, G_IO_ERROR, G_IO_ERROR_ADDRESS_IN_USE))
{
meta_verbose ("Failed to bind abstract socket: %s\n", error->message);
+ g_clear_error (&error);
display++;
continue;
}
@@ -480,6 +505,7 @@ choose_xdisplay (MetaXWaylandManager *manager)
if (manager->unix_fd < 0)
{
meta_verbose ("Failed to bind unix socket: %s\n", error->message);
+ g_clear_error (&error);
unlink (lock_file);
close (manager->abstract_fd);
display++;
--
2.29.2