What's the right way to call xcb_connect_to_display_with_auth_info() given a Xauthority file?

LaƩrcio de Sousa laerciosousa at sme-mogidascruzes.sp.gov.br
Fri Oct 17 10:39:14 PDT 2014


Hmm... I've got it!

Based on your feedback, I've written a small patch for xcb_{util,auth}.c
introducing a new function xcb_connect_with_auth_file(). I'll submit it to
Xcb mailing list.

Thank you very much!

2014-10-17 11:31 GMT-03:00 Uli Schlachter <psychon at znc.in>:

> Hi,
>
> Am 17.10.2014 um 14:55 schrieb Laércio de Sousa:
> [...]
> > I would like to establish this connection without having to set
> environment
> > variable XAUTHORITY. I know there's a funcion in XCB API called
> > xcb_connect_to_display_with_auth_info() which receives a
> > xcb_auth_info_t struct,
> > but I have absolutely no idea of how to build this struct given a
> > Xauthority file path.
> >
> > How could I do it?
> > Thanks in advance!
> [...]
>
> I never used this myself, but you could just look into xcb's source code to
> figure out how xcb_connect() gets its auth info.
>
> xcb_connect() just calls xcb_connect_with_auth_info() with NULL for the
> auth
> information. This function then uses _xcb_get_auth_info() to get the
> xcb_auth_info_t structure:
>
>
> http://cgit.freedesktop.org/xcb/libxcb/tree/src/xcb_util.c?id=382d306d6c44a9ece5551c210a932773b5cb94a5#n521
>
> The function _xcb_get_auth_info() does some dances to get a Xauth*, then
> copies
> some information from it into the xcb_auth_info_t and calls compute_auth():
>
>
> http://cgit.freedesktop.org/xcb/libxcb/tree/src/xcb_auth.c?id=382d306d6c44a9ece5551c210a932773b5cb94a5#n344
>
> This function mostly shuffles some bytes around (does anyone use XDM
> AUTH?, I
> guess the AUTH_MC1 case should suffice for 90% of people):
>
>
> http://cgit.freedesktop.org/xcb/libxcb/tree/src/xcb_auth.c?id=382d306d6c44a9ece5551c210a932773b5cb94a5#n187
>
> Since you just have a Xauthority file path, you could use XauReadAuth() to
> read
> the FILE*. That gives you an Xauth* structure which you can hopefully use
> in the
> same way that libxcb uses it.
>
> Cheers,
> Uli
> --
> "Are you preparing for another war, Plutarch?" I ask.
> "Oh, not now. Now we're in that sweet period where everyone agrees that our
> recent horrors should never be repeated," he says. "But collective
> thinking is
> usually short-lived. We're fickle, stupid beings with poor memories and a
> great
> gift for self-destruction.
>



-- 
*Laércio de Sousa*
*Orientador de Informática*
*Escola Municipal "Professor Eulálio Gruppi"*
*Rua Ismael da Silva Mello, 559, Mogi Moderno*
*Mogi das Cruzes - SPCEP 08717-390*
Telefone: (11) 4726-8313
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.x.org/archives/xorg-devel/attachments/20141017/51181cae/attachment.html>


More information about the xorg-devel mailing list