[mutter] xwayland: Fix build without <sys/random.h>



commit c63d0173b5499631b388c5ad620d189c89ff3831
Author: Olivier Fourdan <ofourdan redhat com>
Date:   Thu Jun 20 12:11:29 2019 +0200

    xwayland: Fix build without <sys/random.h>
    
    The include <sys/random.h> was added to glibc-2.25, previously was
    <linux/random.h>.
    
    Adjust meson build and code to accomodate both.
    
    Fixes: a8984a81c "xwayland: Generate a Xauth file and pass this to
                      Xwayland when starting it"
    
    https://gitlab.gnome.org/GNOME/mutter/merge_requests/633

 config.h.meson              | 5 +++--
 meson.build                 | 9 +++++++++
 src/wayland/meta-xwayland.c | 4 ++++
 3 files changed, 16 insertions(+), 2 deletions(-)
---
diff --git a/config.h.meson b/config.h.meson
index 2095b6915..77045319c 100644
--- a/config.h.meson
+++ b/config.h.meson
@@ -61,5 +61,6 @@
 /* XKB base prefix */
 #mesondefine XKB_BASE
 
-/* Default rules for allowing Xwayland grabs */
-#mesondefine XWAYLAND_GRAB_DEFAULT_ACCESS_RULES
+/* Either <sys/random.h> or <linux/random.h> */
+#mesondefine HAVE_SYS_RANDOM
+#mesondefine HAVE_LINUX_RANDOM
diff --git a/meson.build b/meson.build
index d88a8653d..886481f4d 100644
--- a/meson.build
+++ b/meson.build
@@ -364,6 +364,15 @@ if have_wayland
     xwayland_path = find_program('Xwayland').path()
   endif
   cdata.set_quoted('XWAYLAND_PATH', xwayland_path)
+
+  # For Xwayland authority file generation.
+  if cc.has_header_symbol('sys/random.h', 'getrandom')
+    cdata.set('HAVE_SYS_RANDOM', 1)
+  elif cc.has_header_symbol('linux/random.h', 'getrandom')
+    cdata.set('HAVE_LINUX_RANDOM', 1)
+  else
+    error('Required function getrandom not found')
+  endif
 endif
 
 xwayland_grab_default_access_rules = get_option('xwayland_grab_default_access_rules')
diff --git a/src/wayland/meta-xwayland.c b/src/wayland/meta-xwayland.c
index 92a2224b2..9455326d0 100644
--- a/src/wayland/meta-xwayland.c
+++ b/src/wayland/meta-xwayland.c
@@ -31,7 +31,11 @@
 #include <glib.h>
 #include <sys/socket.h>
 #include <sys/un.h>
+#if defined(HAVE_SYS_RANDOM)
 #include <sys/random.h>
+#elif defined(HAVE_LINUX_RANDOM)
+#include <linux/random.h>
+#endif
 #include <unistd.h>
 #include <X11/Xauth.h>
 


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