<div dir="ltr">Hmm... I've got it!<div><br></div><div>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.</div><div><br></div><div>Thank you very much!</div></div><div class="gmail_extra"><br><div class="gmail_quote">2014-10-17 11:31 GMT-03:00 Uli Schlachter <span dir="ltr"><<a href="mailto:psychon@znc.in" target="_blank">psychon@znc.in</a>></span>:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hi,<br>
<br>
Am 17.10.2014 um 14:55 schrieb Laércio de Sousa:<br>
[...]<br>
<span class="">> I would like to establish this connection without having to set environment<br>
> variable XAUTHORITY. I know there's a funcion in XCB API called<br>
> xcb_connect_to_display_with_auth_info() which receives a<br>
> xcb_auth_info_t struct,<br>
> but I have absolutely no idea of how to build this struct given a<br>
> Xauthority file path.<br>
><br>
> How could I do it?<br>
> Thanks in advance!<br>
</span>[...]<br>
<br>
I never used this myself, but you could just look into xcb's source code to<br>
figure out how xcb_connect() gets its auth info.<br>
<br>
xcb_connect() just calls xcb_connect_with_auth_info() with NULL for the auth<br>
information. This function then uses _xcb_get_auth_info() to get the<br>
xcb_auth_info_t structure:<br>
<br>
<a href="http://cgit.freedesktop.org/xcb/libxcb/tree/src/xcb_util.c?id=382d306d6c44a9ece5551c210a932773b5cb94a5#n521" target="_blank">http://cgit.freedesktop.org/xcb/libxcb/tree/src/xcb_util.c?id=382d306d6c44a9ece5551c210a932773b5cb94a5#n521</a><br>
<br>
The function _xcb_get_auth_info() does some dances to get a Xauth*, then copies<br>
some information from it into the xcb_auth_info_t and calls compute_auth():<br>
<br>
<a href="http://cgit.freedesktop.org/xcb/libxcb/tree/src/xcb_auth.c?id=382d306d6c44a9ece5551c210a932773b5cb94a5#n344" target="_blank">http://cgit.freedesktop.org/xcb/libxcb/tree/src/xcb_auth.c?id=382d306d6c44a9ece5551c210a932773b5cb94a5#n344</a><br>
<br>
This function mostly shuffles some bytes around (does anyone use XDM AUTH?, I<br>
guess the AUTH_MC1 case should suffice for 90% of people):<br>
<br>
<a href="http://cgit.freedesktop.org/xcb/libxcb/tree/src/xcb_auth.c?id=382d306d6c44a9ece5551c210a932773b5cb94a5#n187" target="_blank">http://cgit.freedesktop.org/xcb/libxcb/tree/src/xcb_auth.c?id=382d306d6c44a9ece5551c210a932773b5cb94a5#n187</a><br>
<br>
Since you just have a Xauthority file path, you could use XauReadAuth() to read<br>
the FILE*. That gives you an Xauth* structure which you can hopefully use in the<br>
same way that libxcb uses it.<br>
<br>
Cheers,<br>
Uli<br>
<span class="HOEnZb"><font color="#888888">--<br>
"Are you preparing for another war, Plutarch?" I ask.<br>
"Oh, not now. Now we're in that sweet period where everyone agrees that our<br>
recent horrors should never be repeated," he says. "But collective thinking is<br>
usually short-lived. We're fickle, stupid beings with poor memories and a great<br>
gift for self-destruction.<br>
</font></span></blockquote></div><br><br clear="all"><div><br></div>-- <br><div dir="ltr"><div><b>Laércio de Sousa</b><br></div><div style="text-align:center"><div style="text-align:left"><i>Orientador de Informática</i></div><div style="text-align:left"><u>Escola Municipal "Professor Eulálio Gruppi"</u></div><div style="text-align:left"><i>Rua Ismael da Silva Mello, 559, Mogi Moderno</i></div><i><div style="text-align:left"><i>Mogi das Cruzes - SP</i></div><div style="text-align:left"><i>CEP 08717-390</i></div></i></div><div><span style="font-family:arial;font-size:small">Telefone: (11) 4726-8313</span></div></div>
</div>