[Xcb] Question about a xcb_util.c commit

David Coppa dcoppa at gmail.com
Fri Jun 10 16:34:26 UTC 2016



Il 10 giugno 2016 17:27:34 CEST, Uli Schlachter <psychon at znc.in> ha scritto:
>Hi,
>
>Am 10.06.2016 um 16:30 schrieb David Coppa:
>> Hi all,
>> 
>> I have a question regarding this particular commit, "Fallback to
>> TCP if no protocol is specified and the UNIX connection fails",
>> that you can see at
>>
>https://cgit.freedesktop.org/xcb/libxcb/commit/?id=7d235c62f0d5bd0df1236cc52141c10c5d272a18
>> 
>> Does anyone know the rationale behind it?
>
>Not really, but if you want me to guess: No protocol specified can be
>interpreted as a wildcard, so why not try both?
>
>> It seems strange to me to try to connect via tcp if opening the
>> unix socket fails (because the X server crashed, for example).
>
>How about "the X server only listens on TCP and that's why the unix
>socket
>didn't work"?
>
>> I'm asking because this piece of code does not interact very well
>> with the way we're sandboxing some window managers (specifically
>> i3) using pledge() on OpenBSD.
>> 
>> When pledged, i3 is not allowed to open AF_INET sockets, only AF_UNIX
>> ones.
>
>Ok, so what is the problem here?
>
>Scenario 1: X server listens on the unix socket. XCB connects to the
>unix socket
>and everything works.
>
>Scenario 2: No X server running. The unix socket fails (because nothing
>listens
>on it), the TCP socket fails (permission denied, I guess). An error is
>reported.
>
>Also: When exactly does i3 pledge()? Does this break e.g.
>"DISPLAY=1.2.3.4:0
>i3"? I thought people were "angry" about wayland because it isn't as
>(pseudo)
>network transparent as X11

Yes, running a pledged i3 on a remote X server is not possible, because "inet" has not been declared in the allowed pledges. I think it's an acceptable compromise, and Xorg by default runs with 'nolisten tcp' btw, iirc...

Mine it's not really a problem, my question was mainly driven by curiosity.

We had a report by a user some time ago about i3 dumping core, after an X server crash, with a pledge related message:

i3(49392): syscall 97 "inet"

The X crash was caused by a bug in the radeon driver, while i3 was killed by the pledge subsystem because of restore_xcb_check_cb() (src/restore_layout.c). If it sees that the
connection to X has been lost, it calls restore_connect() which calls
libxcb's xcb_connect().
In libxcb that calls xcb_connect_to_display_with_auth_info() which calls
_xcb_open(), which calls _xcb_open_unix() and ususally that would be it,
but if opening the unix socket fails (beause X has fallen over) it tries
again to connect by calling _xcb_open_tcp() which sets up an AF_INET addrinfo and passes that to _xcb_socket().

Thanks for your insights!
David





More information about the Xcb mailing list