aboutsummaryrefslogtreecommitdiff
path: root/nxcomp/Loop.cpp
diff options
context:
space:
mode:
authorMike Gabriel <mike.gabriel@das-netzwerkteam.de>2015-02-09 15:27:46 +0100
committerMike Gabriel <mike.gabriel@das-netzwerkteam.de>2015-02-09 15:27:46 +0100
commitaaf4a59e4c4ec54a26283bce6bf25281e12f0424 (patch)
tree3d56d4a82594c64e53b4836c32a732b54294af0c /nxcomp/Loop.cpp
parent3384aba386c44ec26d3f131b897f77da440324d7 (diff)
downloadnx-libs-aaf4a59e4c4ec54a26283bce6bf25281e12f0424.tar.gz
nx-libs-aaf4a59e4c4ec54a26283bce6bf25281e12f0424.tar.bz2
nx-libs-aaf4a59e4c4ec54a26283bce6bf25281e12f0424.zip
Add X11 abstract socket support to nxcomp/nxproxy (027_nxcomp_abstract-X11-socket.full+lite.patch).
Diffstat (limited to 'nxcomp/Loop.cpp')
-rw-r--r--nxcomp/Loop.cpp38
1 files changed, 38 insertions, 0 deletions
diff --git a/nxcomp/Loop.cpp b/nxcomp/Loop.cpp
index 14e5ee795..6fd772912 100644
--- a/nxcomp/Loop.cpp
+++ b/nxcomp/Loop.cpp
@@ -4250,6 +4250,39 @@ int SetupDisplaySocket(int &xServerAddrFamily, sockaddr *&xServerAddr,
// where the socket will be created.
//
+ // Try abstract X11 socket first (via a test connect), if that fails
+ // fall back to Unix domain socket file.
+
+ #ifdef __linux__
+ int testSocketFD;
+ testSocketFD = socket(xServerAddrFamily, SOCK_STREAM, PF_UNSPEC);
+
+ int len = sprintf(unixSocketName + 1, "/tmp/.X11-unix/X%d", xPort);
+ unixSocketName[0] = '\0';
+
+ sockaddr_un *xServerAddrABSTRACT = new sockaddr_un;
+ memset(xServerAddrABSTRACT, 0, xServerAddrLength);
+ xServerAddrABSTRACT -> sun_family = AF_UNIX;
+ memcpy(xServerAddrABSTRACT -> sun_path, unixSocketName, len+1);
+ xServerAddrLength = len +3;
+
+ int ret = connect(testSocketFD, (struct sockaddr *) xServerAddrABSTRACT, xServerAddrLength);
+ if (ret == 0) {
+
+ cerr << "Info" << ": Using abstract X11 socket in kernel namespace "
+ << "for accessing DISPLAY=:" << xPort << ".\n";
+
+ close(testSocketFD);
+ xServerAddr = (sockaddr *) xServerAddrABSTRACT;
+ return 1;
+
+ } else {
+
+ cerr << "Info" << ": Falling back to file system X11 socket "
+ << "for accessing DISPLAY=:" << xPort << ".\n";
+
+ #endif
+
struct stat statInfo;
char unixSocketDir[DEFAULT_STRING_LENGTH];
@@ -4322,6 +4355,11 @@ int SetupDisplaySocket(int &xServerAddrFamily, sockaddr *&xServerAddr,
xServerAddr = (sockaddr *) xServerAddrUNIX;
xServerAddrLength = sizeof(sockaddr_un);
+
+ #ifdef __linux__
+
+ }
+ #endif
}
else
{