Obsolete VTE pre-2.91 ABI
[oi-userland.git] / components / x11 / xorg-server / patches / 06-make_xkm_output_dir.patch
blob18b4d22f64a95e0f51ee8310aedf69b902f7ae83
1 Based on Xorg upstream git commit b07602014061cb41540f6a7e74e4132e67aa1117
2 From: Alan Coopersmith <Alan.Coopersmith@sun.com>
3 Date: Mon, 22 Aug 2005 21:47:59 +0000
5 If MAKE_XKM_OUTPUT_DIR is defined, call trans_mkdir to create directory if
6 it doesn't already exist. (ported from Solaris Xsun bug #5039004)
8 [Xorg has since dropped upstream, but we still use.]
10 Updated to include changes to ensure xkb directory & files are writable
11 by gid 0, to fix bug:
12 6916317 Changing xkb settings after login not working on snv130
14 diff --git a/xkb/Makefile.am b/xkb/Makefile.am
15 index fb3ccbf..5a82e09 100644
16 --- a/xkb/Makefile.am
17 +++ b/xkb/Makefile.am
18 @@ -1,6 +1,7 @@
19 noinst_LTLIBRARIES = libxkb.la libxkbstubs.la
21 AM_CFLAGS = $(DIX_CFLAGS)
22 +AM_CFLAGS += -DMAKE_XKM_OUTPUT_DIR
24 DDX_SRCS = \
25 ddxBeep.c \
26 diff --git a/xkb/ddxLoad.c b/xkb/ddxLoad.c
27 index d462957..9338a1c 100644
28 --- a/xkb/ddxLoad.c
29 +++ b/xkb/ddxLoad.c
30 @@ -68,14 +68,30 @@ THE USE OR PERFORMANCE OF THIS SOFTWARE.
31 #define PATHSEPARATOR "/"
32 #endif
34 +#ifdef MAKE_XKM_OUTPUT_DIR
35 +/* Borrow trans_mkdir from Xtransutil.c to more safely make directories */
36 +# undef X11_t
37 +# define TRANS_SERVER
38 +# define prmsg(lvl,...) \
39 + if (lvl <= 1) { LogMessage(X_ERROR, __VA_ARGS__); } else ((void)0)
40 +# include <X11/Xtrans/Xtransutil.c>
41 +# ifndef XKM_OUTPUT_DIR_MODE
42 +# define XKM_OUTPUT_DIR_MODE 0775
43 +# endif
44 +#endif
46 static void
47 OutputDirectory(char *outdir, size_t size)
49 #ifndef WIN32
50 +#ifdef MAKE_XKM_OUTPUT_DIR
51 + if (geteuid() == 0 && trans_mkdir(XKM_OUTPUT_DIR, XKM_OUTPUT_DIR_MODE) == 0 && (strlen(XKM_OUTPUT_DIR) < size)) {
52 +#else
53 /* Can we write an xkm and then open it too? */
54 if (access(XKM_OUTPUT_DIR, W_OK | X_OK) == 0 &&
55 (strlen(XKM_OUTPUT_DIR) < size)) {
56 - (void) strcpy(outdir, XKM_OUTPUT_DIR);
57 +#endif
58 + (void) strcpy (outdir, XKM_OUTPUT_DIR);
60 else
61 #else
62 @@ -113,6 +129,15 @@ XkbDDXCompileKeymapByNames(XkbDescPtr xkb,
63 const char *xkmfile = "-";
64 #endif
66 + /* save gid and reset to gid 0 before making xkm_output_dir or
67 + running xkbcomp to create the xkm file in it. */
68 + gid_t usr_gid = getgid();
70 + if (setregid(0, usr_gid) < 0)
71 + ErrorF("Error in setting regid to 0: %s\n", strerror(errno));
72 + if (setegid(0) < 0)
73 + ErrorF("Error in setting egid to 0: %s\n", strerror(errno));
75 snprintf(keymap, sizeof(keymap), "server-%s", display);
77 OutputDirectory(xkm_output_dir, sizeof(xkm_output_dir));
78 @@ -164,6 +189,11 @@ XkbDDXCompileKeymapByNames(XkbDescPtr xkb,
79 out = fopen(tmpname, "w");
80 #endif
82 + if (setregid(usr_gid, 0) < 0)
83 + ErrorF("Error in resetting regid: %s\n", strerror(errno));
84 + if (setegid(usr_gid) < 0)
85 + ErrorF("Error in resetting egid: %s\n", strerror(errno));
87 if (out != NULL) {
88 #ifdef DEBUG
89 if (xkbDebugFlags) {