diff options
-rw-r--r-- | COPYING | 2 | ||||
-rw-r--r-- | Xtrans.c | 39 | ||||
-rw-r--r-- | Xtransint.h | 16 | ||||
-rw-r--r-- | Xtranssock.c | 49 | ||||
-rw-r--r-- | Xtransutil.c | 14 | ||||
-rw-r--r-- | configure.ac | 2 | ||||
-rw-r--r-- | xtrans.m4 | 2 |
7 files changed, 56 insertions, 68 deletions
@@ -48,7 +48,7 @@ CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. ______________________________________________________________________________ -Copyright (c) 2002, 2005, Oracle and/or its affiliates. All rights reserved. +Copyright (c) 2002, 2005, Oracle and/or its affiliates. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), @@ -202,8 +202,8 @@ TRANS(ParseAddress) (const char *address, * If a "::" is found then assume DNET. */ - char *mybuf, *tmpptr; - const char *_protocol; + char *mybuf, *tmpptr = NULL; + const char *_protocol = NULL; char *_host, *_port; char hostnamebuf[256]; int _host_len; @@ -211,6 +211,28 @@ TRANS(ParseAddress) (const char *address, prmsg (3,"ParseAddress(%s)\n", address); + /* First, check for AF_UNIX socket paths */ + if (address[0] == '/') { + _protocol = "local"; + _host = ""; + _port = address; + } else +#ifdef HAVE_LAUNCHD + /* launchd sockets will look like 'local//tmp/launch-XgkNns/:0' */ + if(!strncmp(address,"local//",7)) { + _protocol="local"; + _host=""; + _port=address+6; + } else +#endif + if (!strncmp(address, "unix:", 5)) { + _protocol = "local"; + _host = ""; + _port = address + 5; + } + if (_protocol) + goto done_parsing; + /* Copy the string so it can be changed */ tmpptr = mybuf = strdup (address); @@ -332,15 +354,7 @@ TRANS(ParseAddress) (const char *address, */ #endif -#ifdef HAVE_LAUNCHD - /* launchd sockets will look like 'local//tmp/launch-XgkNns/:0' */ - if(address != NULL && strlen(address)>8 && (!strncmp(address,"local//",7))) { - _protocol="local"; - _host=""; - _port=address+6; - } -#endif - +done_parsing: /* * Now that we have all of the components, allocate new * string space for them. @@ -1173,6 +1187,9 @@ TRANS(MakeAllCOTSServerListeners) (const char *port, int *partial, if ((status = TRANS(CreateListener (ciptr, port, flags))) < 0) { + if (*partial != 0) + continue; + if (status == TRANS_ADDR_IN_USE) { /* diff --git a/Xtransint.h b/Xtransint.h index fe1f117..a43f7f8 100644 --- a/Xtransint.h +++ b/Xtransint.h @@ -297,7 +297,9 @@ 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) /* Don't unlink transport endpoints */ -#define TRANS_ABSTRACT (1<<5) /* Use abstract sockets if available */ +#define TRANS_ABSTRACT (1<<5) /* This previously meant that abstract sockets should be used available. For security + * reasons, this is now a no-op on the client side, but it is still supported for servers. + */ #define TRANS_NOXAUTH (1<<6) /* Don't verify authentication (because it's secure some other way at the OS layer) */ #define TRANS_RECEIVED (1<<7) /* The fd for this has already been opened by someone else. */ @@ -351,11 +353,6 @@ static int TRANS(WriteV)( #endif /* WIN32 */ - -static int is_numeric ( - const char * /* str */ -); - #ifdef TRANS_SERVER static int trans_mkdir ( const char *, /* path */ @@ -375,10 +372,11 @@ static int trans_mkdir ( #include <stdarg.h> /* - * The X server provides ErrorF() & VErrorF(), for other software that uses - * xtrans, we provide our own simple versions. + * The X server and the font server both provide ErrorF() & VErrorF(). For + * other software that uses xtrans, we provide our own simple + * versions. */ -# if defined(XSERV_t) && defined(TRANS_SERVER) +# if (defined(XSERV_t) || defined(TRANS_HAS_ERRORF)) && defined(TRANS_SERVER) # include "os.h" # else static inline void _X_ATTRIBUTE_PRINTF(1, 0) diff --git a/Xtranssock.c b/Xtranssock.c index 59b2924..4dca2d6 100644 --- a/Xtranssock.c +++ b/Xtranssock.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2002, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2002, Oracle and/or its affiliates. * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), @@ -141,7 +141,7 @@ from the copyright holders. /* others don't need this */ #define SocketInitOnce() /**/ -#ifdef linux +#ifdef __linux__ #define HAVE_ABSTRACT_SOCKETS #endif @@ -196,6 +196,20 @@ static Sockettrans2dev Sockettrans2devtab[] = { static int TRANS(SocketINETClose) (XtransConnInfo ciptr); #endif +#if defined(TCPCONN) || defined(TRANS_REOPEN) +static int +is_numeric (const char *str) +{ + int i; + + for (i = 0; i < (int) strlen (str); i++) + if (!isdigit (str[i])) + return (0); + + return (1); +} +#endif + #ifdef UNIXCONN @@ -1825,12 +1839,6 @@ TRANS(SocketUNIXConnect) (XtransConnInfo ciptr, struct sockaddr_un sockname; SOCKLEN_T namelen; - - 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); /* @@ -1866,7 +1874,7 @@ TRANS(SocketUNIXConnect) (XtransConnInfo ciptr, sockname.sun_family = AF_UNIX; - if (set_sun_path(port, UNIX_PATH, sockname.sun_path, abstract) != 0) { + if (set_sun_path(port, UNIX_PATH, sockname.sun_path, 0) != 0) { prmsg (1, "SocketUNIXConnect: path too long\n"); return TRANS_CONNECT_FAILED; } @@ -1882,16 +1890,6 @@ TRANS(SocketUNIXConnect) (XtransConnInfo ciptr, #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'; - } - /* * Do the connect() */ @@ -1925,15 +1923,7 @@ TRANS(SocketUNIXConnect) (XtransConnInfo ciptr, return TRANS_IN_PROGRESS; else if (olderrno == EINTR) return TRANS_TRY_CONNECT_AGAIN; - else if (olderrno == ENOENT || olderrno == ECONNREFUSED) { - /* If opening as abstract socket failed, try again normally */ - if (abstract) { - ciptr->transptr->flags &= ~(TRANS_ABSTRACT); - return TRANS_TRY_CONNECT_AGAIN; - } else { - return TRANS_CONNECT_FAILED; - } - } else { + else { prmsg (2,"SocketUNIXConnect: Can't connect: errno = %d\n", EGET()); @@ -1955,9 +1945,6 @@ TRANS(SocketUNIXConnect) (XtransConnInfo ciptr, return TRANS_CONNECT_FAILED; } - if (abstract) - sockname.sun_path[0] = '@'; - ciptr->family = AF_UNIX; ciptr->addrlen = namelen; ciptr->peeraddrlen = namelen; diff --git a/Xtransutil.c b/Xtransutil.c index 320f87b..c83e029 100644 --- a/Xtransutil.c +++ b/Xtransutil.c @@ -431,20 +431,6 @@ TRANS(WSAStartup) (void) } #endif -#include <ctype.h> - -static int -is_numeric (const char *str) -{ - int i; - - for (i = 0; i < (int) strlen (str); i++) - if (!isdigit (str[i])) - return (0); - - return (1); -} - #ifdef TRANS_SERVER #include <sys/types.h> #include <sys/stat.h> diff --git a/configure.ac b/configure.ac index 5786af9..f9b0e0b 100644 --- a/configure.ac +++ b/configure.ac @@ -21,7 +21,7 @@ # Initialize Autoconf AC_PREREQ([2.60]) -AC_INIT([xtrans], [1.4.0], +AC_INIT([xtrans], [1.5.0], [https://gitlab.freedesktop.org/xorg/lib/libxtrans/issues], [xtrans]) AC_CONFIG_SRCDIR([Makefile.am]) @@ -1,5 +1,5 @@ dnl -dnl Copyright (c) 2005, Oracle and/or its affiliates. All rights reserved. +dnl Copyright (c) 2005, Oracle and/or its affiliates. dnl dnl Permission is hereby granted, free of charge, to any person obtaining a dnl copy of this software and associated documentation files (the "Software"), |