Commit 9bc7cbf9 authored by Nirbheek Chauhan's avatar Nirbheek Chauhan Committed by Peter Hutterer

xkb: check permissions on XKM_OUTPUT_DIR

Checking just for root is insufficient since that does not guarantee write/read
permissions in XKM_OUTPUT_DIR (for example with sandbox).

Check if we can write a file, as well as read it later. Otherwise, invoke the
fallback to /tmp
Signed-off-by: default avatarNirbheek Chauhan <nirbheek@gentoo.org>
Signed-off-by: default avatarRémi Cardona <remi@gentoo.org>
Signed-off-by: Peter Hutterer's avatarPeter Hutterer <peter.hutterer@who-t.net>
parent 622fc98f
......@@ -158,10 +158,9 @@ OutputDirectory(
size_t size)
{
#ifndef WIN32
if (getuid() == 0 && (strlen(XKM_OUTPUT_DIR) < size))
/* Can we write an xkm and then open it too? */
if (access(XKM_OUTPUT_DIR, W_OK | X_OK) == 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
#else
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment