[mutter] xwayland: Add local user to xhost



commit eac227a203dba4d45398dfb85ec5b4610b5f3be7
Author: Olivier Fourdan <ofourdan redhat com>
Date:   Mon Aug 19 15:50:54 2019 +0200

    xwayland: Add local user to xhost
    
    With the addition of xauth support (commit a8984a81c), Xwayland would
    rely only on the provided cookies for authentication.
    
    As a result, running an Xclient from another VT (hence without the
    XAUTHORITY environment variable set) would result in an access denied.
    
    The same on X11 is granted because the local user is automatically
    granted access to Xserver by the startup scripts.
    
    Add the local user to xhost at startup on Xwayland so that the user can
    still run a client by setting the DISPLAY as long as it's the same user
    on the same host.
    
    https://gitlab.gnome.org/GNOME/mutter/merge_requests/735

 src/wayland/meta-xwayland.c | 18 ++++++++++++++++++
 1 file changed, 18 insertions(+)
---
diff --git a/src/wayland/meta-xwayland.c b/src/wayland/meta-xwayland.c
index a7b44453a..948f26518 100644
--- a/src/wayland/meta-xwayland.c
+++ b/src/wayland/meta-xwayland.c
@@ -565,6 +565,23 @@ prepare_auth_file (MetaXWaylandManager *manager)
   return TRUE;
 }
 
+static void
+add_local_user_to_xhost (Display *xdisplay)
+{
+  XHostAddress host_entry;
+  XServerInterpretedAddress siaddr;
+
+  siaddr.type = (char *) "localuser";
+  siaddr.typelength = strlen (siaddr.type);
+  siaddr.value = (char *) g_get_user_name();
+  siaddr.valuelength = strlen (siaddr.value);
+
+  host_entry.family = FamilyServerInterpreted;
+  host_entry.address = (char *) &siaddr;
+
+  XAddHost (xdisplay, &host_entry);
+}
+
 static void
 xserver_finished_init (MetaXWaylandManager *manager)
 {
@@ -808,6 +825,7 @@ meta_xwayland_complete_init (MetaDisplay *display,
   g_signal_connect (display, "x11-display-closing",
                     G_CALLBACK (on_x11_display_closing), NULL);
   meta_xwayland_init_dnd (xdisplay);
+  add_local_user_to_xhost (xdisplay);
 
   if (meta_get_x11_display_policy () == META_DISPLAY_POLICY_ON_DEMAND)
     {


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]