summaryrefslogtreecommitdiffstats
path: root/src/plugins/platforms/xcb/qxcbconnection.cpp
diff options
context:
space:
mode:
authorAlexander Volkov <a.volkov@rusbitech.ru>2018-02-06 13:49:42 +0300
committerAlexander Volkov <a.volkov@rusbitech.ru>2018-02-15 22:15:02 +0000
commit24adaa9a742e6f95ff897d0eb9a2bce0527dd042 (patch)
treebb159c5d6f69cb0ccde7f6555f1a41e88f12c2c3 /src/plugins/platforms/xcb/qxcbconnection.cpp
parent8db9e33997a8fbe3e13eab1ca62ae2d5ac39abef (diff)
xcb: Fix access to shm for X server running from another user
Use ShmCreateSegment call, that was added in MIT-SHM 1.2, to create shared memory segments on the server side. It returns a POSIX shared memory object that is used to mmap memory. It's in effect a file descriptor that is passed through the X server socket and thus avoids permission checks. On the other hand this scheme is more secure, because the file descriptor, and thus the shared memory, are accessible only by the X server and the application. Task-number: QTBUG-46017 Change-Id: I202eead9d01aee2ab5b65f4f74f4c13da7cb2239 Reviewed-by: Gatis Paeglis <gatis.paeglis@qt.io>
Diffstat (limited to 'src/plugins/platforms/xcb/qxcbconnection.cpp')
-rw-r--r--src/plugins/platforms/xcb/qxcbconnection.cpp9
1 files changed, 9 insertions, 0 deletions
diff --git a/src/plugins/platforms/xcb/qxcbconnection.cpp b/src/plugins/platforms/xcb/qxcbconnection.cpp
index e8bb97c6af..d0868f44c0 100644
--- a/src/plugins/platforms/xcb/qxcbconnection.cpp
+++ b/src/plugins/platforms/xcb/qxcbconnection.cpp
@@ -2103,6 +2103,15 @@ void QXcbConnection::initializeShm()
}
has_shm = true;
+
+ auto shm_query = Q_XCB_REPLY(xcb_shm_query_version, m_connection);
+ if (!shm_query) {
+ qWarning("QXcbConnection: Failed to request MIT-SHM version");
+ return;
+ }
+
+ has_shm_fd = (shm_query->major_version == 1 && shm_query->minor_version >= 2) ||
+ shm_query->major_version > 1;
}
void QXcbConnection::initializeXFixes()