| 1 |
From 9bc7cbf9c02656982c2525836b5498993f708e02 Mon Sep 17 00:00:00 2001 |
| 2 |
From: Nirbheek Chauhan <nirbheek@gentoo.org> |
| 3 |
Date: Tue, 29 Sep 2009 22:35:06 +0530 |
| 4 |
Subject: [PATCH 01/10] xkb: check permissions on XKM_OUTPUT_DIR |
| 5 |
MIME-Version: 1.0 |
| 6 |
Content-Type: text/plain; charset=UTF-8 |
| 7 |
Content-Transfer-Encoding: 8bit |
| 8 |
|
| 9 |
Checking just for root is insufficient since that does not guarantee write/read |
| 10 |
permissions in XKM_OUTPUT_DIR (for example with sandbox). |
| 11 |
|
| 12 |
Check if we can write a file, as well as read it later. Otherwise, invoke the |
| 13 |
fallback to /tmp |
| 14 |
|
| 15 |
Signed-off-by: Nirbheek Chauhan <nirbheek@gentoo.org> |
| 16 |
Signed-off-by: Rémi Cardona <remi@gentoo.org> |
| 17 |
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net> |
| 18 |
--- |
| 19 |
xkb/ddxLoad.c | 5 ++--- |
| 20 |
1 files changed, 2 insertions(+), 3 deletions(-) |
| 21 |
|
| 22 |
diff --git a/xkb/ddxLoad.c b/xkb/ddxLoad.c |
| 23 |
index 6954dd1..ba8d50b 100644 |
| 24 |
--- a/xkb/ddxLoad.c |
| 25 |
+++ b/xkb/ddxLoad.c |
| 26 |
@@ -158,10 +158,9 @@ OutputDirectory( |
| 27 |
size_t size) |
| 28 |
{ |
| 29 |
#ifndef WIN32 |
| 30 |
- if (getuid() == 0 && (strlen(XKM_OUTPUT_DIR) < size)) |
| 31 |
+ /* Can we write an xkm and then open it too? */ |
| 32 |
+ if (access(XKM_OUTPUT_DIR, W_OK | X_OK) == 0 && (strlen(XKM_OUTPUT_DIR) < size)) |
| 33 |
{ |
| 34 |
- /* if server running as root it *may* be able to write */ |
| 35 |
- /* FIXME: check whether directory is writable at all */ |
| 36 |
(void) strcpy (outdir, XKM_OUTPUT_DIR); |
| 37 |
} else |
| 38 |
#else |
| 39 |
-- |
| 40 |
1.6.5.rc1 |