ddxLoad: Check XDG_RUNTIME_DIR before fallback to /tmp/
The XKM_OUTPUT_DIR folder by default is defined as ${datadir}/X11/xkb/compiled and it is usually defined as /var/lib/xkb or %{_localstatedir}/lib/xkb by distributions. If X is executed as non-root it won't have permissions to write into that folder. If we fallback directly to /tmp we might get name collisions: ``` > Error: Cannot open "/tmp/server-10.xkm" to write keyboard description > Exiting ``` Where the file /tmp/server-10.xkm already exists but is owned by another user that previously executed X and had the display number 10. This is specially problematic when exeuting Xvfb. Before falling back to /tmp/ check first the XDG_RUNTIME_DIR.
This commit is contained in:
parent
81458a86bf
commit
bddcaf0886
|
@ -31,6 +31,7 @@ THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
|||
#include <xkb-config.h>
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <ctype.h>
|
||||
#include <X11/X.h>
|
||||
#include <X11/Xos.h>
|
||||
|
@ -69,9 +70,17 @@ OutputDirectory(char *outdir, size_t size)
|
|||
/* Can we write an xkm and then open it too? */
|
||||
if (access(XKM_OUTPUT_DIR, W_OK | X_OK) == 0) {
|
||||
directory = XKM_OUTPUT_DIR;
|
||||
if (XKM_OUTPUT_DIR[strlen(XKM_OUTPUT_DIR) - 1] != '/')
|
||||
pathsep = "/";
|
||||
} else {
|
||||
const char *xdg_runtime_dir = getenv("XDG_RUNTIME_DIR");
|
||||
|
||||
if (xdg_runtime_dir && xdg_runtime_dir[0] == '/' &&
|
||||
access(xdg_runtime_dir, W_OK | X_OK) == 0)
|
||||
directory = xdg_runtime_dir;
|
||||
}
|
||||
|
||||
if (directory && directory[strlen(directory) - 1] != '/')
|
||||
pathsep = "/";
|
||||
|
||||
#else
|
||||
directory = Win32TempDir();
|
||||
pathsep = "\\";
|
||||
|
|
Loading…
Reference in New Issue