xtrans: Changes to 'upstream-experimental'
Xtrans.c | 30 ++++--
Xtrans.h | 6 -
Xtransdnet.c | 6 -
Xtransint.h | 16 +--
Xtranslcl.c | 10 --
Xtranssock.c | 255 ++++++++++++++++++++++++++++++++++++++++++-----------------
Xtranstli.c | 6 -
Xtransutil.c | 14 +--
configure.ac | 5 -
transport.c | 6 -
xtrans.m4 | 18 +++-
11 files changed, 237 insertions(+), 135 deletions(-)
New commits:
commit 81d8bdced6b45ab2ab3d3a0bc164ddbf1659fea1
Author: Adam Jackson <ajax@redhat.com>
Date: Wed Jul 2 15:24:20 2008 -0400
xtrans 1.2.1
diff --git a/configure.ac b/configure.ac
index 304fd6b..803dc23 100644
--- a/configure.ac
+++ b/configure.ac
@@ -21,7 +21,7 @@ dnl
dnl Process this file with autoconf to create configure.
AC_PREREQ([2.57])
-AC_INIT(xtrans, 1.2, [https://bugs.freedesktop.org/enter_bug.cgi?product=xorg], xtrans)
+AC_INIT(xtrans, 1.2.1, [https://bugs.freedesktop.org/enter_bug.cgi?product=xorg], xtrans)
AM_INIT_AUTOMAKE([dist-bzip2])
AM_MAINTAINER_MODE
commit 302af17c4d5f0293a9af4d6c1097ab57a57d3f0f
Author: Alan Coopersmith <alan.coopersmith@sun.com>
Date: Tue Jun 24 15:45:38 2008 -0700
Clear some pointer type mismatch warnings
diff --git a/Xtranssock.c b/Xtranssock.c
index 309839c..ff37782 100644
--- a/Xtranssock.c
+++ b/Xtranssock.c
@@ -566,10 +566,10 @@ TRANS(SocketReopen) (int i, int type, int fd, char *port)
PRMSG (1, "SocketReopen: malloc(addr) failed\n", 0, 0, 0);
return NULL;
}
- ciptr->addr = addr;
+ ciptr->addr = (char *) addr;
ciptr->addrlen = portlen + 2;
- if ((ciptr->peeraddr = (struct sockaddr *) xcalloc (1, portlen + 2)) == NULL) {
+ if ((ciptr->peeraddr = (char *) xcalloc (1, portlen + 2)) == NULL) {
PRMSG (1, "SocketReopen: malloc(portaddr) failed\n", 0, 0, 0);
return NULL;
}
commit 4d184e41d30a8fe27380e04beb24f775d4a40782
Author: Alan Coopersmith <alan.coopersmith@sun.com>
Date: Tue Jun 24 15:45:18 2008 -0700
LocalClose() takes a ConnInfoPtr, not an fd
diff --git a/Xtranslcl.c b/Xtranslcl.c
index 0127d67..addbc62 100644
--- a/Xtranslcl.c
+++ b/Xtranslcl.c
@@ -858,7 +858,7 @@ TRANS(NAMEDOpenServer)(XtransConnInfo ciptr, char *port)
if (TRANS(FillAddrInfo) (ciptr, server_path, server_path) == 0)
{
PRMSG(1,"NAMEDOpenServer: failed to fill in addr info\n", 0,0,0);
- TRANS(LocalClose)(fd);
+ TRANS(LocalClose)(ciptr);
return -1;
}
commit 177c2fd41727bd0110b493933dcbdbf21878fe09
Author: Jeremy Huddleston <jeremyhu@freedesktop.org>
Date: Fri May 23 09:48:59 2008 -0700
Launchd: This functionality has been moved into xorg-server
diff --git a/Xtrans.c b/Xtrans.c
index 48b7497..b6b3224 100644
--- a/Xtrans.c
+++ b/Xtrans.c
@@ -48,9 +48,6 @@ from The Open Group.
*/
#include <ctype.h>
-#ifdef HAVE_LAUNCHD
-#include <launch.h>
-#endif
/*
* The transport table contains a definition for every transport (protocol)
@@ -866,7 +863,7 @@ TRANS(Connect) (XtransConnInfo ciptr, char *address)
}
#ifdef HAVE_LAUNCHD
- if (!host || !*host) host=strdup("");
+ if (!host) host=strdup("");
#endif
if (!port || !*port)
@@ -1064,11 +1061,6 @@ TRANS(MakeAllCOTSServerListeners) (char *port, int *partial, int *count_ret,
char buffer[256]; /* ??? What size ?? */
XtransConnInfo ciptr, temp_ciptrs[NUMTRANS];
int status, i, j;
-#ifdef HAVE_LAUNCHD
- int launchd_fd;
- launch_data_t sockets_dict, checkin_request, checkin_response;
- launch_data_t listening_fd_array, listening_fd;
-#endif
#if defined(IPv6) && defined(AF_INET6)
int ipv6_succ = 0;
@@ -1078,59 +1070,6 @@ TRANS(MakeAllCOTSServerListeners) (char *port, int *partial, int *count_ret,
*count_ret = 0;
-#ifdef HAVE_LAUNCHD
- /* Get launchd fd */
- if ((checkin_request = launch_data_new_string(LAUNCH_KEY_CHECKIN)) == NULL) {
- fprintf(stderr,"launch_data_new_string(\"" LAUNCH_KEY_CHECKIN "\") Unable to create string.\n");
- goto not_launchd;
- }
-
- if ((checkin_response = launch_msg(checkin_request)) == NULL) {
- fprintf(stderr,"launch_msg(\"" LAUNCH_KEY_CHECKIN "\") IPC failure: %s\n",strerror(errno));
- goto not_launchd;
- }
-
- if (LAUNCH_DATA_ERRNO == launch_data_get_type(checkin_response)) {
- // ignore EACCES, which is common if we weren't started by launchd
- if (launch_data_get_errno(checkin_response) != EACCES)
- fprintf(stderr,"launchd check-in failed: %s\n",strerror(launch_data_get_errno(checkin_response)));
- goto not_launchd;
- }
-
- sockets_dict = launch_data_dict_lookup(checkin_response, LAUNCH_JOBKEY_SOCKETS);
- if (NULL == sockets_dict) {
- fprintf(stderr,"launchd check-in: no sockets found to answer requests on!\n");
- goto not_launchd;
- }
-
- if (launch_data_dict_get_count(sockets_dict) > 1) {
- fprintf(stderr,"launchd check-in: some sockets will be ignored!\n");
- goto not_launchd;
- }
-
- listening_fd_array = launch_data_dict_lookup(sockets_dict, ":0");
- if (NULL == listening_fd_array) {
- fprintf(stderr,"launchd check-in: No known sockets found to answer requests on!\n");
- goto not_launchd;
- }
-
- if (launch_data_array_get_count(listening_fd_array)!=1) {
- fprintf(stderr,"launchd check-in: Expected 1 socket from launchd, got %d)\n",
- launch_data_array_get_count(listening_fd_array));
- goto not_launchd;
- }
-
- listening_fd=launch_data_array_get_index(listening_fd_array, 0);
- launchd_fd=launch_data_get_fd(listening_fd);
- fprintf(stderr,"Xquartz: run by launchd for fd %d\n",launchd_fd);
- if((ciptr = TRANS(ReopenCOTSServer(TRANS_SOCKET_LOCAL_INDEX,
- launchd_fd, getenv("DISPLAY"))))==NULL)
- fprintf(stderr,"Got NULL while trying to Reopen launchd port\n");
- else temp_ciptrs[(*count_ret)++] = ciptr;
-
-not_launchd:
-#endif
-
for (i = 0; i < NUMTRANS; i++)
{
Xtransport *trans = Xtransports[i].transport;
commit 02fcb08803dca5bb2df4f8be490a845659bd7ed3
Author: Adam Jackson <ajax@redhat.com>
Date: Mon May 12 17:49:41 2008 -0400
Connection failure for abstract socket is ECONNREFUSED, not ENOENT.
Apropos of bug #15884.
diff --git a/Xtranssock.c b/Xtranssock.c
index 8b8e4a9..309839c 100644
--- a/Xtranssock.c
+++ b/Xtranssock.c
@@ -2161,7 +2161,7 @@ TRANS(SocketUNIXConnect) (XtransConnInfo ciptr, char *host, char *port)
return TRANS_IN_PROGRESS;
else if (olderrno == EINTR)
return TRANS_TRY_CONNECT_AGAIN;
- else if (olderrno == ENOENT) {
+ else if (olderrno == ENOENT || olderrno == ECONNREFUSED) {
/* If opening as abstract socket failed, try again normally */
if (abstract) {
ciptr->transptr->flags &= ~(TRANS_ABSTRACT);
commit 906294025573d07c739894fa3b2eedc82813a379
Author: Bill Nottingham <notting@redhat.com>
Date: Mon May 12 17:43:36 2008 -0400
Ignore mkdir() errors when creating the abstract socket.
Red Hat bug #445303.
diff --git a/Xtranssock.c b/Xtranssock.c
index 9be7f5a..8b8e4a9 100644
--- a/Xtranssock.c
+++ b/Xtranssock.c
@@ -1148,7 +1148,7 @@ TRANS(SocketUNIXCreateListener) (XtransConnInfo ciptr, char *port,
#else
mode = 0777;
#endif
- if (trans_mkdir(UNIX_DIR, mode) == -1) {
+ if (!abstract && trans_mkdir(UNIX_DIR, mode) == -1) {
PRMSG (1, "SocketUNIXCreateListener: mkdir(%s) failed, errno = %d\n",
UNIX_DIR, errno, 0);
(void) umask (oldUmask);
commit 08134c2ce72bc43c172b6ae134d8a94a40b45c9b
Author: James Cloos <cloos@jhcloos.com>
Date: Sat May 10 07:02:09 2008 -0400
Remove extraneous execute bit from .c file
diff --git a/Xtransutil.c b/Xtransutil.c
old mode 100755
new mode 100644
commit e75b9dad0ae4bc0869af81652d8259675a3c5cac
Author: Julien Cristau <jcristau@debian.org>
Date: Thu May 8 16:27:29 2008 +0200
Bump to 1.2
diff --git a/configure.ac b/configure.ac
index 0846bf1..304fd6b 100644
--- a/configure.ac
+++ b/configure.ac
@@ -21,7 +21,7 @@ dnl
dnl Process this file with autoconf to create configure.
AC_PREREQ([2.57])
-AC_INIT(xtrans, 1.1, [https://bugs.freedesktop.org/enter_bug.cgi?product=xorg], xtrans)
+AC_INIT(xtrans, 1.2, [https://bugs.freedesktop.org/enter_bug.cgi?product=xorg], xtrans)
AM_INIT_AUTOMAKE([dist-bzip2])
AM_MAINTAINER_MODE
commit 962ad4d3f8096f5ffa14b32b3ee094f250790c77
Author: Alan Hourihane <alanh@tungstengraphics.com>
Date: Mon Apr 28 23:46:05 2008 +0100
disable UNIXCONN on MINGW
diff --git a/xtrans.m4 b/xtrans.m4
index dfc5dd3..31d456b 100644
--- a/xtrans.m4
+++ b/xtrans.m4
@@ -67,17 +67,21 @@ AC_INCLUDES_DEFAULT
AC_DEFUN([XTRANS_CONNECTION_FLAGS],[
AC_REQUIRE([AC_CANONICAL_HOST])
AC_REQUIRE([AC_TYPE_SIGNAL])
+ [case $host_os in
+ mingw*) unixdef="no" ;;
+ *) unixdef="yes" ;;
+ esac]
AC_ARG_ENABLE(unix-transport,
AC_HELP_STRING([--enable-unix-transport],[Enable UNIX domain socket transport]),
- [UNIXCONN=$enableval], [UNIXCONN=yes])
- AC_ARG_ENABLE(tcp-transport,
- AC_HELP_STRING([--enable-tcp-transport],[Enable TCP socket transport]),
- [TCPCONN=$enableval], [TCPCONN=yes])
+ [UNIXCONN=$enableval], [UNIXCONN=$unixdef])
AC_MSG_CHECKING([if Xtrans should support UNIX socket connections])
if test "$UNIXCONN" = "yes"; then
AC_DEFINE(UNIXCONN,1,[Support UNIX socket connections])
fi
AC_MSG_RESULT($UNIXCONN)
+ AC_ARG_ENABLE(tcp-transport,
+ AC_HELP_STRING([--enable-tcp-transport],[Enable TCP socket transport]),
+ [TCPCONN=$enableval], [TCPCONN=yes])
AC_MSG_CHECKING([if Xtrans should support TCP socket connections])
AC_MSG_RESULT($TCPCONN)
if test "$TCPCONN" = "yes"; then
commit 9e8c0e3356bc6359368b7655d3a717d6c000387e
Author: Alan Hourihane <alanh@tungstengraphics.com>
Date: Sat Apr 26 16:23:19 2008 +0100
fix build for MAKEWORD
diff --git a/Xtransutil.c b/Xtransutil.c
old mode 100644
new mode 100755
index 9906367..f68b1e7
--- a/Xtransutil.c
+++ b/Xtransutil.c
@@ -57,6 +57,10 @@ from The Open Group.
#ifdef XTHREADS
#include <X11/Xthreads.h>
#endif
+#ifdef WIN32
+#include <X11/Xlibint.h>
+#include <X11/Xwinsock.h>
+#endif
#ifdef X11_t
commit 568c5ea02ee1de437833ee0b53a7b3fd7ece084f
Author: Colin Harrison <colin.harrison-at-virgin.net>
Date: Sat Apr 26 08:53:13 2008 +0100
Update to winsock2
diff --git a/Xtransutil.c b/Xtransutil.c
index a35c84b..9906367 100644
--- a/Xtransutil.c
+++ b/Xtransutil.c
@@ -479,7 +479,7 @@ TRANS(WSAStartup) (void)
PRMSG (2,"WSAStartup()\n", 0, 0, 0);
- if (!wsadata.wVersion && WSAStartup(0x0101, &wsadata))
+ if (!wsadata.wVersion && WSAStartup(MAKEWORD(2,2), &wsadata))
return 1;
return 0;
}
commit 960902584a3ef125946beb5ebe331b54d697e9d9
Author: James Cloos <cloos@jhcloos.com>
Date: Fri Apr 25 15:53:20 2008 -0400
Fix length calculation for the path for abstract unix domain sockets
Since the struct has a fixed-lenght char[] its sizeof() contains
trailing NUL octets which results in corrupt abstract sockets.
Instead, take the strlen(3) of the path, plus the single NUL octet
(which identifies the path as an abstract path rather than a file-
system path) plus the offset from the start of the struct to the
start of the char array.
This fixes:
https://bugs.freedesktop.org/show_bug.cgi?id=15677
diff --git a/Xtranssock.c b/Xtranssock.c
index 8f64429..9be7f5a 100644
--- a/Xtranssock.c
+++ b/Xtranssock.c
@@ -1180,7 +1180,7 @@ TRANS(SocketUNIXCreateListener) (XtransConnInfo ciptr, char *port,
if (abstract) {
sockname.sun_path[0] = '\0';
- namelen = sizeof(sockname);
+ namelen = offsetof(struct sockaddr_un, sun_path) + 1 + strlen(&sockname.sun_path[1]);
}
else
unlink (sockname.sun_path);
commit 3a2a5375b8aab85697b4f2644ab99c3ccf79e658
Author: Colin Harrison <colin.harrison-at-virgin.net>
Date: Wed Apr 23 10:39:30 2008 +0100
Only call WSAGetLastError() if there has been an
error condition.
diff --git a/Xtranssock.c b/Xtranssock.c
index 5ac6a62..8f64429 100644
--- a/Xtranssock.c
+++ b/Xtranssock.c
@@ -2221,7 +2221,7 @@ TRANS(SocketBytesReadable) (XtransConnInfo ciptr, BytesReadable_t *pend)
#ifdef WIN32
{
int ret = ioctlsocket ((SOCKET) ciptr->fd, FIONREAD, (u_long *) pend);
- errno = WSAGetLastError();
+ if (ret == SOCKET_ERROR) errno = WSAGetLastError();
return ret;
}
#else
@@ -2248,7 +2248,7 @@ TRANS(SocketRead) (XtransConnInfo ciptr, char *buf, int size)
{
int ret = recv ((SOCKET)ciptr->fd, buf, size, 0);
#ifdef WIN32
- errno = WSAGetLastError();
+ if (ret == SOCKET_ERROR) errno = WSAGetLastError();
#endif
return ret;
}
@@ -2268,7 +2268,7 @@ TRANS(SocketWrite) (XtransConnInfo ciptr, char *buf, int size)
{
int ret = send ((SOCKET)ciptr->fd, buf, size, 0);
#ifdef WIN32
- errno = WSAGetLastError();
+ if (ret == SOCKET_ERROR) errno = WSAGetLastError();
#endif
return ret;
}
@@ -2307,7 +2307,7 @@ TRANS(SocketDisconnect) (XtransConnInfo ciptr)
#ifdef WIN32
{
int ret = shutdown (ciptr->fd, 2);
- errno = WSAGetLastError();
+ if (ret == SOCKET_ERROR) errno = WSAGetLastError();
return ret;
}
#else
@@ -2326,7 +2326,7 @@ TRANS(SocketINETClose) (XtransConnInfo ciptr)
#ifdef WIN32
{
int ret = close (ciptr->fd);
- errno = WSAGetLastError();
+ if (ret == SOCKET_ERROR) errno = WSAGetLastError();
return ret;
}
#else
commit ac13a1a34b61247a21da130f0ba9922f35d3dc3b
Author: Alan Coopersmith <alan.coopersmith@sun.com>
Date: Tue Apr 15 12:32:35 2008 -0700
Sun bug #6688467: _X11TransConvertAddress: Unknown family type on 64-bit SPARC
Check for socklen_t definition and if found use it instead of size_t or
int for the length argument to getpeername/getsockname/etc.
<http://bugs.opensolaris.org/bugdatabase/view_bug.do?bug_id=6688467>
diff --git a/Xtranssock.c b/Xtranssock.c
index da4afe9..5ac6a62 100644
--- a/Xtranssock.c
+++ b/Xtranssock.c
@@ -281,6 +281,14 @@ static int TRANS(SocketINETClose) (XtransConnInfo ciptr);
#define MAXHOSTNAMELEN 255
#endif
+#if defined HAVE_SOCKLEN_T || (defined(IPv6) && defined(AF_INET6))
+# define SOCKLEN_T socklen_t
+#elif defined(SVR4) || defined(__SCO__)
+# define SOCKLEN_T size_t
+#else
+# define SOCKLEN_T int
+#endif
+
/*
* This provides compatibility for apps linked against system libraries
* that don't have IPv6 support.
@@ -330,11 +338,7 @@ TRANS(SocketINETGetAddr) (XtransConnInfo ciptr)
#endif
struct sockaddr_in socknamev4;
void *socknamePtr;
-#if defined(SVR4) || defined(__SCO__)
- size_t namelen;
-#else
- int namelen;
-#endif
+ SOCKLEN_T namelen;
PRMSG (3,"SocketINETGetAddr(%p)\n", ciptr, 0, 0);
@@ -407,11 +411,7 @@ TRANS(SocketINETGetPeerAddr) (XtransConnInfo ciptr)
#endif
struct sockaddr_in socknamev4;
void *socknamePtr;
-#if defined(SVR4) || defined(__SCO__)
- size_t namelen;
-#else
- int namelen;
-#endif
+ SOCKLEN_T namelen;
#if defined(IPv6) && defined(AF_INET6)
if (haveIPv6 && ciptr->family == AF_INET6)
@@ -918,7 +918,7 @@ TRANS(SocketCreateListener) (XtransConnInfo ciptr,
int socknamelen, unsigned int flags)
{
- int namelen = socknamelen;
+ SOCKLEN_T namelen = socknamelen;
int fd = ciptr->fd;
int retry;
@@ -998,7 +998,7 @@ TRANS(SocketINETCreateListener) (XtransConnInfo ciptr, char *port, unsigned int
struct sockaddr_in sockname;
#endif
unsigned short sport;
- int namelen = sizeof(sockname);
+ SOCKLEN_T namelen = sizeof(sockname);
int status;
long tmpport;
#ifdef XTHREADS_NEEDS_BYNAMEPARAMS
@@ -1315,7 +1315,7 @@ TRANS(SocketINETAccept) (XtransConnInfo ciptr, int *status)
{
XtransConnInfo newciptr;
struct sockaddr_in sockname;
- int namelen = sizeof(sockname);
+ SOCKLEN_T namelen = sizeof(sockname);
PRMSG (2, "SocketINETAccept(%p,%d)\n", ciptr, ciptr->fd, 0);
@@ -1394,11 +1394,7 @@ TRANS(SocketUNIXAccept) (XtransConnInfo ciptr, int *status)
{
XtransConnInfo newciptr;
struct sockaddr_un sockname;
-#if defined(SVR4) || defined(__SCO__)
- size_t namelen = sizeof sockname;
-#else
- int namelen = sizeof sockname;
-#endif
+ SOCKLEN_T namelen = sizeof sockname;
PRMSG (2, "SocketUNIXAccept(%p,%d)\n", ciptr, ciptr->fd, 0);
@@ -2031,11 +2027,11 @@ TRANS(SocketUNIXConnect) (XtransConnInfo ciptr, char *host, char *port)
{
struct sockaddr_un sockname;
- int namelen;
+ SOCKLEN_T namelen;
#if defined(hpux) && defined(X11_t)
struct sockaddr_un old_sockname;
- int old_namelen;
+ SOCKLEN_T old_namelen;
#endif
int abstract = 0;
diff --git a/xtrans.m4 b/xtrans.m4
index 1d80595..dfc5dd3 100644
--- a/xtrans.m4
+++ b/xtrans.m4
@@ -52,6 +52,12 @@ AC_DEFUN([XTRANS_TCP_FLAGS],[
#include <sys/socket.h>
#include <netinet/in.h>
])
+
+ # POSIX.1g changed the type of pointer passed to getsockname/getpeername/etc.
+ AC_CHECK_TYPES([socklen_t], [], [], [
+AC_INCLUDES_DEFAULT
+#include <sys/socket.h>])
+
]) # XTRANS_TCP_FLAGS
# XTRANS_CONNECTION_FLAGS()
commit 556a351de83fc6f401b02213dae95731553c216d
Author: Loïc Minier <lool@dooz.org>
Date: Mon Mar 24 15:38:27 2008 -0400
Bug #10489: Don't retry unix socket connect()s on ENOENT.
If the socket isn't there, it's not gonna magically appear. Either it's
a server socket and you should have just waited for the SIGUSR1 from the
server, or it's a stale reference to an ICE socket.
However, do retry once, so fallback from abstract to filesystem namespace
works.
Originally Debian bug #385976.
diff --git a/Xtranssock.c b/Xtranssock.c
index 8a7d2ec..da4afe9 100644
--- a/Xtranssock.c
+++ b/Xtranssock.c
@@ -2146,8 +2146,13 @@ TRANS(SocketUNIXConnect) (XtransConnInfo ciptr, char *host, char *port)
errno = olderrno;
/*
- * If the error was ENOENT, the server may be starting up
- * and we should try again.
+ * If the error was ENOENT, the server may be starting up; we used
+ * to suggest to try again in this case with
+ * TRANS_TRY_CONNECT_AGAIN, but this introduced problems for
+ * processes still referencing stale sockets in their environment.
+ * Hence, we now return a hard error, TRANS_CONNECT_FAILED, and it
+ * is suggested that higher level stacks handle retries on their
+ * level when they face a slow starting server.
*
* If the error was EWOULDBLOCK or EINPROGRESS then the socket
* was non-blocking and we should poll using select
@@ -2161,14 +2166,14 @@ TRANS(SocketUNIXConnect) (XtransConnInfo ciptr, char *host, char *port)
else if (olderrno == EINTR)
return TRANS_TRY_CONNECT_AGAIN;
else if (olderrno == ENOENT) {
- /*
- * If opening as abstract socket failed, try again "normally"
- */
- if (abstract)
+ /* If opening as abstract socket failed, try again normally */
+ if (abstract) {
ciptr->transptr->flags &= ~(TRANS_ABSTRACT);
- return TRANS_TRY_CONNECT_AGAIN;
- }
- else {
+ return TRANS_TRY_CONNECT_AGAIN;
+ } else {
+ return TRANS_CONNECT_FAILED;
+ }
+ } else {
PRMSG (2,"SocketUNIXConnect: Can't connect: errno = %d\n",
EGET(),0, 0);
commit 3de3e666e0653d4e8ae23fc3e6e31864ddad4059
Author: Julien Cristau <jcristau@debian.org>
Date: Sun Mar 23 19:43:32 2008 +0100
BSD44SOCKETS is the wrong check for SOCK_MAXADDRLEN
GNU/kFreeBSD defines BSD44SOCKETS, but doesn't have SOCK_MAXADDRLEN.
Check for the latter directly.
diff --git a/Xtranssock.c b/Xtranssock.c
index 94b73e2..8a7d2ec 100644
--- a/Xtranssock.c
+++ b/Xtranssock.c
@@ -540,7 +540,7 @@ TRANS(SocketReopen) (int i, int type, int fd, char *port)
}
portlen = strlen(port) + 1; // include space for trailing null
-#ifdef BSD44SOCKETS
+#ifdef SOCK_MAXADDRLEN
if (portlen < 0 || portlen > (SOCK_MAXADDRLEN + 2)) {
PRMSG (1, "SocketReopen: invalid portlen %d\n", portlen, 0, 0);
return NULL;
@@ -551,7 +551,7 @@ TRANS(SocketReopen) (int i, int type, int fd, char *port)
PRMSG (1, "SocketReopen: invalid portlen %d\n", portlen, 0, 0);
return NULL;
}
-#endif /*BSD44SOCKETS*/
+#endif /*SOCK_MAXADDRLEN*/
if ((ciptr = (XtransConnInfo) xcalloc (
1, sizeof(struct _XtransConnInfo))) == NULL)
commit 662994b9096181117cec4cae88f24bf6da806159
Author: Adam Jackson <ajax@redhat.com>
Date: Wed Mar 5 21:02:28 2008 -0500
xtrans 1.1
diff --git a/configure.ac b/configure.ac
index c713be8..0846bf1 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1,6 +1,3 @@
-dnl
-dnl $Id$
-dnl
dnl Copyright © 2003 Keith Packard, Noah Levitt
dnl
dnl Permission to use, copy, modify, distribute, and sell this software and its
@@ -24,7 +21,7 @@ dnl
dnl Process this file with autoconf to create configure.
AC_PREREQ([2.57])
-AC_INIT(xtrans, 1.0.4, [https://bugs.freedesktop.org/enter_bug.cgi?product=xorg], xtrans)
+AC_INIT(xtrans, 1.1, [https://bugs.freedesktop.org/enter_bug.cgi?product=xorg], xtrans)
AM_INIT_AUTOMAKE([dist-bzip2])
AM_MAINTAINER_MODE
commit 2afe206ec9569e0d62caa6d91c3fb057b0efa23d
Author: Adam Jackson <ajax@redhat.com>
Date: Wed Mar 5 20:48:59 2008 -0500
Add support for the abstract socket namespace under Linux.
Unlike normal unix sockets, the abstract namespace is not bound to the
filesystem. This has some notable advantages; /tmp need not exist, the
socket directory need not have magic permissions, etc. xtrans servers
will listen on both the normal and abstract socket endpoints; clients
will attempt to connect to the abstract socket before connecting to the
corresponding filesystem socket.
Based on a patch by Bill Crawford.
diff --git a/Xtransint.h b/Xtransint.h
index 97e8a89..317dbf8 100644
--- a/Xtransint.h
+++ b/Xtransint.h
@@ -369,9 +369,10 @@ typedef struct _Xtransport_table {
#define TRANS_DISABLED (1<<2) /* Don't open this one */
#define TRANS_NOLISTEN (1<<3) /* Don't listen on this one */
#define TRANS_NOUNLINK (1<<4) /* Dont unlink transport endpoints */
+#define TRANS_ABSTRACT (1<<5) /* Use abstract sockets if available */
/* Flags to preserve when setting others */
-#define TRANS_KEEPFLAGS (TRANS_NOUNLINK)
+#define TRANS_KEEPFLAGS (TRANS_NOUNLINK|TRANS_ABSTRACT)
/*
* readv() and writev() don't exist or don't work correctly on some
diff --git a/Xtranssock.c b/Xtranssock.c
index 646d634..94b73e2 100644
--- a/Xtranssock.c
+++ b/Xtranssock.c
@@ -158,6 +158,10 @@ static int IBMsockInit = 0;
#define SocketInitOnce() /**/
#endif
+#ifdef linux
+#define HAVE_ABSTRACT_SOCKETS
+#endif
+
#define MIN_BACKLOG 128
#ifdef SOMAXCONN
#if SOMAXCONN > MIN_BACKLOG
@@ -880,23 +884,28 @@ TRANS(SocketSetOption) (XtransConnInfo ciptr, int option, int arg)
#ifdef UNIXCONN
static int
-set_sun_path(const char *port, const char *upath, char *path)
+set_sun_path(const char *port, const char *upath, char *path, int abstract)
{
struct sockaddr_un s;
int maxlen = sizeof(s.sun_path) - 1;
+ const char *at = "";
if (!port || !*port || !path)
return -1;
- if (*port == '/') { /* a full pathname */
- if (strlen(port) > maxlen)
- return -1;
- sprintf(path, "%s", port);
- } else {
- if (strlen(port) + strlen(upath) > maxlen)
- return -1;
- sprintf(path, "%s%s", upath, port);
- }
+#ifdef HAVE_ABSTRACT_SOCKETS
+ if (port[0] == '@')
+ upath = "";
+ else if (abstract)
+ at = "@";
+#endif
+
+ if (*port == '/') /* a full pathname */
+ upath = "";
+
+ if (strlen(port) + strlen(upath) > maxlen)
+ return -1;
+ sprintf(path, "%s%s%s", at, upath, port);
return 0;
}
#endif
@@ -1119,6 +1128,12 @@ TRANS(SocketUNIXCreateListener) (XtransConnInfo ciptr, char *port,
int oldUmask;
int status;
unsigned int mode;
+ char tmpport[108];
+
+ int abstract = 0;
+#ifdef HAVE_ABSTRACT_SOCKETS
+ abstract = ciptr->transptr->flags & TRANS_ABSTRACT;
+#endif
PRMSG (2, "SocketUNIXCreateListener(%s)\n",
port ? port : "NULL", 0, 0);
@@ -1141,16 +1156,16 @@ TRANS(SocketUNIXCreateListener) (XtransConnInfo ciptr, char *port,
}
#endif
+ memset(&sockname, 0, sizeof(sockname));
sockname.sun_family = AF_UNIX;
- if (port && *port) {
- if (set_sun_path(port, UNIX_PATH, sockname.sun_path) != 0) {
- PRMSG (1, "SocketUNIXCreateListener: path too long\n", 0, 0, 0);
- return TRANS_CREATE_LISTENER_FAILED;
- }
- } else {
- snprintf (sockname.sun_path, sizeof(sockname.sun_path),
- "%s%ld", UNIX_PATH, (long)getpid());
+ if (!(port && *port)) {
+ snprintf (tmpport, sizeof(tmpport), "%s%ld", UNIX_PATH, (long)getpid());
+ port = tmpport;
+ }
+ if (set_sun_path(port, UNIX_PATH, sockname.sun_path, abstract) != 0) {
+ PRMSG (1, "SocketUNIXCreateListener: path too long\n", 0, 0, 0);
+ return TRANS_CREATE_LISTENER_FAILED;
}
#if (defined(BSD44SOCKETS) || defined(__UNIXWARE__)) && !defined(Lynx)
@@ -1163,7 +1178,12 @@ TRANS(SocketUNIXCreateListener) (XtransConnInfo ciptr, char *port,
namelen = strlen(sockname.sun_path) + offsetof(struct sockaddr_un, sun_path);
#endif
- unlink (sockname.sun_path);
+ if (abstract) {
+ sockname.sun_path[0] = '\0';
+ namelen = sizeof(sockname);
+ }
+ else
+ unlink (sockname.sun_path);
if ((status = TRANS(SocketCreateListener) (ciptr,
(struct sockaddr *) &sockname, namelen, flags)) < 0)
@@ -1193,6 +1213,9 @@ TRANS(SocketUNIXCreateListener) (XtransConnInfo ciptr, char *port,
return TRANS_CREATE_LISTENER_FAILED;
}
+ if (abstract)
+ sockname.sun_path[0] = '@';
+
ciptr->family = sockname.sun_family;
ciptr->addrlen = namelen;
memcpy (ciptr->addr, &sockname, ciptr->addrlen);
@@ -1215,16 +1238,22 @@ TRANS(SocketUNIXResetListener) (XtransConnInfo ciptr)
struct stat statb;
int status = TRANS_RESET_NOOP;
unsigned int mode;
+ int abstract = 0;
+#ifdef HAVE_ABSTRACT_SOCKETS
+ abstract = ciptr->transptr->flags & TRANS_ABSTRACT;
+#endif
PRMSG (3, "SocketUNIXResetListener(%p,%d)\n", ciptr, ciptr->fd, 0);
- if (stat (unsock->sun_path, &statb) == -1 ||
+ if (!abstract && (
+ stat (unsock->sun_path, &statb) == -1 ||
((statb.st_mode & S_IFMT) !=
#if (defined (sun) && defined(SVR4)) || defined(NCR) || defined(SCO325) || !defined(S_IFSOCK)
- S_IFIFO))
+ S_IFIFO
#else
- S_IFSOCK))
+ S_IFSOCK
#endif
+ )))
{
int oldUmask = umask (0);
@@ -1407,6 +1436,10 @@ TRANS(SocketUNIXAccept) (XtransConnInfo ciptr, int *status)
return NULL;
}
+ /*
+ * if the socket is abstract, we already modified the address to have a
+ * @ instead of the initial NUL, so no need to do that again here.
+ */
newciptr->addrlen = ciptr->addrlen;
memcpy (newciptr->addr, ciptr->addr, newciptr->addrlen);
@@ -2005,6 +2038,10 @@ TRANS(SocketUNIXConnect) (XtransConnInfo ciptr, char *host, char *port)
int old_namelen;
#endif
+ int abstract = 0;
+#ifdef HAVE_ABSTRACT_SOCKETS
+ abstract = ciptr->transptr->flags & TRANS_ABSTRACT;
+#endif
PRMSG (2,"SocketUNIXConnect(%d,%s,%s)\n", ciptr->fd, host, port);
@@ -2042,7 +2079,7 @@ TRANS(SocketUNIXConnect) (XtransConnInfo ciptr, char *host, char *port)
sockname.sun_family = AF_UNIX;
- if (set_sun_path(port, UNIX_PATH, sockname.sun_path) != 0) {
+ if (set_sun_path(port, UNIX_PATH, sockname.sun_path, abstract) != 0) {
PRMSG (1, "SocketUNIXConnect: path too long\n", 0, 0, 0);
return TRANS_CONNECT_FAILED;
}
@@ -2063,7 +2100,7 @@ TRANS(SocketUNIXConnect) (XtransConnInfo ciptr, char *host, char *port)
* This is gross, but it was in Xlib
*/
old_sockname.sun_family = AF_UNIX;
- if (set_sun_path(port, OLD_UNIX_PATH, old_sockname.sun_path) != 0) {
+ if (set_sun_path(port, OLD_UNIX_PATH, old_sockname.sun_path, abstract) != 0) {
PRMSG (1, "SocketUNIXConnect: path too long\n", 0, 0, 0);
return TRANS_CONNECT_FAILED;
}
@@ -2071,6 +2108,17 @@ TRANS(SocketUNIXConnect) (XtransConnInfo ciptr, char *host, char *port)
offsetof(struct sockaddr_un, sun_path);
#endif
+ /*
+ * Adjust the socket path if using abstract sockets.
+ * Done here because otherwise all the strlen() calls above would fail.
+ */
+
+ if (abstract) {
+ sockname.sun_path[0] = '\0';
+#if defined(hpux) && defined(X11_t)
+ old_sockname.sun_path[0] = '\0';
+#endif
+ }
/*
* Do the connect()
@@ -2108,12 +2156,19 @@ TRANS(SocketUNIXConnect) (XtransConnInfo ciptr, char *host, char *port)
* should try again.
*/
- if (olderrno == ENOENT || olderrno == EINTR)
- return TRANS_TRY_CONNECT_AGAIN;
- else if (olderrno == EWOULDBLOCK || olderrno == EINPROGRESS)
+ if (olderrno == EWOULDBLOCK || olderrno == EINPROGRESS)
return TRANS_IN_PROGRESS;
- else
- {
+ else if (olderrno == EINTR)
+ return TRANS_TRY_CONNECT_AGAIN;
+ else if (olderrno == ENOENT) {
+ /*
+ * If opening as abstract socket failed, try again "normally"
+ */
+ if (abstract)
+ ciptr->transptr->flags &= ~(TRANS_ABSTRACT);
+ return TRANS_TRY_CONNECT_AGAIN;
+ }
+ else {
PRMSG (2,"SocketUNIXConnect: Can't connect: errno = %d\n",
EGET(),0, 0);
@@ -2136,12 +2191,15 @@ TRANS(SocketUNIXConnect) (XtransConnInfo ciptr, char *host, char *port)
return TRANS_CONNECT_FAILED;
}
+ if (abstract)
+ sockname.sun_path[0] = '@';
+
ciptr->family = AF_UNIX;
ciptr->addrlen = namelen;
ciptr->peeraddrlen = namelen;
memcpy (ciptr->addr, &sockname, ciptr->addrlen);
memcpy (ciptr->peeraddr, &sockname, ciptr->peeraddrlen);
-
+
return 0;
}
@@ -2281,7 +2339,6 @@ TRANS(SocketINETClose) (XtransConnInfo ciptr)
#ifdef UNIXCONN
static int
TRANS(SocketUNIXClose) (XtransConnInfo ciptr)
-
{
/*
* If this is the server side, then once the socket is closed,
@@ -2300,7 +2357,8 @@ TRANS(SocketUNIXClose) (XtransConnInfo ciptr)
&& sockname->sun_family == AF_UNIX
&& sockname->sun_path[0])
{
- if (!(ciptr->flags & TRANS_NOUNLINK))
+ if (!(ciptr->flags & TRANS_NOUNLINK
+ || ciptr->transptr->flags & TRANS_ABSTRACT))
unlink (sockname->sun_path);
}
@@ -2467,7 +2525,11 @@ Xtransport TRANS(SocketINET6Funcs) = {
Xtransport TRANS(SocketLocalFuncs) = {
/* Socket Interface */
"local",
+#ifdef HAVE_ABSTRACT_SOCKETS
+ TRANS_ABSTRACT,
+#else
0,
+#endif
#ifdef TRANS_CLIENT
TRANS(SocketOpenCOTSClient),
#endif /* TRANS_CLIENT */
@@ -2513,7 +2575,7 @@ static char* unix_nolisten[] = { "local" , NULL };
Xtransport TRANS(SocketUNIXFuncs) = {
/* Socket Interface */
"unix",
-#if !defined(LOCALCONN)
+#if !defined(LOCALCONN) && !defined(HAVE_ABSTRACT_SOCKETS)
TRANS_ALIAS,
#else
0,
commit c8ed67f16f71042ef134a4d2189c20dd200a0648
Author: Jeremy Huddleston <jeremy@tifa.local>
Date: Sun Feb 10 19:04:40 2008 -0800
Fixed #ifdef checks that were using i386 to use __i386__
"""
It's simply obsolete, sloppy, compiler namespace pollution. The
compiler is not allowed to predefine symbols that might conflict with
ordinary identifiers. For backwards compatibility gcc currently
predefines i386 when compiling for x86 32-bit (but not 64-bit), but that
will go away. It is also not defined if you specify -ansi when invoking
the compiler, because then it is seriously standards compliant. Other
compilers shouldn't define it either. Correct code shouldn't rely on it
being defined. However __i386__ is safe and proper.
"""
Reply to: