|
|
70130e |
From 66a3b14e118e90db80f96fcab52af4df35bc2377 Mon Sep 17 00:00:00 2001
|
|
|
70130e |
From: Adam Jackson <ajax@redhat.com>
|
|
|
70130e |
Date: Mon, 10 Dec 2007 11:26:57 -0500
|
|
|
70130e |
Subject: [PATCH] Hack for proper MIT-SHM rejection for ssh-forwarded clients.
|
|
|
70130e |
|
|
|
70130e |
---
|
|
|
70130e |
Xext/shm.c | 16 ++++++++++++++++
|
|
|
70130e |
1 file changed, 16 insertions(+)
|
|
|
70130e |
|
|
|
70130e |
diff --git a/Xext/shm.c b/Xext/shm.c
|
|
|
70130e |
index de48020..c011210 100644
|
|
|
70130e |
--- a/Xext/shm.c
|
|
|
70130e |
+++ b/Xext/shm.c
|
|
|
70130e |
@@ -321,8 +321,21 @@ shm_access(ClientPtr client, SHMPERM_TYPE * perm, int readonly)
|
|
|
70130e |
mode_t mask;
|
|
|
70130e |
int uidset = 0, gidset = 0;
|
|
|
70130e |
LocalClientCredRec *lcc;
|
|
|
70130e |
+ Bool is_ssh = FALSE;
|
|
|
70130e |
|
|
|
70130e |
if (GetLocalClientCreds(client, &lcc) != -1) {
|
|
|
70130e |
+#ifdef linux
|
|
|
70130e |
+ if (lcc->fieldsSet & LCC_PID_SET) {
|
|
|
70130e |
+ /* ssh isn't actually a local client */
|
|
|
70130e |
+ char exe[64], buf[64];
|
|
|
70130e |
+
|
|
|
70130e |
+ memset(buf, 0, 64);
|
|
|
70130e |
+ snprintf(exe, 64, "/proc/%d/exe", lcc->pid);
|
|
|
70130e |
+ readlink(exe, buf, 63);
|
|
|
70130e |
+ if (strstr(buf, "/ssh"))
|
|
|
70130e |
+ is_ssh = TRUE;
|
|
|
70130e |
+ }
|
|
|
70130e |
+#endif
|
|
|
70130e |
|
|
|
70130e |
if (lcc->fieldsSet & LCC_UID_SET) {
|
|
|
70130e |
uid = lcc->euid;
|
|
|
70130e |
@@ -342,6 +355,9 @@ shm_access(ClientPtr client, SHMPERM_TYPE * perm, int readonly)
|
|
|
70130e |
#endif
|
|
|
70130e |
FreeLocalClientCreds(lcc);
|
|
|
70130e |
|
|
|
70130e |
+ if (is_ssh)
|
|
|
70130e |
+ return -1;
|
|
|
70130e |
+
|
|
|
70130e |
if (uidset) {
|
|
|
70130e |
/* User id 0 always gets access */
|
|
|
70130e |
if (uid == 0) {
|
|
|
70130e |
--
|
|
|
70130e |
1.7.10.1
|
|
|
70130e |
|