summaryrefslogtreecommitdiffstats
path: root/channels.c
diff options
context:
space:
mode:
authorDamien Miller <djm@mindrot.org>2009-01-21 06:46:26 +0100
committerDamien Miller <djm@mindrot.org>2009-01-21 06:46:26 +0100
commit819dbb633af6e1970c6b3275882c85d458441500 (patch)
tree4ea9645c9b263ab5cac06a0c117890948bd5720c /channels.c
parent - (djm) [uidswap.c] bz#1412: Support >16 supplemental groups in OS X. (diff)
downloadopenssh-819dbb633af6e1970c6b3275882c85d458441500.tar.xz
openssh-819dbb633af6e1970c6b3275882c85d458441500.zip
- (djm) [channels.c] bz#1419: support "on demand" X11 forwarding via
launchd on OS X; patch from vgiffin AT apple.com, slightly tweaked; ok dtucker@
Diffstat (limited to '')
-rw-r--r--channels.c23
1 files changed, 21 insertions, 2 deletions
diff --git a/channels.c b/channels.c
index 5b7d6d649..8fcba783e 100644
--- a/channels.c
+++ b/channels.c
@@ -3078,7 +3078,7 @@ x11_create_display_inet(int x11_display_offset, int x11_use_localhost,
}
static int
-connect_local_xsocket(u_int dnr)
+connect_local_xsocket_path(const char *pathname)
{
int sock;
struct sockaddr_un addr;
@@ -3088,7 +3088,7 @@ connect_local_xsocket(u_int dnr)
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);
@@ -3096,6 +3096,14 @@ connect_local_xsocket(u_int dnr)
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)
{
@@ -3117,6 +3125,17 @@ x11_connect_display(void)
* connection to the real X server.
*/
+ /* Check if the display is from launchd. */
+#ifdef __APPLE__
+ 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;
+ }
+#endif
/*
* 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]