|
Lines 4354-4359
connect_local_xsocket(u_int dnr)
Link Here
|
| 4354 |
return connect_local_xsocket_path(buf); |
4354 |
return connect_local_xsocket_path(buf); |
| 4355 |
} |
4355 |
} |
| 4356 |
|
4356 |
|
|
|
4357 |
static int |
| 4358 |
is_path_to_xsocket(const char *display, char *path, size_t pathlen) |
| 4359 |
{ |
| 4360 |
char *dot; |
| 4361 |
struct stat sbuf; |
| 4362 |
|
| 4363 |
if (strlcpy(path, display, pathlen) >= pathlen) { |
| 4364 |
error("%s: display path too long", __func__); |
| 4365 |
return 0; |
| 4366 |
} |
| 4367 |
if (stat(path, &sbuf) == 0) { |
| 4368 |
return 1; |
| 4369 |
} |
| 4370 |
if ((dot = strrchr(path, '.')) != NULL) { |
| 4371 |
*dot = '\0'; |
| 4372 |
if (stat(path, &sbuf) == 0) |
| 4373 |
return 1; |
| 4374 |
} |
| 4375 |
|
| 4376 |
return 0; |
| 4377 |
} |
| 4378 |
|
| 4357 |
int |
4379 |
int |
| 4358 |
x11_connect_display(void) |
4380 |
x11_connect_display(void) |
| 4359 |
{ |
4381 |
{ |
|
Lines 4375-4391
x11_connect_display(void)
Link Here
|
| 4375 |
* connection to the real X server. |
4397 |
* connection to the real X server. |
| 4376 |
*/ |
4398 |
*/ |
| 4377 |
|
4399 |
|
| 4378 |
/* Check if the display is from launchd. */ |
|
|
| 4379 |
#ifdef __APPLE__ |
4400 |
#ifdef __APPLE__ |
| 4380 |
if (strncmp(display, "/tmp/launch", 11) == 0) { |
4401 |
/* Check if display is a path to a socket (as set by launchd). */ |
| 4381 |
sock = connect_local_xsocket_path(display); |
4402 |
{ |
| 4382 |
if (sock < 0) |
4403 |
char path[PATH_MAX]; |
| 4383 |
return -1; |
|
|
| 4384 |
|
4404 |
|
| 4385 |
/* OK, we now have a connection to the display. */ |
4405 |
if (is_path_to_xsocket(display, path, sizeof(path))) { |
| 4386 |
return sock; |
4406 |
debug("x11_connect_display: $DISPLAY is launchd"); |
|
|
4407 |
|
| 4408 |
/* Create a socket. */ |
| 4409 |
sock = connect_local_xsocket_path(path); |
| 4410 |
if (sock < 0) |
| 4411 |
return -1; |
| 4412 |
|
| 4413 |
/* OK, we now have a connection to the display. */ |
| 4414 |
return sock; |
| 4415 |
} |
| 4387 |
} |
4416 |
} |
| 4388 |
#endif |
4417 |
#endif |
|
|
4418 |
|
| 4389 |
/* |
4419 |
/* |
| 4390 |
* Check if it is a unix domain socket. Unix domain displays are in |
4420 |
* Check if it is a unix domain socket. Unix domain displays are in |
| 4391 |
* one of the following formats: unix:d[.s], :d[.s], ::d[.s] |
4421 |
* one of the following formats: unix:d[.s], :d[.s], ::d[.s] |