[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

xtrans: Changes to 'debian-unstable'



 ChangeLog        |  192 +++++++
 Makefile.am      |    1 
 Xtrans.c         |   19 
 Xtrans.h         |    4 
 Xtransint.h      |   28 +
 Xtranslcl.c      |   35 +
 Xtranssock.c     |  293 ++++++++++-
 Xtranstli.c      | 1407 -------------------------------------------------------
 Xtransutil.c     |   20 
 autogen.sh       |    4 
 configure.ac     |    3 
 debian/changelog |    7 
 debian/control   |    2 
 doc/xtrans.xml   |  565 ++++++++++++++--------
 transport.c      |    3 
 xtrans.m4        |   35 +
 16 files changed, 965 insertions(+), 1653 deletions(-)

New commits:
commit 1633aed46fafb4e7adeee2b9657f6fca931d3bc4
Author: Michele Cane <michele.cane@gmail.com>
Date:   Sun Nov 24 15:50:50 2013 +0100

    Bump Standards-Version to 3.9.4, no changes needed.

diff --git a/debian/changelog b/debian/changelog
index a5949f3..4946147 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -1,6 +1,7 @@
 xtrans (1.3.2-1) UNRELEASED; urgency=low
 
   * New upstream release.
+  * Bump Standards-Version to 3.9.4, no changes needed.
 
  -- Michele Cane <michele.cane@gmail.com>  Sun, 24 Nov 2013 15:41:16 +0100
 
diff --git a/debian/control b/debian/control
index 695ae51..6890b99 100644
--- a/debian/control
+++ b/debian/control
@@ -13,7 +13,7 @@ Build-Depends:
  xmlto (>= 0.0.22),
  xorg-sgml-doctools (>= 1:1.8),
  w3m,
-Standards-Version: 3.8.3
+Standards-Version: 3.9.4
 Vcs-Git: git://git.debian.org/git/pkg-xorg/lib/xtrans
 Vcs-Browser: http://git.debian.org/?p=pkg-xorg/lib/xtrans.git
 

commit 025c17f5bcd2f717112910fc37678476e5070725
Author: Michele Cane <michele.cane@gmail.com>
Date:   Sun Nov 24 15:42:18 2013 +0100

    Bump ChangeLog.

diff --git a/ChangeLog b/ChangeLog
index f1a486c..67db0de 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,195 @@
+commit 0153d1670e4a1883e1bb6dd971435d6268eac5ba
+Author: Alan Coopersmith <alan.coopersmith@oracle.com>
+Date:   Thu Nov 7 20:16:53 2013 -0800
+
+    xtrans 1.3.2
+    
+    Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
+
+commit 426049c30162ed620cc16bb58edef6aac4e2ee5d
+Author: Alan Coopersmith <alan.coopersmith@oracle.com>
+Date:   Thu Nov 7 19:17:44 2013 -0800
+
+    Allow XTRANS_SEND_FDS on Solaris as well
+    
+    Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
+
+commit 76b4f4430f9a857a1b54bfde9ef57a95b87789f5
+Author: Alan Coopersmith <alan.coopersmith@oracle.com>
+Date:   Wed Nov 6 22:34:03 2013 -0800
+
+    Check if we need to define _XOPEN_SOURCE for struct msghdr.msg_control
+    
+    Required to expose the structure members in Solaris headers, since it
+    was an XPG4/UNIX95 addition to the Solaris ABI.
+    
+    Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
+
+commit 32070a64ba99fb89ec039e26444b1e026d6a978e
+Author: Alan Coopersmith <alan.coopersmith@oracle.com>
+Date:   Wed Nov 6 21:52:21 2013 -0800
+
+    Add stubs for send/recv fd functions in local transports
+    
+    Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
+
+commit 08bf85958fab64951a9ba9e27dcb6b8eb818cc7e
+Author: Keith Packard <keithp@keithp.com>
+Date:   Thu Nov 7 18:04:30 2013 -0800
+
+    Switch to CMSG_* macros for FD passing
+    
+    This should be portable to non-Linux systems
+    
+    Signed-off-by: Keith Packard <keithp@keithp.com>
+    Reviewed-by: Alan Coopersmith <alan.coopersmith@oracle.com>
+    Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
+
+commit 6b54b5cf8086f127aa87096e2bdd2263d1c81683
+Author: Keith Packard <keithp@keithp.com>
+Date:   Thu Nov 7 03:49:05 2013 -0800
+
+    Actually disable all of the FD passing code unless XTRANS_SEND_FDS is set
+    
+    Stick all of the functions relating to FD passing inside
+    
+    Signed-off-by: Keith Packard <keithp@keithp.com>
+
+commit f3709f3e0b883a0b4956313f89fa931e9264c346
+Author: Keith Packard <keithp@keithp.com>
+Date:   Wed Nov 6 23:16:11 2013 -0800
+
+    Update to version 1.3.1
+    
+    Signed-off-by: Keith Packard <keithp@keithp.com>
+
+commit 074614940c570524e1446f55fc12a64415057e1f
+Author: Mark Kettenis <kettenis@openbsd.org>
+Date:   Wed Nov 6 23:13:28 2013 -0800
+
+    Don't include file descriptor passing code by default
+    
+    Leave it up to the consumer to request this functionality by defining
+    XTRANS_SEND_FDS.
+    
+    Signed-off-by: Mark Kettenis <kettenis@openbsd.org>
+    Reviewed-by: Keith Packard <keithp@keithp.com>
+    Signed-off-by: Keith Packard <keithp@keithp.com>
+    
+    v2 - make sure this is only defined on systems where the code actually
+    works (Linux for now)
+
+commit a7094c389ac9fd5ca265996f76eb55cb1133974b
+Author: Keith Packard <keithp@keithp.com>
+Date:   Sat Nov 2 19:23:41 2013 -0700
+
+    Add SEND_FDS version of Readv
+    
+    Now that we've found that libFS uses readv, we can test whether this
+    readv implementation works correctly.
+    
+    Signed-off-by: Keith Packard <keithp@keithp.com>
+
+commit 58151f63553faf81babd1371770b7a7f33cecac1
+Author: Keith Packard <keithp@keithp.com>
+Date:   Sat Nov 2 19:10:11 2013 -0700
+
+    Revert "Remove 'Readv' interface"
+    
+    This reverts commit 9e8d99c2e27f2c8acbbfb5b760649aa1bfad665e.
+    
+    libFS still uses this API...
+
+commit 1fb0fd555a16dd8fce4abc6d3fd22b315f46762a
+Author: Keith Packard <keithp@keithp.com>
+Date:   Thu Oct 31 17:21:53 2013 -0700
+
+    Update to version 1.3.0
+    
+    Adds FD passing interfaces and pulls in current patches past 1.2.7
+    
+    Signed-off-by: Keith Packard <keithp@keithp.com>
+
+commit adf920aa25c1709998c7c9276927061bd58e2dfc
+Author: Keith Packard <keithp@keithp.com>
+Date:   Tue Jan 8 16:47:05 2013 -0800
+
+    Add APIs to send file descriptors through the network
+    
+    Exposes new TRANS(SendFd)/TRANS(RecvFd) APIs.
+    
+    Signed-off-by: Keith Packard <keithp@keithp.com>
+
+commit 9e8d99c2e27f2c8acbbfb5b760649aa1bfad665e
+Author: Keith Packard <keithp@keithp.com>
+Date:   Fri Jan 18 16:47:30 2013 -0800
+
+    Remove 'Readv' interface
+    
+    No-one uses this, so there's no reason for it to be in the library
+    
+    Signed-off-by: Keith Packard <keithp@keithp.com>
+
+commit f6a161f2a003f4da0a2e414b4faa0ee0de0c01f0
+Author: Łukasz Stelmach <l.stelmach@samsung.com>
+Date:   Tue Jul 9 16:24:43 2013 +0200
+
+    Add const qualifier to unix_nolisten
+    
+    Signed-off-by: Łukasz Stelmach <l.stelmach@samsung.com>
+    Reviewed-by: Alan Coopersmith <alan.coopersmith@oracle.com>
+    Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net>
+    Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
+
+commit bd53f4c8543faf910a7a151241ee07661b4d57ad
+Author: Alan Coopersmith <alan.coopersmith@oracle.com>
+Date:   Sun Jan 27 22:11:40 2013 -0800
+
+    Docs: Drop pre-C89 TRANS() from docs since it's no longer in the headers
+    
+    Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
+
+commit 3c4e0455425d5afd546c4a3f2cc9f8c7e60f2fca
+Author: Alan Coopersmith <alan.coopersmith@oracle.com>
+Date:   Sun Jan 27 21:39:34 2013 -0800
+
+    Docs: convert function synopses to docbook funcsynopsis markup
+    
+    Also add some cross-reference links and various other markup improvements.
+    
+    Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
+
+commit d9f3728ff74ceb956f6cf8dc24b38611f9a4868a
+Author: Colin Walters <walters@verbum.org>
+Date:   Wed Jan 4 17:37:06 2012 -0500
+
+    autogen.sh: Implement GNOME Build API
+    
+    http://people.gnome.org/~walters/docs/build-api.txt
+    
+    Signed-off-by: Adam Jackson <ajax@redhat.com>
+
+commit 575e1e901ca842ba8ff7417f48175fb6a8d70859
+Author: Adam Jackson <ajax@redhat.com>
+Date:   Tue Jan 15 14:28:48 2013 -0500
+
+    configure: Remove AM_MAINTAINER_MODE
+    
+    Signed-off-by: Adam Jackson <ajax@redhat.com>
+
+commit ec3136232f7ce930f9ca812b6ab42a71b60af4af
+Author: Alan Coopersmith <alan.coopersmith@oracle.com>
+Date:   Wed Dec 26 19:08:16 2012 -0800
+
+    Remove unused TLI ("STREAMSCONN") code from xtrans
+    
+    Has never been converted to build in modular builds, so has been unusable
+    since X11R7.0 release in 2005.  All known platforms with TLI/XTI support
+    that X11R7 & later releases run on also have (and mostly prefer) BSD
+    socket support for their networking API.
+    
+    Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
+
 commit 8ce5ecd33b05becc054dbd07f87e385165b6c979
 Author: Alan Coopersmith <alan.coopersmith@oracle.com>
 Date:   Thu Mar 22 20:04:07 2012 -0700
diff --git a/debian/changelog b/debian/changelog
index 80f7ddd..a5949f3 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -1,3 +1,9 @@
+xtrans (1.3.2-1) UNRELEASED; urgency=low
+
+  * New upstream release.
+
+ -- Michele Cane <michele.cane@gmail.com>  Sun, 24 Nov 2013 15:41:16 +0100
+
 xtrans (1.2.7-1) unstable; urgency=low
 
   * New upstream release.

commit 0153d1670e4a1883e1bb6dd971435d6268eac5ba
Author: Alan Coopersmith <alan.coopersmith@oracle.com>
Date:   Thu Nov 7 20:16:53 2013 -0800

    xtrans 1.3.2
    
    Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>

diff --git a/configure.ac b/configure.ac
index ac346d5..998fb06 100644
--- a/configure.ac
+++ b/configure.ac
@@ -21,7 +21,7 @@
 
 # Initialize Autoconf
 AC_PREREQ([2.60])
-AC_INIT([xtrans], [1.3.1],
+AC_INIT([xtrans], [1.3.2],
         [https://bugs.freedesktop.org/enter_bug.cgi?product=xorg], [xtrans])
 AC_CONFIG_SRCDIR([Makefile.am])
 

commit 426049c30162ed620cc16bb58edef6aac4e2ee5d
Author: Alan Coopersmith <alan.coopersmith@oracle.com>
Date:   Thu Nov 7 19:17:44 2013 -0800

    Allow XTRANS_SEND_FDS on Solaris as well
    
    Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>

diff --git a/Xtransint.h b/Xtransint.h
index 8dee614..1f32f0c 100644
--- a/Xtransint.h
+++ b/Xtransint.h
@@ -72,8 +72,8 @@ from The Open Group.
 #  define XTRANSDEBUG 1
 #endif
 
-#if XTRANS_SEND_FDS && !defined(linux)
-#error "FD passing support only on Linux"
+#if XTRANS_SEND_FDS && !(defined(linux) || defined(__sun))
+#error "FD passing support only on Linux & Solaris"
 #endif
 
 #ifdef WIN32

commit 76b4f4430f9a857a1b54bfde9ef57a95b87789f5
Author: Alan Coopersmith <alan.coopersmith@oracle.com>
Date:   Wed Nov 6 22:34:03 2013 -0800

    Check if we need to define _XOPEN_SOURCE for struct msghdr.msg_control
    
    Required to expose the structure members in Solaris headers, since it
    was an XPG4/UNIX95 addition to the Solaris ABI.
    
    Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>

diff --git a/xtrans.m4 b/xtrans.m4
index 91c6f9d..d84442e 100644
--- a/xtrans.m4
+++ b/xtrans.m4
@@ -57,6 +57,41 @@ AC_DEFUN([XTRANS_TCP_FLAGS],[
 AC_INCLUDES_DEFAULT
 #include <sys/socket.h>])
 
+ # XPG4v2/UNIX95 added msg_control - check to see if we need to define
+ # _XOPEN_SOURCE to get it (such as on Solaris)
+ AC_CHECK_MEMBER([struct msghdr.msg_control], [], [],
+                 [
+AC_INCLUDES_DEFAULT
+#include <sys/socket.h>
+                 ])
+ # First try for Solaris in C99 compliant mode, which requires XPG6/UNIX03
+ if test "x$ac_cv_member_struct_msghdr_msg_control" = xno; then
+     unset ac_cv_member_struct_msghdr_msg_control
+     AC_MSG_NOTICE([trying again with _XOPEN_SOURCE=600])
+     AC_CHECK_MEMBER([struct msghdr.msg_control],
+                     [AC_DEFINE([_XOPEN_SOURCE], [600],
+                       [Defined if needed to expose struct msghdr.msg_control])
+                     ], [], [
+#define _XOPEN_SOURCE 600
+AC_INCLUDES_DEFAULT
+#include <sys/socket.h>
+                     ])
+ fi
+ # If that didn't work, fall back to XPG5/UNIX98 with C89
+ if test "x$ac_cv_member_struct_msghdr_msg_control" = xno; then
+     unset ac_cv_member_struct_msghdr_msg_control
+     AC_MSG_NOTICE([trying again with _XOPEN_SOURCE=500])
+     AC_CHECK_MEMBER([struct msghdr.msg_control],
+                     [AC_DEFINE([_XOPEN_SOURCE], [500],
+                       [Defined if needed to expose struct msghdr.msg_control])
+                     ], [], [
+#define _XOPEN_SOURCE 500
+AC_INCLUDES_DEFAULT
+#include <sys/socket.h>
+                     ])
+ fi
+
+
 ]) # XTRANS_TCP_FLAGS
 
 # XTRANS_CONNECTION_FLAGS()

commit 32070a64ba99fb89ec039e26444b1e026d6a978e
Author: Alan Coopersmith <alan.coopersmith@oracle.com>
Date:   Wed Nov 6 21:52:21 2013 -0800

    Add stubs for send/recv fd functions in local transports
    
    Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>

diff --git a/Xtranslcl.c b/Xtranslcl.c
index 5beef7c..4deb86c 100644
--- a/Xtranslcl.c
+++ b/Xtranslcl.c
@@ -140,6 +140,21 @@ TRANS(ReopenFail)(XtransConnInfo ciptr _X_UNUSED, int fd _X_UNUSED, char *port _
 
 #endif /* TRANS_REOPEN */
 
+#if XTRANS_SEND_FDS
+static int
+TRANS(LocalRecvFdInvalid)(XtransConnInfo ciptr)
+{
+    errno = EINVAL;
+    return -1;
+}
+
+static int
+TRANS(LocalSendFdInvalid)(XtransConnInfo ciptr, int fd, int do_close)
+{
+    errno = EINVAL;
+    return -1;
+}
+#endif
 
 
 static int
@@ -2368,6 +2383,10 @@ Xtransport	TRANS(LocalFuncs) = {
 	TRANS(LocalWrite),
 	TRANS(LocalReadv),
 	TRANS(LocalWritev),
+#if XTRANS_SEND_FDS
+	TRANS(LocalSendFdInvalid),
+	TRANS(LocalRecvFdInvalid),
+#endif
 	TRANS(LocalDisconnect),
 	TRANS(LocalClose),
 	TRANS(LocalCloseForCloning),
@@ -2410,6 +2429,10 @@ Xtransport	TRANS(PTSFuncs) = {
 	TRANS(LocalWrite),
 	TRANS(LocalReadv),
 	TRANS(LocalWritev),
+#if XTRANS_SEND_FDS
+	TRANS(LocalSendFdInvalid),
+	TRANS(LocalRecvFdInvalid),
+#endif
 	TRANS(LocalDisconnect),
 	TRANS(LocalClose),
 	TRANS(LocalCloseForCloning),
@@ -2454,6 +2477,10 @@ Xtransport	TRANS(NAMEDFuncs) = {
 	TRANS(LocalWrite),
 	TRANS(LocalReadv),
 	TRANS(LocalWritev),
+#if XTRANS_SEND_FDS
+	TRANS(LocalSendFdInvalid),
+	TRANS(LocalRecvFdInvalid),
+#endif
 	TRANS(LocalDisconnect),
 	TRANS(LocalClose),
 	TRANS(LocalCloseForCloning),
@@ -2495,6 +2522,10 @@ Xtransport	TRANS(PIPEFuncs) = {
 	TRANS(LocalWrite),
 	TRANS(LocalReadv),
 	TRANS(LocalWritev),
+#if XTRANS_SEND_FDS
+	TRANS(LocalSendFdInvalid),
+	TRANS(LocalRecvFdInvalid),
+#endif
 	TRANS(LocalDisconnect),
 	TRANS(LocalClose),
 	TRANS(LocalCloseForCloning),
@@ -2539,6 +2570,10 @@ Xtransport	TRANS(SCOFuncs) = {
 	TRANS(LocalWrite),
 	TRANS(LocalReadv),
 	TRANS(LocalWritev),
+#if XTRANS_SEND_FDS
+	TRANS(LocalSendFdInvalid),
+	TRANS(LocalRecvFdInvalid),
+#endif
 	TRANS(LocalDisconnect),
 	TRANS(LocalClose),
 	TRANS(LocalCloseForCloning),

commit 08bf85958fab64951a9ba9e27dcb6b8eb818cc7e
Author: Keith Packard <keithp@keithp.com>
Date:   Thu Nov 7 18:04:30 2013 -0800

    Switch to CMSG_* macros for FD passing
    
    This should be portable to non-Linux systems
    
    Signed-off-by: Keith Packard <keithp@keithp.com>
    Reviewed-by: Alan Coopersmith <alan.coopersmith@oracle.com>
    Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>

diff --git a/Xtranssock.c b/Xtranssock.c
index c96f45b..c9d1033 100644
--- a/Xtranssock.c
+++ b/Xtranssock.c
@@ -2237,26 +2237,33 @@ TRANS(SocketRead) (XtransConnInfo ciptr, char *buf, int size)
 #else
 #if XTRANS_SEND_FDS
     {
-        struct msghdr   msg;
-        struct iovec    iov;
-        struct fd_pass  pass;
+        struct iovec    iov = {
+            .iov_base = buf,
+            .iov_len = size
+        };
+        char            cmsgbuf[CMSG_SPACE(sizeof(int) * MAX_FDS)];
+        struct msghdr   msg = {
+            .msg_name = NULL,
+            .msg_namelen = 0,
+            .msg_iov = &iov,
+            .msg_iovlen = 1,
+            .msg_control = cmsgbuf,
+            .msg_controllen = CMSG_LEN(MAX_FDS * sizeof(int))
+        };
 
-        iov.iov_base = buf;
-        iov.iov_len = size;
-
-        init_msg_recv(&msg, &iov, 1, &pass, MAX_FDS);
         size = recvmsg(ciptr->fd, &msg, 0);
-        if (size >= 0 && msg.msg_controllen > sizeof (struct cmsghdr)) {
-            if (pass.cmsghdr.cmsg_level == SOL_SOCKET &&
-                pass.cmsghdr.cmsg_type == SCM_RIGHTS &&
-                !((msg.msg_flags & MSG_TRUNC) ||
-                  (msg.msg_flags & MSG_CTRUNC)))
-            {
-                int nfd = (msg.msg_controllen - sizeof (struct cmsghdr)) / sizeof (int);
-                int *fd = (int *) CMSG_DATA(&pass.cmsghdr);
-                int i;
-                for (i = 0; i < nfd; i++)
-                    appendFd(&ciptr->recv_fds, fd[i], 0);
+        if (size >= 0) {
+            struct cmsghdr *hdr;
+
+            for (hdr = CMSG_FIRSTHDR(&msg); hdr; hdr = CMSG_NXTHDR(&msg, hdr)) {
+                if (hdr->cmsg_level == SOL_SOCKET && hdr->cmsg_type == SCM_RIGHTS) {
+                    int nfd = (hdr->cmsg_len - CMSG_LEN(0)) / sizeof (int);
+                    int i;
+                    int *fd = (int *) CMSG_DATA(hdr);
+
+                    for (i = 0; i < nfd; i++)
+                        appendFd(&ciptr->recv_fds, fd[i], 0);
+                }
             }
         }
         return size;
@@ -2275,22 +2282,29 @@ TRANS(SocketReadv) (XtransConnInfo ciptr, struct iovec *buf, int size)
 
 #if XTRANS_SEND_FDS
     {
-        struct msghdr   msg;
-        struct fd_pass  pass;
+        char            cmsgbuf[CMSG_SPACE(sizeof(int) * MAX_FDS)];
+        struct msghdr   msg = {
+            .msg_name = NULL,
+            .msg_namelen = 0,
+            .msg_iov = buf,
+            .msg_iovlen = size,
+            .msg_control = cmsgbuf,
+            .msg_controllen = CMSG_LEN(MAX_FDS * sizeof(int))
+        };
 
-        init_msg_recv(&msg, buf, size, &pass, MAX_FDS);
         size = recvmsg(ciptr->fd, &msg, 0);
-        if (size >= 0 && msg.msg_controllen > sizeof (struct cmsghdr)) {
-            if (pass.cmsghdr.cmsg_level == SOL_SOCKET &&
-                pass.cmsghdr.cmsg_type == SCM_RIGHTS &&
-                !((msg.msg_flags & MSG_TRUNC) ||
-                  (msg.msg_flags & MSG_CTRUNC)))
-            {
-                int nfd = (msg.msg_controllen - sizeof (struct cmsghdr)) / sizeof (int);
-                int *fd = (int *) CMSG_DATA(&pass.cmsghdr);
-                int i;
-                for (i = 0; i < nfd; i++)
-                    appendFd(&ciptr->recv_fds, fd[i], 0);
+        if (size >= 0) {
+            struct cmsghdr *hdr;
+
+            for (hdr = CMSG_FIRSTHDR(&msg); hdr; hdr = CMSG_NXTHDR(&msg, hdr)) {
+                if (hdr->cmsg_level == SOL_SOCKET && hdr->cmsg_type == SCM_RIGHTS) {
+                    int nfd = (hdr->cmsg_len - CMSG_LEN(0)) / sizeof (int);
+                    int i;
+                    int *fd = (int *) CMSG_DATA(hdr);
+
+                    for (i = 0; i < nfd; i++)
+                        appendFd(&ciptr->recv_fds, fd[i], 0);
+                }
             }
         }
         return size;
@@ -2310,22 +2324,32 @@ TRANS(SocketWritev) (XtransConnInfo ciptr, struct iovec *buf, int size)
 #if XTRANS_SEND_FDS
     if (ciptr->send_fds)
     {
-        struct msghdr           msg;
-        struct fd_pass          pass;
-        int                     nfd;
-        struct _XtransConnFd    *cf;
+        char                    cmsgbuf[CMSG_SPACE(sizeof(int) * MAX_FDS)];
+        int                     nfd = nFd(&ciptr->send_fds);
+        struct _XtransConnFd    *cf = ciptr->send_fds;
+        struct msghdr           msg = {
+            .msg_name = NULL,
+            .msg_namelen = 0,
+            .msg_iov = buf,
+            .msg_iovlen = size,
+            .msg_control = cmsgbuf,
+            .msg_controllen = CMSG_LEN(nfd * sizeof(int))
+        };
+        struct cmsghdr          *hdr = CMSG_FIRSTHDR(&msg);
         int                     i;
+        int                     *fds;
 
-        nfd = nFd(&ciptr->send_fds);
-        cf = ciptr->send_fds;
+        hdr->cmsg_len = msg.msg_controllen;
+        hdr->cmsg_level = SOL_SOCKET;
+        hdr->cmsg_type = SCM_RIGHTS;
 
+        fds = (int *) CMSG_DATA(hdr);
         /* Set up fds */
         for (i = 0; i < nfd; i++) {
-            pass.fd[i] = cf->fd;
+            fds[i] = cf->fd;
             cf = cf->next;
         }
 
-        init_msg_send(&msg, buf, size, &pass, nfd);
         i = sendmsg(ciptr->fd, &msg, 0);
         if (i > 0)
             discardFd(&ciptr->send_fds, cf, 0);

commit 6b54b5cf8086f127aa87096e2bdd2263d1c81683
Author: Keith Packard <keithp@keithp.com>
Date:   Thu Nov 7 03:49:05 2013 -0800

    Actually disable all of the FD passing code unless XTRANS_SEND_FDS is set
    
    Stick all of the functions relating to FD passing inside
    
    Signed-off-by: Keith Packard <keithp@keithp.com>

diff --git a/Xtrans.c b/Xtrans.c
index be9a057..735d7b8 100644
--- a/Xtrans.c
+++ b/Xtrans.c
@@ -879,6 +879,7 @@ TRANS(Writev) (XtransConnInfo ciptr, struct iovec *buf, int size)
     return ciptr->transptr->Writev (ciptr, buf, size);
 }
 
+#if XTRANS_SEND_FDS
 int
 TRANS(SendFd) (XtransConnInfo ciptr, int fd, int do_close)
 {
@@ -890,6 +891,7 @@ TRANS(RecvFd) (XtransConnInfo ciptr)
 {
     return ciptr->transptr->RecvFd(ciptr);
 }
+#endif
 
 int
 TRANS(Disconnect) (XtransConnInfo ciptr)
diff --git a/Xtransint.h b/Xtransint.h
index 581af9f..8dee614 100644
--- a/Xtransint.h
+++ b/Xtransint.h
@@ -291,6 +291,7 @@ typedef struct _Xtransport {
 	int			/* size */
     );
 
+#if XTRANS_SEND_FDS
     int (*SendFd)(
 	XtransConnInfo,		/* connection */
         int,                    /* fd */
@@ -300,6 +301,7 @@ typedef struct _Xtransport {
     int (*RecvFd)(
 	XtransConnInfo		/* connection */
     );
+#endif
 
     int	(*Disconnect)(
 	XtransConnInfo		/* connection */
diff --git a/Xtranssock.c b/Xtranssock.c
index 84e4dcd..c96f45b 100644
--- a/Xtranssock.c
+++ b/Xtranssock.c
@@ -2506,8 +2506,10 @@ Xtransport	TRANS(SocketTCPFuncs) = {
 	TRANS(SocketWrite),
 	TRANS(SocketReadv),
 	TRANS(SocketWritev),
+#if XTRANS_SEND_FDS
         TRANS(SocketSendFdInvalid),
         TRANS(SocketRecvFdInvalid),
+#endif
 	TRANS(SocketDisconnect),
 	TRANS(SocketINETClose),
 	TRANS(SocketINETClose),
@@ -2548,8 +2550,10 @@ Xtransport	TRANS(SocketINETFuncs) = {
 	TRANS(SocketWrite),
 	TRANS(SocketReadv),
 	TRANS(SocketWritev),
+#if XTRANS_SEND_FDS
         TRANS(SocketSendFdInvalid),
         TRANS(SocketRecvFdInvalid),
+#endif
 	TRANS(SocketDisconnect),
 	TRANS(SocketINETClose),
 	TRANS(SocketINETClose),
@@ -2591,8 +2595,10 @@ Xtransport     TRANS(SocketINET6Funcs) = {
 	TRANS(SocketWrite),
 	TRANS(SocketReadv),
 	TRANS(SocketWritev),
+#if XTRANS_SEND_FDS
         TRANS(SocketSendFdInvalid),
         TRANS(SocketRecvFdInvalid),
+#endif
 	TRANS(SocketDisconnect),
 	TRANS(SocketINETClose),
 	TRANS(SocketINETClose),
@@ -2641,8 +2647,10 @@ Xtransport	TRANS(SocketLocalFuncs) = {
 	TRANS(SocketWrite),
 	TRANS(SocketReadv),
 	TRANS(SocketWritev),
+#if XTRANS_SEND_FDS
         TRANS(SocketSendFd),
         TRANS(SocketRecvFd),
+#endif
 	TRANS(SocketDisconnect),
 	TRANS(SocketUNIXClose),
 	TRANS(SocketUNIXCloseForCloning),
@@ -2697,8 +2705,10 @@ Xtransport	TRANS(SocketUNIXFuncs) = {
 	TRANS(SocketWrite),
 	TRANS(SocketReadv),
 	TRANS(SocketWritev),
+#if XTRANS_SEND_FDS
         TRANS(SocketSendFd),
         TRANS(SocketRecvFd),
+#endif
 	TRANS(SocketDisconnect),
 	TRANS(SocketUNIXClose),
 	TRANS(SocketUNIXCloseForCloning),

commit f3709f3e0b883a0b4956313f89fa931e9264c346
Author: Keith Packard <keithp@keithp.com>
Date:   Wed Nov 6 23:16:11 2013 -0800

    Update to version 1.3.1
    
    Signed-off-by: Keith Packard <keithp@keithp.com>

diff --git a/configure.ac b/configure.ac
index 8c3aa3d..ac346d5 100644
--- a/configure.ac
+++ b/configure.ac
@@ -21,7 +21,7 @@
 
 # Initialize Autoconf
 AC_PREREQ([2.60])
-AC_INIT([xtrans], [1.3.0],
+AC_INIT([xtrans], [1.3.1],
         [https://bugs.freedesktop.org/enter_bug.cgi?product=xorg], [xtrans])
 AC_CONFIG_SRCDIR([Makefile.am])
 

commit 074614940c570524e1446f55fc12a64415057e1f
Author: Mark Kettenis <kettenis@openbsd.org>
Date:   Wed Nov 6 23:13:28 2013 -0800

    Don't include file descriptor passing code by default
    
    Leave it up to the consumer to request this functionality by defining
    XTRANS_SEND_FDS.
    
    Signed-off-by: Mark Kettenis <kettenis@openbsd.org>
    Reviewed-by: Keith Packard <keithp@keithp.com>
    Signed-off-by: Keith Packard <keithp@keithp.com>
    
    v2 - make sure this is only defined on systems where the code actually
    works (Linux for now)

diff --git a/Xtransint.h b/Xtransint.h
index dd886db..581af9f 100644
--- a/Xtransint.h
+++ b/Xtransint.h
@@ -72,7 +72,9 @@ from The Open Group.
 #  define XTRANSDEBUG 1
 #endif
 
-#define XTRANS_SEND_FDS       1
+#if XTRANS_SEND_FDS && !defined(linux)
+#error "FD passing support only on Linux"
+#endif
 
 #ifdef WIN32
 # define _WILLWINSOCK_

commit a7094c389ac9fd5ca265996f76eb55cb1133974b
Author: Keith Packard <keithp@keithp.com>
Date:   Sat Nov 2 19:23:41 2013 -0700

    Add SEND_FDS version of Readv
    
    Now that we've found that libFS uses readv, we can test whether this
    readv implementation works correctly.
    
    Signed-off-by: Keith Packard <keithp@keithp.com>

diff --git a/Xtranssock.c b/Xtranssock.c
index 23150b2..84e4dcd 100644
--- a/Xtranssock.c
+++ b/Xtranssock.c
@@ -2273,7 +2273,31 @@ TRANS(SocketReadv) (XtransConnInfo ciptr, struct iovec *buf, int size)
 {
     prmsg (2,"SocketReadv(%d,%p,%d)\n", ciptr->fd, buf, size);
 
+#if XTRANS_SEND_FDS
+    {
+        struct msghdr   msg;
+        struct fd_pass  pass;
+
+        init_msg_recv(&msg, buf, size, &pass, MAX_FDS);
+        size = recvmsg(ciptr->fd, &msg, 0);
+        if (size >= 0 && msg.msg_controllen > sizeof (struct cmsghdr)) {
+            if (pass.cmsghdr.cmsg_level == SOL_SOCKET &&
+                pass.cmsghdr.cmsg_type == SCM_RIGHTS &&
+                !((msg.msg_flags & MSG_TRUNC) ||
+                  (msg.msg_flags & MSG_CTRUNC)))
+            {
+                int nfd = (msg.msg_controllen - sizeof (struct cmsghdr)) / sizeof (int);
+                int *fd = (int *) CMSG_DATA(&pass.cmsghdr);
+                int i;
+                for (i = 0; i < nfd; i++)
+                    appendFd(&ciptr->recv_fds, fd[i], 0);
+            }
+        }
+        return size;
+    }
+#else
     return READV (ciptr, buf, size);
+#endif
 }
 
 

commit 58151f63553faf81babd1371770b7a7f33cecac1
Author: Keith Packard <keithp@keithp.com>
Date:   Sat Nov 2 19:10:11 2013 -0700

    Revert "Remove 'Readv' interface"
    
    This reverts commit 9e8d99c2e27f2c8acbbfb5b760649aa1bfad665e.
    
    libFS still uses this API...

diff --git a/Xtrans.c b/Xtrans.c
index 7c7967f..be9a057 100644
--- a/Xtrans.c
+++ b/Xtrans.c
@@ -866,6 +866,13 @@ TRANS(Write) (XtransConnInfo ciptr, char *buf, int size)
 }
 
 int
+TRANS(Readv) (XtransConnInfo ciptr, struct iovec *buf, int size)
+
+{
+    return ciptr->transptr->Readv (ciptr, buf, size);
+}
+
+int
 TRANS(Writev) (XtransConnInfo ciptr, struct iovec *buf, int size)
 
 {
diff --git a/Xtrans.h b/Xtrans.h
index 53b8b62..69accd7 100644
--- a/Xtrans.h
+++ b/Xtrans.h
@@ -344,6 +344,12 @@ int TRANS(Write)(
     int			/* size */
 );
 
+int TRANS(Readv)(
+    XtransConnInfo,	/* ciptr */
+    struct iovec *,	/* buf */
+    int			/* size */
+);
+
 int TRANS(Writev)(
     XtransConnInfo,	/* ciptr */
     struct iovec *,	/* buf */

commit 1fb0fd555a16dd8fce4abc6d3fd22b315f46762a
Author: Keith Packard <keithp@keithp.com>
Date:   Thu Oct 31 17:21:53 2013 -0700

    Update to version 1.3.0
    
    Adds FD passing interfaces and pulls in current patches past 1.2.7
    
    Signed-off-by: Keith Packard <keithp@keithp.com>

diff --git a/configure.ac b/configure.ac
index cc3c006..8c3aa3d 100644
--- a/configure.ac
+++ b/configure.ac
@@ -21,7 +21,7 @@
 
 # Initialize Autoconf
 AC_PREREQ([2.60])
-AC_INIT([xtrans], [1.2.7],
+AC_INIT([xtrans], [1.3.0],
         [https://bugs.freedesktop.org/enter_bug.cgi?product=xorg], [xtrans])
 AC_CONFIG_SRCDIR([Makefile.am])
 

commit adf920aa25c1709998c7c9276927061bd58e2dfc
Author: Keith Packard <keithp@keithp.com>
Date:   Tue Jan 8 16:47:05 2013 -0800

    Add APIs to send file descriptors through the network
    
    Exposes new TRANS(SendFd)/TRANS(RecvFd) APIs.
    
    Signed-off-by: Keith Packard <keithp@keithp.com>

diff --git a/Xtrans.c b/Xtrans.c
index ac8b13d..7c7967f 100644
--- a/Xtrans.c
+++ b/Xtrans.c
@@ -873,6 +873,18 @@ TRANS(Writev) (XtransConnInfo ciptr, struct iovec *buf, int size)
 }
 
 int
+TRANS(SendFd) (XtransConnInfo ciptr, int fd, int do_close)
+{
+    return ciptr->transptr->SendFd(ciptr, fd, do_close);
+}
+
+int
+TRANS(RecvFd) (XtransConnInfo ciptr)
+{
+    return ciptr->transptr->RecvFd(ciptr);
+}
+
+int
 TRANS(Disconnect) (XtransConnInfo ciptr)
 
 {
diff --git a/Xtrans.h b/Xtrans.h
index 1b0af45..53b8b62 100644
--- a/Xtrans.h
+++ b/Xtrans.h
@@ -350,6 +350,10 @@ int TRANS(Writev)(
     int			/* size */
 );
 
+int TRANS(SendFd) (XtransConnInfo ciptr, int fd, int do_close);
+
+int TRANS(RecvFd) (XtransConnInfo ciptr);
+
 int TRANS(Disconnect)(
     XtransConnInfo	/* ciptr */
 );
diff --git a/Xtransint.h b/Xtransint.h
index 3bce8dc..dd886db 100644
--- a/Xtransint.h
+++ b/Xtransint.h
@@ -72,6 +72,8 @@ from The Open Group.
 #  define XTRANSDEBUG 1
 #endif
 
+#define XTRANS_SEND_FDS       1
+
 #ifdef WIN32
 # define _WILLWINSOCK_
 #endif
@@ -123,6 +125,16 @@ from The Open Group.
 #define X_TCP_PORT	6000
 #endif
 
+#if XTRANS_SEND_FDS
+
+struct _XtransConnFd {
+    struct _XtransConnFd   *next;
+    int                    fd;
+    int                    do_close;
+};
+
+#endif
+
 struct _XtransConnInfo {
     struct _Xtransport     *transptr;
     int		index;
@@ -135,6 +147,8 @@ struct _XtransConnInfo {
     int		addrlen;
     char	*peeraddr;
     int		peeraddrlen;
+    struct _XtransConnFd        *recv_fds;
+    struct _XtransConnFd        *send_fds;
 };
 
 #define XTRANS_OPEN_COTS_CLIENT       1
@@ -275,6 +289,16 @@ typedef struct _Xtransport {
 	int			/* size */
     );
 
+    int (*SendFd)(
+	XtransConnInfo,		/* connection */
+        int,                    /* fd */
+        int                     /* do_close */
+    );
+
+    int (*RecvFd)(


Reply to: