summaryrefslogtreecommitdiff
path: root/xkb/ddxLoad.c
diff options
context:
space:
mode:
authorAlan Coopersmith <Alan.Coopersmith@sun.com>2005-08-22 21:47:59 +0000
committerAlan Coopersmith <Alan.Coopersmith@sun.com>2005-08-22 21:47:59 +0000
commitb07602014061cb41540f6a7e74e4132e67aa1117 (patch)
treea799a16c84551e4f256322229845961ed89a8236 /xkb/ddxLoad.c
parent4a19a33db6d04b5835830a665daa679ee2fcafe7 (diff)
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) When BuildLikeSun is set, define MAKE_XKM_OUTPUT_DIR and set the xkb output directory to /var/run/xkb.
Diffstat (limited to 'xkb/ddxLoad.c')
-rw-r--r--xkb/ddxLoad.c22
1 files changed, 20 insertions, 2 deletions
diff --git a/xkb/ddxLoad.c b/xkb/ddxLoad.c
index 5bad9cb31..66ce9014d 100644
--- a/xkb/ddxLoad.c
+++ b/xkb/ddxLoad.c
@@ -159,20 +159,37 @@ 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 */
(void) strcpy (outdir, XKM_OUTPUT_DIR);
} else
#endif
#ifdef _PATH_VARTMP
- if (strlen(_PATH_VARTMP) < size)
+ if ((strlen(_PATH_VARTMP) + 1) < size)
{
(void) strcpy (outdir, _PATH_VARTMP);
if (outdir[strlen(outdir) - 1] != '/') /* Hi IBM, Digital */
@@ -186,6 +203,7 @@ OutputDirectory(
(void) strcat(outdir, "\\");
} else
#endif
+ if (strlen("/tmp/") < size)
{
(void) strcpy (outdir, "/tmp/");
}