1185N/ABased on Xorg upstream git commit b07602014061cb41540f6a7e74e4132e67aa1117
606N/AFrom: Alan Coopersmith <Alan.Coopersmith@sun.com>
606N/ADate: Mon, 22 Aug 2005 21:47:59 +0000
606N/AIf MAKE_XKM_OUTPUT_DIR is defined, call trans_mkdir to create directory if
606N/Ait doesn't already exist. (ported from Solaris Xsun bug #5039004)
606N/A[Xorg has since dropped upstream, but we still use.]
880N/AUpdated to include changes to ensure xkb directory & files are writable
880N/A6916317 Changing xkb settings after login not working on snv130
1124N/Aindex fb3ccbf..5a82e09 100644
1088N/A+AM_CFLAGS += -DMAKE_XKM_OUTPUT_DIR
1340N/Aindex d462957..9338a1c 100644
1340N/A@@ -68,14 +68,30 @@ THE USE OR PERFORMANCE OF THIS SOFTWARE.
606N/A+#ifdef MAKE_XKM_OUTPUT_DIR
1276N/A+ if (lvl <= 1) { LogMessage(X_ERROR, __VA_ARGS__); } else ((void)0)
606N/A+# ifndef XKM_OUTPUT_DIR_MODE
880N/A+# define XKM_OUTPUT_DIR_MODE 0775
1276N/A OutputDirectory(char *outdir, size_t size)
1286N/A+ if (geteuid() == 0 && trans_mkdir(XKM_OUTPUT_DIR, XKM_OUTPUT_DIR_MODE) == 0 && (strlen(XKM_OUTPUT_DIR) < size)) {
1276N/A /* Can we write an xkm and then open it too? */
1276N/A if (access(XKM_OUTPUT_DIR, W_OK | X_OK) == 0 &&
1276N/A (strlen(XKM_OUTPUT_DIR) < size)) {
1286N/A- (void) strcpy(outdir, XKM_OUTPUT_DIR);
1286N/A+ (void) strcpy (outdir, XKM_OUTPUT_DIR);
1340N/A@@ -113,6 +129,15 @@ XkbDDXCompileKeymapByNames(XkbDescPtr xkb,
880N/A const char *xkmfile = "-";
880N/A+ /* save gid and reset to gid 0 before making xkm_output_dir or
880N/A+ running xkbcomp to create the xkm file in it. */
880N/A+ if (setregid(0, usr_gid) < 0)
1265N/A+ ErrorF("Error in setting regid to 0: %s\n", strerror(errno));
1265N/A+ ErrorF("Error in setting egid to 0: %s\n", strerror(errno));
880N/A snprintf(keymap, sizeof(keymap), "server-%s", display);
880N/A OutputDirectory(xkm_output_dir, sizeof(xkm_output_dir));
1340N/A@@ -164,6 +189,11 @@ XkbDDXCompileKeymapByNames(XkbDescPtr xkb,
880N/A+ if (setregid(usr_gid, 0) < 0)
1265N/A+ ErrorF("Error in resetting regid: %s\n", strerror(errno));
880N/A+ if (setegid(usr_gid) < 0)
1265N/A+ ErrorF("Error in resetting egid: %s\n", strerror(errno));