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

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