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. _______________________________________________ [email protected]: X.Org development Archives: http://lists.x.org/archives/xorg-devel Info: http://lists.x.org/mailman/listinfo/xorg-devel
