summaryrefslogtreecommitdiff
path: root/tools
diff options
context:
space:
mode:
authorEric Koegel <eric.koegel@gmail.com>2014-10-05 16:22:43 +0300
committerEric Koegel <eric.koegel@gmail.com>2014-10-05 16:22:43 +0300
commitbfb6fb08b8dbd7efc02a21c9d53cfc362d1b1786 (patch)
tree1d68b537d71277473df887686a824d4575540f86 /tools
parente081eb1b6a3cf1a0390bf3f784ec06a3123b480a (diff)
downloadConsoleKit2-bfb6fb08b8dbd7efc02a21c9d53cfc362d1b1786.tar.gz
Return early when remote DISPLAY variable set
When DISPLAY is set to a remote display, the remote display server is down/unreachable and you su from user to root (or some other user), this can take ~30 seconds+ to complete. ps reveals ck-get-x11-server-pid is waiting on network connection to the xserver that will eventually timeout. Since it is impossible to get the process ID of the other end of a TCP connection (manpages say Xlib uses TCP connections when DISPLAY has a hostname: part) this patch skips getting the PID for remote DISPLAYs. References: If the DISPLAY variable has a hostname component, e.g. "remotehost:0.0", XOpenDisplay will use a TCP connection to it, and the fd it returns later will be a TCP socket. (http://tronche.com/gui/x/xlib/display/opening.html) It is only possible to get the peer socket's PID for UNIX domain sockets. (E.g. On linux, SO_PEERCRED is only usable for UNIX domain sockets (i.e. PF_UNIX) )( http://linux.die.net/man/7/socket) Bug report and patch provided by Joe Mullally. https://bugs.launchpad.net/ubuntu/+source/consolekit/+bug/517323
Diffstat (limited to 'tools')
-rw-r--r--tools/ck-get-x11-server-pid.c5
1 files changed, 5 insertions, 0 deletions
diff --git a/tools/ck-get-x11-server-pid.c b/tools/ck-get-x11-server-pid.c
index 3324164..036a12a 100644
--- a/tools/ck-get-x11-server-pid.c
+++ b/tools/ck-get-x11-server-pid.c
@@ -47,6 +47,11 @@ display_init (int *argc, char ***argv)
exit (1);
}
+ if (display_name[0] != ':' && g_strrstr(display_name, ":") != NULL) {
+ g_warning ("DISPLAY is not a UNIX domain socket, can't get PID");
+ exit (1);
+ }
+
xdisplay = XOpenDisplay (display_name);
if (xdisplay == NULL) {
g_warning ("cannot open display: %s", display_name ? display_name : "");