open-src/xserver/xorg/make_xkm_output_dir.patch
author Alan Coopersmith <Alan.Coopersmith@Sun.COM>
Thu, 15 Jan 2009 12:55:00 -0800
changeset 606 068c11b419c9
child 705 24ca414edbff
permissions -rw-r--r--
6582489 X11R7.4: Xorg server 1.5.3, Mesa 7.2, and associated driver updates Includes changes contributed by Liang, Kan <[email protected]>: - G41 support patches - DRM_CAS in libdrm type error can cause deadlock and hang the glxgears. Includes changes contributed by Martin Bochnig <[email protected]>: - Make SUNWxorg-mesa package platform-clean


Based on Xorg upstream git commit b07602014061cb41540f6a7e74e4132e67aa1117 
From: Alan Coopersmith <[email protected]>
Date: Mon, 22 Aug 2005 21:47:59 +0000

If MAKE_XKM_OUTPUT_DIR is defined, call trans_mkdir to create directory if
it doesn't already exist. (ported from Solaris Xsun bug #5039004)

[Xorg has since dropped upstream, but we still use.]

diff -urp -x '*~' -x '*.orig' xkb/Makefile.am xkb/Makefile.am
--- xkb/Makefile.am	2008-03-07 05:31:29.000000000 -0800
+++ xkb/Makefile.am	2008-09-22 21:39:13.086729000 -0700
@@ -1,6 +1,7 @@
 noinst_LTLIBRARIES = libxkb.la libxkbstubs.la
 
 AM_CFLAGS = $(DIX_CFLAGS) \
+	-DMAKE_XKM_OUTPUT_DIR \
 	-DHAVE_XKB_CONFIG_H
 
 DDX_SRCS = \
diff -urp -x '*~' -x '*.orig' xkb/ddxLoad.c xkb/ddxLoad.c
--- xkb/ddxLoad.c	2008-09-03 10:03:39.000000000 -0700
+++ xkb/ddxLoad.c	2008-09-22 21:39:13.086234000 -0700
@@ -153,13 +153,29 @@ Win32System(const char *cmdline)
 #define System(x) Win32System(x)
 #endif
 
+#ifdef MAKE_XKM_OUTPUT_DIR
+/* Borrow trans_mkdir from Xtransutil.c to more safely make directories */
+# undef X11_t
+# define TRANS_SERVER
+# define PRMSG(lvl,x,a,b,c) \
+	if (lvl <= 1) { LogMessage(X_ERROR,x,a,b,c); } else ((void)0)
+# include <X11/Xtrans/Xtransutil.c>
+# ifndef XKM_OUTPUT_DIR_MODE
+#  define XKM_OUTPUT_DIR_MODE 0755
+# endif
+#endif
+
 static void
 OutputDirectory(
     char* outdir,
     size_t size)
 {
 #ifndef WIN32
-    if (getuid() == 0 && (strlen(XKM_OUTPUT_DIR) < size))
+    if (getuid() == 0 && (strlen(XKM_OUTPUT_DIR) < size)
+#ifdef MAKE_XKM_OUTPUT_DIR    
+	&& (trans_mkdir(XKM_OUTPUT_DIR, XKM_OUTPUT_DIR_MODE) == 0)
+#endif
+	)
     {
 	/* if server running as root it *may* be able to write */
 	/* FIXME: check whether directory is writable at all */