DVG-5142987_launchd_DISPLAY_for_X11.patch [plain text]
diff -uNr ../openssh-4.5p1.orig/channels.c ./channels.c
--- ../openssh-4.5p1.orig/channels.c 2006-08-29 18:07:40.000000000 -0700
+++ ./channels.c 2007-04-19 18:59:28.000000000 -0700
@@ -2954,7 +2954,7 @@
}
static int
-connect_local_xsocket(u_int dnr)
+connect_local_xsocket_path(const char *pathname)
{
int sock;
struct sockaddr_un addr;
@@ -2964,7 +2964,7 @@
error("socket: %.100s", strerror(errno));
memset(&addr, 0, sizeof(addr));
addr.sun_family = AF_UNIX;
- snprintf(addr.sun_path, sizeof addr.sun_path, _PATH_UNIX_X, dnr);
+ strlcpy(addr.sun_path, pathname, sizeof addr.sun_path);
if (connect(sock, (struct sockaddr *)&addr, sizeof(addr)) == 0)
return sock;
close(sock);
@@ -2972,6 +2972,14 @@
return -1;
}
+static int
+connect_local_xsocket(u_int dnr)
+{
+ char buf[1024];
+ snprintf(buf, sizeof buf, _PATH_UNIX_X, dnr);
+ return connect_local_xsocket_path(buf);
+}
+
int
x11_connect_display(void)
{
@@ -2994,9 +3002,18 @@
*/
/*
+ * Check if the display is from launchd, then...
* Check if it is a unix domain socket. Unix domain displays are in
* one of the following formats: unix:d[.s], :d[.s], ::d[.s]
*/
+ if (strncmp(display, "/tmp/launch", 11) == 0) {
+ sock = connect_local_xsocket_path(display);
+ if (sock < 0)
+ return -1;
+
+ /* OK, we now have a connection to the display. */
+ return sock;
+ }
if (strncmp(display, "unix:", 5) == 0 ||
display[0] == ':') {
/* Connect to the unix domain socket. */