|
Lines 2954-2960
Link Here
|
| 2954 |
} |
2954 |
} |
| 2955 |
|
2955 |
|
| 2956 |
static int |
2956 |
static int |
| 2957 |
connect_local_xsocket(u_int dnr) |
2957 |
connect_local_xsocket_path(const char *pathname) |
| 2958 |
{ |
2958 |
{ |
| 2959 |
int sock; |
2959 |
int sock; |
| 2960 |
struct sockaddr_un addr; |
2960 |
struct sockaddr_un addr; |
|
Lines 2964-2970
Link Here
|
| 2964 |
error("socket: %.100s", strerror(errno)); |
2964 |
error("socket: %.100s", strerror(errno)); |
| 2965 |
memset(&addr, 0, sizeof(addr)); |
2965 |
memset(&addr, 0, sizeof(addr)); |
| 2966 |
addr.sun_family = AF_UNIX; |
2966 |
addr.sun_family = AF_UNIX; |
| 2967 |
snprintf(addr.sun_path, sizeof addr.sun_path, _PATH_UNIX_X, dnr); |
2967 |
strlcpy(addr.sun_path, pathname, sizeof addr.sun_path); |
| 2968 |
if (connect(sock, (struct sockaddr *)&addr, sizeof(addr)) == 0) |
2968 |
if (connect(sock, (struct sockaddr *)&addr, sizeof(addr)) == 0) |
| 2969 |
return sock; |
2969 |
return sock; |
| 2970 |
close(sock); |
2970 |
close(sock); |
|
Lines 2972-2977
Link Here
|
| 2972 |
return -1; |
2972 |
return -1; |
| 2973 |
} |
2973 |
} |
| 2974 |
|
2974 |
|
|
|
2975 |
static int |
| 2976 |
connect_local_xsocket(u_int dnr) |
| 2977 |
{ |
| 2978 |
char buf[1024]; |
| 2979 |
snprintf(buf, sizeof buf, _PATH_UNIX_X, dnr); |
| 2980 |
return connect_local_xsocket_path(buf); |
| 2981 |
} |
| 2982 |
|
| 2975 |
int |
2983 |
int |
| 2976 |
x11_connect_display(void) |
2984 |
x11_connect_display(void) |
| 2977 |
{ |
2985 |
{ |
|
Lines 2994-3002
Link Here
|
| 2994 |
*/ |
3002 |
*/ |
| 2995 |
|
3003 |
|
| 2996 |
/* |
3004 |
/* |
|
|
3005 |
* Check if the display is from launchd, then... |
| 2997 |
* Check if it is a unix domain socket. Unix domain displays are in |
3006 |
* Check if it is a unix domain socket. Unix domain displays are in |
| 2998 |
* one of the following formats: unix:d[.s], :d[.s], ::d[.s] |
3007 |
* one of the following formats: unix:d[.s], :d[.s], ::d[.s] |
| 2999 |
*/ |
3008 |
*/ |
|
|
3009 |
if (strncmp(display, "/tmp/launch", 11) == 0) { |
| 3010 |
sock = connect_local_xsocket_path(display); |
| 3011 |
if (sock < 0) |
| 3012 |
return -1; |
| 3013 |
|
| 3014 |
/* OK, we now have a connection to the display. */ |
| 3015 |
return sock; |
| 3016 |
} |
| 3000 |
if (strncmp(display, "unix:", 5) == 0 || |
3017 |
if (strncmp(display, "unix:", 5) == 0 || |
| 3001 |
display[0] == ':') { |
3018 |
display[0] == ':') { |
| 3002 |
/* Connect to the unix domain socket. */ |
3019 |
/* Connect to the unix domain socket. */ |