aboutsummaryrefslogtreecommitdiff
path: root/nx-X11/programs/Xserver/xkb/ddxLoad.c
diff options
context:
space:
mode:
authorMike Gabriel <mike.gabriel@das-netzwerkteam.de>2019-06-22 11:32:42 +0200
committerMike Gabriel <mike.gabriel@das-netzwerkteam.de>2019-06-22 11:32:42 +0200
commitabf3741362f4c200945db6403fcd54df6754d4af (patch)
treeea7d12c03048fab6e0cbc7571b779c592d610512 /nx-X11/programs/Xserver/xkb/ddxLoad.c
parentc0754a35755cdd4e25386abc6378e07605845948 (diff)
parentc8a5e33fcdde322f486d6c69e7e16fa346793fc9 (diff)
downloadnx-libs-abf3741362f4c200945db6403fcd54df6754d4af.tar.gz
nx-libs-abf3741362f4c200945db6403fcd54df6754d4af.tar.bz2
nx-libs-abf3741362f4c200945db6403fcd54df6754d4af.zip
Merge branch 'uli42-pr/various' into 3.6.x
Attributes GH PR #815: https://github.com/ArcticaProject/nx-libs/pull/815
Diffstat (limited to 'nx-X11/programs/Xserver/xkb/ddxLoad.c')
-rw-r--r--nx-X11/programs/Xserver/xkb/ddxLoad.c101
1 files changed, 24 insertions, 77 deletions
diff --git a/nx-X11/programs/Xserver/xkb/ddxLoad.c b/nx-X11/programs/Xserver/xkb/ddxLoad.c
index b770ba026..bff69196f 100644
--- a/nx-X11/programs/Xserver/xkb/ddxLoad.c
+++ b/nx-X11/programs/Xserver/xkb/ddxLoad.c
@@ -57,14 +57,6 @@ THE USE OR PERFORMANCE OF THIS SOFTWARE.
#include <paths.h>
#endif
-#ifndef PATH_MAX
-#ifdef MAXPATHLEN
-#define PATH_MAX MAXPATHLEN
-#else
-#define PATH_MAX 1024
-#endif
-#endif
-
/*
* If XKM_OUTPUT_DIR specifies a path without a leading slash, it is
* relative to the top-level XKB configuration directory.
@@ -166,44 +158,19 @@ 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 <nx-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)
-#ifdef MAKE_XKM_OUTPUT_DIR
- && (trans_mkdir(XKM_OUTPUT_DIR, XKM_OUTPUT_DIR_MODE) == 0)
-#endif
- )
+ if (getuid() == 0 && (strlen(XKM_OUTPUT_DIR) < size))
{
/* 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) + 1) < size)
- {
- (void) strcpy (outdir, _PATH_VARTMP);
- if (outdir[strlen(outdir) - 1] != '/') /* Hi IBM, Digital */
- (void) strcat (outdir, "/");
- } else
-#endif
-#ifdef WIN32
+#else
if (strlen(Win32TempDir()) + 1 < size)
{
(void) strcpy(outdir, Win32TempDir());
@@ -264,15 +231,10 @@ char *cmd = NULL,file[PATH_MAX],xkm_output_dir[PATH_MAX],*map,*outFile;
xkm_output_dir,outFile) == -1)
cmd = NULL;
}
-#ifdef DEBUG
if (xkbDebugFlags) {
- ErrorF("XkbDDXCompileNamedKeymap compiling keymap using:\n");
- ErrorF(" \"cmd\"\n");
+ DebugF("XkbDDXCompileNamedKeymap compiling keymap using:\n");
+ DebugF(" \"cmd\"\n");
}
-#endif
-#ifdef DEBUG_CMD
- ErrorF("xkb executes: %s\n",cmd);
-#endif
if (System(cmd)==0) {
if (nameRtrn) {
strncpy(nameRtrn,outFile,nameRtrnLen);
@@ -284,9 +246,7 @@ char *cmd = NULL,file[PATH_MAX],xkm_output_dir[PATH_MAX],*map,*outFile;
free(cmd);
return True;
}
-#ifdef DEBUG
- ErrorF("Error compiling keymap (%s)\n",names->keymap);
-#endif
+ DebugF("Error compiling keymap (%s)\n",names->keymap);
if (outFile!=NULL)
_XkbFree(outFile);
if (cmd!=NULL)
@@ -399,12 +359,8 @@ char tmpname[PATH_MAX];
if (fclose(out)==0 && System(buf) >= 0)
#endif
{
-#ifdef DEBUG_CMD
- ErrorF("xkb executes: %s\n",buf);
- ErrorF("xkbcomp input:\n");
- XkbWriteXKBKeymapForNames(stderr,names,NULL,xkb,want,need);
- ErrorF("end xkbcomp input\n");
-#endif
+ if (xkbDebugFlags)
+ DebugF("xkb executes: %s\n",buf);
if (nameRtrn) {
strncpy(nameRtrn,keymap,nameRtrnLen);
nameRtrn[nameRtrnLen-1]= '\0';
@@ -413,24 +369,20 @@ char tmpname[PATH_MAX];
free (buf);
return True;
}
-#ifdef DEBUG
else
- ErrorF("Error compiling keymap (%s)\n",keymap);
-#endif
+ DebugF("Error compiling keymap (%s)\n",keymap);
#ifdef WIN32
/* remove the temporary file */
unlink(tmpname);
#endif
}
-#ifdef DEBUG
else {
#ifndef WIN32
- ErrorF("Could not invoke keymap compiler\n");
+ DebugF("Could not invoke keymap compiler\n");
#else
- ErrorF("Could not open file %s\n", tmpname);
+ DebugF("Could not open file %s\n", tmpname);
#endif
}
-#endif
if (nameRtrn)
nameRtrn[0]= '\0';
if (buf != NULL)
@@ -452,15 +404,16 @@ FILE * file;
&&(!isalpha(xkm_output_dir[0]) || xkm_output_dir[1]!=':')
#endif
) {
- if (strlen(XkbBaseDirectory)+strlen(xkm_output_dir)
- +strlen(mapName)+6 <= PATH_MAX)
- {
- sprintf(buf,"%s/%s%s.xkm",XkbBaseDirectory,
- xkm_output_dir,mapName);
- }
+ if (snprintf(buf, PATH_MAX, "%s/%s%s.xkm", XkbBaseDirectory,
+ xkm_output_dir, mapName) >= PATH_MAX)
+ buf[0] = '\0';
+ }
+ else
+ {
+ if (snprintf(buf, PATH_MAX, "%s%s.xkm", xkm_output_dir, mapName)
+ >= PATH_MAX)
+ buf[0] = '\0';
}
- else if (strlen(xkm_output_dir)+strlen(mapName)+5 <= PATH_MAX)
- sprintf(buf,"%s%s.xkm",xkm_output_dir,mapName);
if (buf[0] != '\0')
file= fopen(buf,"rb");
else file= NULL;
@@ -505,17 +458,13 @@ unsigned missing;
return 0;
}
else if (!XkbDDXCompileNamedKeymap(xkb,names,nameRtrn,nameRtrnLen)) {
-#ifdef NOISY
- ErrorF("Couldn't compile keymap file\n");
-#endif
+ DebugF("Couldn't compile keymap file\n");
return 0;
}
}
else if (!XkbDDXCompileKeymapByNames(xkb,names,want,need,
nameRtrn,nameRtrnLen)){
-#ifdef NOISY
- ErrorF("Couldn't compile keymap file\n");
-#endif
+ DebugF("Couldn't compile keymap file\n");
return 0;
}
file= XkbDDXOpenConfigFile(nameRtrn,fileName,PATH_MAX);
@@ -530,11 +479,9 @@ unsigned missing;
(void) unlink (fileName);
return 0;
}
-#ifdef DEBUG
else if (xkbDebugFlags) {
- ErrorF("Loaded %s, defined=0x%x\n",fileName,finfoRtrn->defined);
+ DebugF("Loaded %s, defined=0x%x\n",fileName,finfoRtrn->defined);
}
-#endif
fclose(file);
(void) unlink (fileName);
return (need|want)&(~missing);
@@ -559,9 +506,9 @@ XkbRF_RulesPtr rules;
sprintf(buf,"rules/%s",rules_name);
}
else {
- if (strlen(XkbBaseDirectory)+strlen(rules_name)+8 > PATH_MAX)
+ if (snprintf(buf, PATH_MAX, "%s/rules/%s", XkbBaseDirectory, rules_name)
+ >= PATH_MAX)
return False;
- sprintf(buf,"%s/rules/%s",XkbBaseDirectory,rules_name);
}
if ((file= fopen(buf,"r"))==NULL)
return False;