diff options
author | Damien Miller <djm@mindrot.org> | 2009-01-21 16:46:26 +1100 |
---|---|---|
committer | Damien Miller <djm@mindrot.org> | 2009-01-21 16:46:26 +1100 |
commit | 819dbb633af6e1970c6b3275882c85d458441500 (patch) | |
tree | 4ea9645c9b263ab5cac06a0c117890948bd5720c | |
parent | 1598d6bc559b766e1fde83d9d9e4929d2694b090 (diff) |
- (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@
-rw-r--r-- | ChangeLog | 5 | ||||
-rw-r--r-- | channels.c | 23 |
2 files changed, 25 insertions, 3 deletions
@@ -1,6 +1,9 @@ 20090107 - (djm) [uidswap.c] bz#1412: Support >16 supplemental groups in OS X. Patch based on one from vgiffin AT apple.com; ok dtucker@ + - (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@ 20090107 - (tim) [configure.ac defines.h openbsd-compat/port-uw.c @@ -5000,5 +5003,5 @@ OpenServer 6 and add osr5bigcrypt support so when someone migrates passwords between UnixWare and OpenServer they will still work. OK dtucker@ -$Id: ChangeLog,v 1.5158 2009/01/21 05:04:24 djm Exp $ +$Id: ChangeLog,v 1.5159 2009/01/21 05:46:26 djm Exp $ @@ -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] |