[X2Go-Commits] [nx-libs] 19/29: Add X11 abstract socket support to nxcomp/nxproxy (027_nxcomp_abstract-X11-socket.full+lite.patch).

git-admin at x2go.org git-admin at x2go.org
Tue Feb 10 05:21:45 CET 2015


This is an automated email from the git hooks/post-receive script.

x2go pushed a commit to branch 3.6.x
in repository nx-libs.

commit aaf4a59e4c4ec54a26283bce6bf25281e12f0424
Author: Mike Gabriel <mike.gabriel at das-netzwerkteam.de>
Date:   Mon Feb 9 15:27:46 2015 +0100

    Add X11 abstract socket support to nxcomp/nxproxy (027_nxcomp_abstract-X11-socket.full+lite.patch).
---
 .../027_nxcomp_abstract-X11-socket.full+lite.patch |   59 --------------------
 debian/patches/series                              |    1 -
 nxcomp/Loop.cpp                                    |   38 +++++++++++++
 3 files changed, 38 insertions(+), 60 deletions(-)

diff --git a/debian/patches/027_nxcomp_abstract-X11-socket.full+lite.patch b/debian/patches/027_nxcomp_abstract-X11-socket.full+lite.patch
deleted file mode 100644
index 4c457c5..0000000
--- a/debian/patches/027_nxcomp_abstract-X11-socket.full+lite.patch
+++ /dev/null
@@ -1,59 +0,0 @@
-Description: Add X11 abstract socket support to nxcomp/nxproxy
-Author: Mike Gabriel <mike.gabriel at das-netzwerkteam.de>
-
-diff --git a/nxcomp/Loop.cpp b/nxcomp/Loop.cpp
-index 92b6fc2..d86809d 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
-   {
diff --git a/debian/patches/series b/debian/patches/series
index ca6b6dc..8da3bdb 100644
--- a/debian/patches/series
+++ b/debian/patches/series
@@ -1,4 +1,3 @@
-027_nxcomp_abstract-X11-socket.full+lite.patch
 028_nx-X11_abstract-kernel-sockets.full.patch
 029_nxcomp_ppc64.full+lite.patch
 030_nx-X11_configure-args.full.patch
diff --git a/nxcomp/Loop.cpp b/nxcomp/Loop.cpp
index 14e5ee7..6fd7729 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
   {

--
Alioth's /srv/git/_hooks_/post-receive-email on /srv/git/code.x2go.org/nx-libs.git


More information about the x2go-commits mailing list