kathenas / rpms / mutter

Forked from rpms/mutter 5 years ago
Clone

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

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