aboutsummaryrefslogtreecommitdiffstats
path: root/contrib/packages/rpm/el5/SOURCES/xserver-1.4.99-ssh-isnt-local.patch
blob: d532fe1d6b8f2416065389e8560b5d4b73baaade (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
From 4306b434038de7e2b17d3c4a6cfd87db469d3bda Mon Sep 17 00:00:00 2001
From: Adam Jackson <ajax@redhat.com>
Date: Mon, 10 Dec 2007 11:26:57 -0500
Subject: [PATCH] Hack for proper MIT-SHM rejection for ssh-forwarded clients.

---
 Xext/shm.c |   15 +++++++++++++++
 1 files changed, 15 insertions(+), 0 deletions(-)

diff --git a/Xext/shm.c b/Xext/shm.c
index 5937a03..5376c19 100644
--- a/Xext/shm.c
+++ b/Xext/shm.c
@@ -381,8 +381,21 @@
     mode_t mask;
     int uidset = 0, gidset = 0;
     LocalClientCredRec *lcc;
+    Bool is_ssh = FALSE;
     
     if (GetLocalClientCreds(client, &lcc) != -1) {
+#ifdef linux
+	if (lcc->fieldsSet & LCC_PID_SET) {
+	    /* ssh isn't actually a local client */
+	    char exe[64], buf[64];
+
+	    memset(buf, 0, 64);
+	    snprintf(exe, 64, "/proc/%d/exe", lcc->pid);
+	    readlink(exe, buf, 63);
+	    if (strstr(buf, "/ssh"))
+		is_ssh = TRUE;
+	}
+#endif
 
 	if (lcc->fieldsSet & LCC_UID_SET) {
 	    uid = lcc->euid;
@@ -401,6 +414,9 @@
 	}
 #endif
 	FreeLocalClientCreds(lcc);
+
+	if (is_ssh)
+	    return -1;
 	
 	if (uidset) {
 	    /* User id 0 always gets access */
-- 
1.5.3.4