aboutsummaryrefslogtreecommitdiffstats
path: root/src/firejail/x11.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/firejail/x11.c')
-rw-r--r--src/firejail/x11.c15
1 files changed, 6 insertions, 9 deletions
diff --git a/src/firejail/x11.c b/src/firejail/x11.c
index afe77e246..09956b903 100644
--- a/src/firejail/x11.c
+++ b/src/firejail/x11.c
@@ -204,7 +204,6 @@ static int random_display_number(void) {
204void x11_start_xvfb(int argc, char **argv) { 204void x11_start_xvfb(int argc, char **argv) {
205 EUID_ASSERT(); 205 EUID_ASSERT();
206 int i; 206 int i;
207 struct stat s;
208 pid_t jail = 0; 207 pid_t jail = 0;
209 pid_t server = 0; 208 pid_t server = 0;
210 209
@@ -348,7 +347,7 @@ void x11_start_xvfb(int argc, char **argv) {
348 // wait for x11 server to start 347 // wait for x11 server to start
349 while (++n < 10) { 348 while (++n < 10) {
350 sleep(1); 349 sleep(1);
351 if (stat(fname, &s) == 0) 350 if (access(fname, F_OK) == 0)
352 break; 351 break;
353 }; 352 };
354 353
@@ -427,7 +426,6 @@ static char *extract_setting(int argc, char **argv, const char *argument) {
427void x11_start_xephyr(int argc, char **argv) { 426void x11_start_xephyr(int argc, char **argv) {
428 EUID_ASSERT(); 427 EUID_ASSERT();
429 int i; 428 int i;
430 struct stat s;
431 pid_t jail = 0; 429 pid_t jail = 0;
432 pid_t server = 0; 430 pid_t server = 0;
433 431
@@ -586,7 +584,7 @@ void x11_start_xephyr(int argc, char **argv) {
586 // wait for x11 server to start 584 // wait for x11 server to start
587 while (++n < 10) { 585 while (++n < 10) {
588 sleep(1); 586 sleep(1);
589 if (stat(fname, &s) == 0) 587 if (access(fname, F_OK) == 0)
590 break; 588 break;
591 }; 589 };
592 590
@@ -701,7 +699,6 @@ static char * get_title_arg_str() {
701static void __attribute__((noreturn)) x11_start_xpra_old(int argc, char **argv, int display, char *display_str) { 699static void __attribute__((noreturn)) x11_start_xpra_old(int argc, char **argv, int display, char *display_str) {
702 EUID_ASSERT(); 700 EUID_ASSERT();
703 int i; 701 int i;
704 struct stat s;
705 pid_t client = 0; 702 pid_t client = 0;
706 pid_t server = 0; 703 pid_t server = 0;
707 704
@@ -818,7 +815,7 @@ static void __attribute__((noreturn)) x11_start_xpra_old(int argc, char **argv,
818 // wait for x11 server to start 815 // wait for x11 server to start
819 while (++n < 10) { 816 while (++n < 10) {
820 sleep(1); 817 sleep(1);
821 if (stat(fname, &s) == 0) 818 if (access(fname, F_OK) == 0)
822 break; 819 break;
823 } 820 }
824 821
@@ -1231,9 +1228,9 @@ void x11_xorg(void) {
1231 char *dest; 1228 char *dest;
1232 if (asprintf(&dest, "%s/.Xauthority", cfg.homedir) == -1) 1229 if (asprintf(&dest, "%s/.Xauthority", cfg.homedir) == -1)
1233 errExit("asprintf"); 1230 errExit("asprintf");
1234 if (lstat(dest, &s) == -1) { 1231 if (access(dest, F_OK) == -1) {
1235 touch_file_as_user(dest, 0600); 1232 touch_file_as_user(dest, 0600);
1236 if (stat(dest, &s) == -1) { 1233 if (access(dest, F_OK) == -1) {
1237 fprintf(stderr, "Error: cannot create %s\n", dest); 1234 fprintf(stderr, "Error: cannot create %s\n", dest);
1238 exit(1); 1235 exit(1);
1239 } 1236 }
@@ -1292,7 +1289,7 @@ void x11_xorg(void) {
1292 // blacklist user .Xauthority file if it is not masked already 1289 // blacklist user .Xauthority file if it is not masked already
1293 const char *envar = env_get("XAUTHORITY"); 1290 const char *envar = env_get("XAUTHORITY");
1294 if (envar) { 1291 if (envar) {
1295 char *rp = realpath(envar, NULL); 1292 char *rp = realpath_as_user(envar);
1296 if (rp) { 1293 if (rp) {
1297 if (strcmp(rp, dest) != 0) 1294 if (strcmp(rp, dest) != 0)
1298 disable_file_or_dir(rp); 1295 disable_file_or_dir(rp);