summaryrefslogtreecommitdiff
path: root/channels.c
diff options
context:
space:
mode:
Diffstat (limited to 'channels.c')
-rw-r--r--channels.c34
1 files changed, 11 insertions, 23 deletions
diff --git a/channels.c b/channels.c
index 40a86dccb..97a865f56 100644
--- a/channels.c
+++ b/channels.c
@@ -39,7 +39,7 @@
39 */ 39 */
40 40
41#include "includes.h" 41#include "includes.h"
42RCSID("$OpenBSD: channels.c,v 1.146 2001/12/06 18:20:32 stevesk Exp $"); 42RCSID("$OpenBSD: channels.c,v 1.147 2001/12/08 17:49:28 stevesk Exp $");
43 43
44#include "ssh.h" 44#include "ssh.h"
45#include "ssh1.h" 45#include "ssh1.h"
@@ -54,6 +54,7 @@ RCSID("$OpenBSD: channels.c,v 1.146 2001/12/06 18:20:32 stevesk Exp $");
54#include "canohost.h" 54#include "canohost.h"
55#include "key.h" 55#include "key.h"
56#include "authfd.h" 56#include "authfd.h"
57#include "pathnames.h"
57 58
58 59
59/* -- channel core */ 60/* -- channel core */
@@ -2491,34 +2492,21 @@ x11_create_display_inet(int x11_display_offset, int gateway_ports)
2491 return display_number; 2492 return display_number;
2492} 2493}
2493 2494
2494#ifndef X_UNIX_PATH
2495#define X_UNIX_PATH "/tmp/.X11-unix/X"
2496#endif
2497
2498static int 2495static int
2499connect_local_xsocket(u_int dnr) 2496connect_local_xsocket(u_int dnr)
2500{ 2497{
2501 static const char *const x_sockets[] = {
2502 X_UNIX_PATH "%u",
2503 "/var/X/.X11-unix/X" "%u",
2504 "/usr/spool/sockets/X11/" "%u",
2505 NULL
2506 };
2507 int sock; 2498 int sock;
2508 struct sockaddr_un addr; 2499 struct sockaddr_un addr;
2509 const char *const * path;
2510 2500
2511 for (path = x_sockets; *path; ++path) { 2501 sock = socket(AF_UNIX, SOCK_STREAM, 0);
2512 sock = socket(AF_UNIX, SOCK_STREAM, 0); 2502 if (sock < 0)
2513 if (sock < 0) 2503 error("socket: %.100s", strerror(errno));
2514 error("socket: %.100s", strerror(errno)); 2504 memset(&addr, 0, sizeof(addr));
2515 memset(&addr, 0, sizeof(addr)); 2505 addr.sun_family = AF_UNIX;
2516 addr.sun_family = AF_UNIX; 2506 snprintf(addr.sun_path, sizeof addr.sun_path, _PATH_UNIX_X, dnr);
2517 snprintf(addr.sun_path, sizeof addr.sun_path, *path, dnr); 2507 if (connect(sock, (struct sockaddr *) & addr, sizeof(addr)) == 0)
2518 if (connect(sock, (struct sockaddr *) & addr, sizeof(addr)) == 0) 2508 return sock;
2519 return sock; 2509 close(sock);
2520 close(sock);
2521 }
2522 error("connect %.100s: %.100s", addr.sun_path, strerror(errno)); 2510 error("connect %.100s: %.100s", addr.sun_path, strerror(errno));
2523 return -1; 2511 return -1;
2524} 2512}