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

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