2010-11-05 16:31:30 +00:00
|
|
|
diff -up openssh-5.3p1/channels.c.bz595935 openssh-5.3p1/channels.c
|
|
|
|
--- openssh-5.3p1/channels.c.bz595935 2010-08-12 14:19:28.000000000 +0200
|
|
|
|
+++ openssh-5.3p1/channels.c 2010-08-12 14:33:51.000000000 +0200
|
|
|
|
@@ -3185,7 +3185,7 @@ x11_create_display_inet(int x11_display_
|
2010-06-30 14:45:30 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
-connect_local_xsocket_path(const char *pathname)
|
|
|
|
+connect_local_xsocket_path(const char *pathname, int len)
|
|
|
|
{
|
|
|
|
int sock;
|
|
|
|
struct sockaddr_un addr;
|
2010-11-05 16:31:30 +00:00
|
|
|
@@ -3195,11 +3195,14 @@ connect_local_xsocket_path(const char *p
|
2010-06-30 14:45:30 +00:00
|
|
|
error("socket: %.100s", strerror(errno));
|
|
|
|
memset(&addr, 0, sizeof(addr));
|
|
|
|
addr.sun_family = AF_UNIX;
|
|
|
|
- strlcpy(addr.sun_path, pathname, sizeof addr.sun_path);
|
2010-11-05 16:31:30 +00:00
|
|
|
- if (connect(sock, (struct sockaddr *)&addr, sizeof(addr)) == 0)
|
2010-06-30 14:45:30 +00:00
|
|
|
+ if (len <= 0)
|
|
|
|
+ return -1;
|
|
|
|
+ if (len > sizeof addr.sun_path)
|
|
|
|
+ len = sizeof addr.sun_path;
|
2010-11-05 16:31:30 +00:00
|
|
|
+ memcpy(addr.sun_path, pathname, len);
|
|
|
|
+ if (connect(sock, (struct sockaddr *)&addr, sizeof addr - (sizeof addr.sun_path - len) ) == 0)
|
2010-06-30 14:45:30 +00:00
|
|
|
return sock;
|
|
|
|
close(sock);
|
2010-11-05 16:31:30 +00:00
|
|
|
- error("connect %.100s: %.100s", addr.sun_path, strerror(errno));
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
@@ -3207,8 +3210,21 @@ static int
|
2010-06-25 12:08:42 +00:00
|
|
|
connect_local_xsocket(u_int dnr)
|
|
|
|
{
|
|
|
|
char buf[1024];
|
2010-06-30 14:45:30 +00:00
|
|
|
- snprintf(buf, sizeof buf, _PATH_UNIX_X, dnr);
|
|
|
|
- return connect_local_xsocket_path(buf);
|
|
|
|
+ int len;
|
2010-06-25 12:08:42 +00:00
|
|
|
+#ifdef linux
|
|
|
|
+ int ret;
|
|
|
|
+#endif
|
2010-06-30 14:45:30 +00:00
|
|
|
+ len = snprintf(buf + 1, sizeof (buf) - 1, _PATH_UNIX_X, dnr);
|
2010-06-25 12:08:42 +00:00
|
|
|
+#ifdef linux
|
|
|
|
+ /* try abstract socket first */
|
|
|
|
+ buf[0] = '\0';
|
2010-06-30 14:45:30 +00:00
|
|
|
+ if ((ret = connect_local_xsocket_path(buf, len + 1)) >= 0)
|
2010-06-25 12:08:42 +00:00
|
|
|
+ return ret;
|
|
|
|
+#endif
|
2010-11-05 16:31:30 +00:00
|
|
|
+ if ((ret = connect_local_xsocket_path(buf + 1, len)) >= 0)
|
|
|
|
+ return ret;
|
|
|
|
+ error("connect %.100s: %.100s", buf + 1, strerror(errno));
|
|
|
|
+ return -1;
|
2010-06-25 12:08:42 +00:00
|
|
|
}
|
2010-06-24 07:02:37 +00:00
|
|
|
|
2010-06-30 14:45:30 +00:00
|
|
|
int
|