|
49 | 49 | #include "sesman.h" |
50 | 50 | #include "string_calls.h" |
51 | 51 | #include "xauth.h" |
| 52 | +#include "xwait.h" |
52 | 53 | #include "xrdp_sockets.h" |
53 | 54 |
|
54 | 55 | #ifndef PR_SET_NO_NEW_PRIVS |
@@ -285,42 +286,6 @@ x_server_running_check_ports(int display) |
285 | 286 | return x_running; |
286 | 287 | } |
287 | 288 |
|
288 | | -/******************************************************************************/ |
289 | | -/** |
290 | | - * |
291 | | - * @brief checks if there's a server running on a display |
292 | | - * @param display the display to check |
293 | | - * @return 0 if there isn't a display running, nonzero otherwise |
294 | | - * |
295 | | - */ |
296 | | -static int |
297 | | -x_server_running(int display) |
298 | | -{ |
299 | | - char text[256]; |
300 | | - int x_running; |
301 | | - |
302 | | - g_sprintf(text, "/tmp/.X11-unix/X%d", display); |
303 | | - x_running = g_file_exist(text); |
304 | | - |
305 | | - if (!x_running) |
306 | | - { |
307 | | - LOG(LOG_LEVEL_DEBUG, "Did not find a running X server at %s", text); |
308 | | - g_sprintf(text, "/tmp/.X%d-lock", display); |
309 | | - x_running = g_file_exist(text); |
310 | | - } |
311 | | - |
312 | | - if (x_running) |
313 | | - { |
314 | | - LOG(LOG_LEVEL_INFO, "Found X server running at %s", text); |
315 | | - } |
316 | | - else |
317 | | - { |
318 | | - LOG(LOG_LEVEL_DEBUG, "Did not find a running X server at %s", text); |
319 | | - } |
320 | | - |
321 | | - return x_running; |
322 | | -} |
323 | | - |
324 | 289 | /******************************************************************************/ |
325 | 290 | /* called with the main thread |
326 | 291 | returns boolean */ |
@@ -375,37 +340,6 @@ session_get_avail_display_from_chain(void) |
375 | 340 | return 0; |
376 | 341 | } |
377 | 342 |
|
378 | | -/******************************************************************************/ |
379 | | -static int |
380 | | -wait_for_xserver(int display) |
381 | | -{ |
382 | | - int i; |
383 | | - |
384 | | - /* give X a bit to start */ |
385 | | - /* wait up to 10 secs for x server to start */ |
386 | | - i = 0; |
387 | | - |
388 | | - LOG(LOG_LEVEL_DEBUG, "Waiting for X server to start on display %d", display); |
389 | | - |
390 | | - while (!x_server_running(display)) |
391 | | - { |
392 | | - i++; |
393 | | - |
394 | | - if (i > 40) |
395 | | - { |
396 | | - LOG(LOG_LEVEL_WARNING, |
397 | | - "Timed out waiting for X server on display %d to startup", |
398 | | - display); |
399 | | - break; |
400 | | - } |
401 | | - |
402 | | - g_sleep(250); |
403 | | - } |
404 | | - |
405 | | - return 0; |
406 | | -} |
407 | | - |
408 | | -/******************************************************************************/ |
409 | 343 | static int |
410 | 344 | session_start_chansrv(int uid, int display) |
411 | 345 | { |
@@ -655,13 +589,12 @@ session_start(struct auth_info *auth_info, |
655 | 589 | } |
656 | 590 | else if (window_manager_pid == 0) |
657 | 591 | { |
658 | | - wait_for_xserver(display); |
659 | 592 | env_set_user(s->uid, |
660 | 593 | 0, |
661 | 594 | display, |
662 | 595 | g_cfg->env_names, |
663 | 596 | g_cfg->env_values); |
664 | | - if (x_server_running(display)) |
| 597 | + if (wait_for_xserver(display)) |
665 | 598 | { |
666 | 599 | auth_set_env(auth_info); |
667 | 600 | if (s->directory != 0) |
@@ -912,7 +845,6 @@ session_start(struct auth_info *auth_info, |
912 | 845 | struct exit_status xserver_exit_status; |
913 | 846 | struct exit_status chansrv_exit_status; |
914 | 847 |
|
915 | | - wait_for_xserver(display); |
916 | 848 | chansrv_pid = session_start_chansrv(s->uid, display); |
917 | 849 |
|
918 | 850 | LOG(LOG_LEVEL_INFO, |
|
0 commit comments