summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNirbheek Chauhan <nirbheek@gentoo.org>2009-09-29 22:35:06 +0530
committerPeter Hutterer <peter.hutterer@who-t.net>2009-10-02 16:20:29 +1000
commit80735dbf560ba156e53cd2a46190b334de281dd6 (patch)
tree621650fd3e14cccbb081d72a1aa26fc02cbc6cc3
parent616c7a009d9c4e84a8882ac797092d61619c1339 (diff)
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: Nirbheek Chauhan <nirbheek@gentoo.org> Signed-off-by: RĂ©mi Cardona <remi@gentoo.org> Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net> (cherry picked from commit 9bc7cbf9c02656982c2525836b5498993f708e02)
-rw-r--r--xkb/ddxLoad.c5
1 files changed, 2 insertions, 3 deletions
diff --git a/xkb/ddxLoad.c b/xkb/ddxLoad.c
index 6954dd150..ba8d50b19 100644
--- a/xkb/ddxLoad.c
+++ b/xkb/ddxLoad.c
@@ -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