diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/firejail/x11.c | 51 |
1 files changed, 50 insertions, 1 deletions
diff --git a/src/firejail/x11.c b/src/firejail/x11.c index 6395903f9..204889625 100644 --- a/src/firejail/x11.c +++ b/src/firejail/x11.c | |||
@@ -625,6 +625,52 @@ void x11_start_xephyr(int argc, char **argv) { | |||
625 | } | 625 | } |
626 | 626 | ||
627 | 627 | ||
628 | // this function returns the string that will appear in the window title when xpra is being used | ||
629 | // this string may include one of these items: | ||
630 | // * the "--name" argument, if specified | ||
631 | // * the basename portion of the "--private" directory, if specified | ||
632 | // note: the malloc() is leaking, but this is a small string allocated one time only during startup, so don't care | ||
633 | static char * get_title_arg_str() { | ||
634 | |||
635 | char * title_arg_str = NULL; | ||
636 | |||
637 | const char * title_start = "--title=firejail x11 sandbox"; | ||
638 | const char * title_sep = " "; | ||
639 | |||
640 | // use the "--name" argument if it was explicitly specified | ||
641 | if ((cfg.name != NULL) && (strlen(cfg.name) > 0)) { | ||
642 | |||
643 | title_arg_str = malloc(strlen(title_start) + strlen(title_sep) + strlen(cfg.name) + 1); | ||
644 | |||
645 | strcpy(title_arg_str, title_start); | ||
646 | strcat(title_arg_str, title_sep); | ||
647 | strcat(title_arg_str, cfg.name); | ||
648 | } | ||
649 | |||
650 | // use the "--private" argument if it was explicitly specified | ||
651 | else if ((cfg.home_private != NULL) && (strlen(cfg.home_private) > 0)) { | ||
652 | |||
653 | char * tmp_in = strdupa(cfg.home_private); | ||
654 | char * base_out = strdupa(basename(tmp_in)); | ||
655 | |||
656 | title_arg_str = malloc(strlen(title_start) + strlen(title_sep) + strlen(base_out) + 1); | ||
657 | |||
658 | strcpy(title_arg_str, title_start); | ||
659 | strcat(title_arg_str, title_sep); | ||
660 | strcat(title_arg_str, base_out); | ||
661 | } | ||
662 | |||
663 | // default | ||
664 | else { | ||
665 | title_arg_str = malloc(strlen(title_start) + 1); | ||
666 | |||
667 | strcpy(title_arg_str, title_start); | ||
668 | } | ||
669 | |||
670 | return title_arg_str; | ||
671 | } | ||
672 | |||
673 | |||
628 | void x11_start_xpra_old(int argc, char **argv, int display, char *display_str) { | 674 | void x11_start_xpra_old(int argc, char **argv, int display, char *display_str) { |
629 | EUID_ASSERT(); | 675 | EUID_ASSERT(); |
630 | int i; | 676 | int i; |
@@ -752,7 +798,10 @@ void x11_start_xpra_old(int argc, char **argv, int display, char *display_str) { | |||
752 | free(fname); | 798 | free(fname); |
753 | 799 | ||
754 | // build attach command | 800 | // build attach command |
755 | char *attach_argv[] = { "xpra", "--title=\"firejail x11 sandbox\"", "attach", display_str, NULL }; | 801 | |
802 | char * title_arg_str = get_title_arg_str(); | ||
803 | |||
804 | char *attach_argv[] = { "xpra", title_arg_str, "attach", display_str, NULL }; | ||
756 | 805 | ||
757 | // run attach command | 806 | // run attach command |
758 | client = fork(); | 807 | client = fork(); |