diff options
author | Izik Eidus <ieidus@redhat.com> | 2009-12-17 20:45:09 +0200 |
---|---|---|
committer | Yaniv Kamay <ykamay@redhat.com> | 2010-01-03 17:47:04 +0200 |
commit | 6b065f80dee389490c20289beb97415b06108d02 (patch) | |
tree | a1ad4d31aeaa036620e6440912c4cea5c57654bc /client/x11/platform.cpp | |
parent | fe02804983422ce50d65867f311117907caa01b7 (diff) | |
download | spice-6b065f80dee389490c20289beb97415b06108d02.tar.gz spice-6b065f80dee389490c20289beb97415b06108d02.tar.xz spice-6b065f80dee389490c20289beb97415b06108d02.zip |
spice: client: add checks to see if it is safe to use XShem.
Beacuse that XShem internal checks wont fail when using the spice client
from remote, we are adding check on the socket family to see if it is
unix domain socket and fail in case it is not.
Signed-off-by: Izik Eidus <ieidus@redhat.com>
Diffstat (limited to 'client/x11/platform.cpp')
-rw-r--r-- | client/x11/platform.cpp | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/client/x11/platform.cpp b/client/x11/platform.cpp index 217664a4..d00092be 100644 --- a/client/x11/platform.cpp +++ b/client/x11/platform.cpp @@ -26,7 +26,9 @@ #include <X11/extensions/render.h> #include <X11/extensions/XKB.h> #include <X11/extensions/Xrender.h> +#include <X11/extensions/XShm.h> #include <unistd.h> +#include <sys/socket.h> #include <sys/epoll.h> #include <sys/resource.h> #include <sys/types.h> @@ -63,6 +65,7 @@ #endif static Display* x_display = NULL; +static bool x_shm_avail = false; static XVisualInfo **vinfo = NULL; static GLXFBConfig **fb_config; @@ -183,6 +186,11 @@ Display* XPlatform::get_display() return x_display; } +bool XPlatform::is_x_shm_avail() +{ + return x_shm_avail; +} + XVisualInfo** XPlatform::get_vinfo() { return vinfo; @@ -2069,6 +2077,9 @@ void Platform::init() { int err, ev; int threads_enable; + int connection_fd; + socklen_t sock_len; + struct sockaddr sock_addr; DBG(0, ""); @@ -2079,6 +2090,12 @@ void Platform::init() THROW("open X display failed"); } + connection_fd = ConnectionNumber(x_display); + if (!getsockname(connection_fd, &sock_addr, &sock_len) && + XShmQueryExtension(x_display) && sock_addr.sa_family == AF_UNIX ) { + x_shm_avail = true; + } + vinfo = new XVisualInfo *[ScreenCount(x_display)]; memset(vinfo, 0, sizeof(XVisualInfo *) * ScreenCount(x_display)); fb_config = new GLXFBConfig *[ScreenCount(x_display)]; |