Bug 15677 - Xlib does not support Unix Domain Sockets without XCB
Summary: Xlib does not support Unix Domain Sockets without XCB
Status: RESOLVED FIXED
Alias: None
Product: xorg
Classification: Unclassified
Component: Lib/Xlib (show other bugs)
Version: 7.3 (2007.09)
Hardware: x86 (IA32) Linux (All)
: low minor
Assignee: Xorg Project Team
QA Contact: Xorg Project Team
URL:
Whiteboard:
Keywords:
Depends on: 7987
Blocks: xorg-7.4
  Show dependency treegraph
 
Reported: 2008-04-23 08:29 UTC by Paul Bender
Modified: 2008-04-25 13:18 UTC (History)
0 users

See Also:
i915 platform:
i915 features:


Attachments
xtrans-1.1-abstract_namelen.patch (444 bytes, patch)
2008-04-25 05:14 UTC, Paul Bender
no flags Details | Splinter Review

Description Paul Bender 2008-04-23 08:29:58 UTC
When I build libX11 (1.1.4) without XCB support, Unix Domain Sockets no longer work. However, TCP/IP continues to work. Unfortunately, I have not tracked down the problem. Also, as this is the first time that I have checked to make sure that the system was using Unix Domain Sockets rather than TCP/IP, I am not sure when the broke.
Comment 1 Alan Coopersmith 2008-04-23 08:33:41 UTC
This should mostly be a function of the libxtrans source code you build
libX11 with - unfortunately libxtrans is not a proper shared libary, but
a shared set of *.c files that each library includes, so you have to 
install different versions and then rebuild libraries like libX11 against
them.    I would wonder if the abstract socket namespace changes in the
recent release of xtrans 1.1 are involved here.
Comment 2 Paul Bender 2008-04-23 15:51:36 UTC
You are on to something.

I am using xtrans 1.1.

I defined XTRANSDEBUG as 5 and recompiled. xorg-server creates the the normal Unix Domain Socket (unix) but appears to fail when creating the Abstract Socket (local). However, libX11 attempts to connect to the Abstract Socket (local) and fails. When I force the disabling of Abstract Sockets by commenting out its definition in Xtranssock.c and recompile libX11, then libX11 connects to the Unix Domain Socket and works.

Likewise, when I switch to xtrans 1.0.4, everything works.

I have not yet looked into why xorg-server appears to be failing to create the Abstract Socket.
Comment 3 James Cloos 2008-04-24 15:19:28 UTC
After reading this bug I upgraded xtrans from 1.0.4 (dist’s latest) to
git master and recompiled xcb, libX11 and xserver.

AFAICT, the server is listening on an abstract socket, but nothing is
using it.

(I’m presuming that the sockets in /proc/net/unix starting with @ are
the abstract ones:

,----[ grep -a @ /proc/net/unix ]
| da391b60: 00000002 00000000 00010000 0001 01 10197 @/tmp/.X11-unix/X0
| df236000: 00000002 00000000 00000000 0002 01   305 @/org/kernel/udev/udevd
`----

as those show up as ‘socket’ in lsof(8)’s output, rather than as a
path.)

It is likely relevant that the @/tmp/.X11-unix/X0 line above is followed
by 180 NULs octets in the /proc/net/unix file.  No other line has that.

So I suspect the kernel isn’t properly creating the socket.

I don’t see what is wrong in Xtranssock.c from a quick read thru.

Perhaps the problem you are seeing is also due to the NULs?
Comment 4 James Cloos 2008-04-24 15:35:48 UTC
Eek.  When reading comment #3 please:

s/kernel/xserver/

:-(
Comment 5 Alan Coopersmith 2008-04-24 19:20:01 UTC
Is this related to not including the NUL in the string length that
was reported in bug 7987?
Comment 6 James Cloos 2008-04-25 02:27:20 UTC
Yes, I think it is related.

From Xtranssock.c:

    if (abstract) {
        sockname.sun_path[0] = '\0';
        namelen = sizeof(sockname);
    }

    if ((status = TRANS(SocketCreateListener) (ciptr,
        (struct sockaddr *) &sockname, namelen, flags)) < 0)

I'm not sude namelen is correctly computed.  Udevd.c does it like this:

        addrlen = offsetof(struct sockaddr_un, sun_path) + 1 + strlen(&saddr.sun_path[1]);

(where sun_path[0] is already set to '\0'.)

By using strlen they end up with a length which leaves out the trailing '\0's,
whereas Xtranssock’s sizeof() will be 108 + sizeof(sa_family_t) + any padding.

I bet fixing the computation of namelen will fix both bugs.
Comment 7 Paul Bender 2008-04-25 05:14:15 UTC
Created attachment 16178 [details] [review]
xtrans-1.1-abstract_namelen.patch

(In reply to comment #6)

Yes, that length calculation does look wrong and the change you suggest fixed the problem. With the change, abstract sockets are working.

I have attached a patch against xtrans 1.1 that implements your suggested change.
Comment 8 James Cloos 2008-04-25 13:02:23 UTC
Pushed with commit 960902584a3ef125946beb5ebe331b54d697e9d9.


Use of freedesktop.org services, including Bugzilla, is subject to our Code of Conduct. How we collect and use information is described in our Privacy Policy.