Skip to content

Commit a8cfb94

Browse files
authored
Merge pull request #6952 from yureitzk/xephyr-options
feature: add --xephyr-extra-params= command
2 parents 7cd56fa + 15b0e07 commit a8cfb94

File tree

7 files changed

+41
-1
lines changed

7 files changed

+41
-1
lines changed

contrib/syntax/lists/profile_commands_arg1.list

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,3 +84,4 @@ whitelist
8484
whitelist-ro
8585
x11
8686
xephyr-screen
87+
xephyr-extra-params

src/firejail/main.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1412,6 +1412,12 @@ int main(int argc, char **argv, char **envp) {
14121412
else
14131413
exit_err_feature("x11");
14141414
}
1415+
else if (strncmp(argv[i], "--xephyr-extra-params=", 16) == 0) {
1416+
if (checkcfg(CFG_X11))
1417+
; // the processing is done directly in x11.c
1418+
else
1419+
exit_err_feature("x11");
1420+
}
14151421
#endif
14161422
//*************************************
14171423
// filtering

src/firejail/usage.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -302,6 +302,7 @@ static const char *const usage_str =
302302
" --x11=xpra - enable Xpra X11 server.\n"
303303
" --x11=xvfb - enable Xvfb X11 server.\n"
304304
" --xephyr-screen=WIDTHxHEIGHT - set screen size for --x11=xephyr.\n"
305+
" --xephyr-extra-params=OPTIONS - set Xephyr server command extra parameters for --x11=xephyr.\n"
305306
#endif
306307
"\n"
307308
"Examples:\n"

src/firejail/x11.c

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -434,6 +434,11 @@ void x11_start_xephyr(int argc, char **argv) {
434434
if (newscreen)
435435
xephyr_screen = newscreen;
436436

437+
// default xephyr options can be overwritten by a --xephyr-extra-params= command line option
438+
char *new_xephyr_extra_params = extract_setting(argc, argv, "--xephyr-extra-params=");
439+
if (new_xephyr_extra_params)
440+
xephyr_extra_params = new_xephyr_extra_params;
441+
437442
env_store_name_val("FIREJAIL_X11", "yes", SETENV);
438443

439444
// unfortunately, xephyr does a number of weird things when started by root user!!!
@@ -711,7 +716,7 @@ static void __attribute__((noreturn)) x11_start_xpra_old(int argc, char **argv,
711716

712717
assert(xpra_extra_params); // should be "" if empty
713718

714-
// parse xephyr_extra_params
719+
// parse xpra_extra_params
715720
// very basic quoting support
716721
char *temp = strdup(xpra_extra_params);
717722
if (*xpra_extra_params != '\0') {

src/man/firejail-profile.5.in

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -687,6 +687,20 @@ Example:
687687
xephyr-screen 640x480
688688
.br
689689
x11 xephyr
690+
691+
.TP
692+
\fBxephyr-extra-params OPTIONS
693+
Set Xephyr server command extra parameters for x11 xephyr. This command should be included in the profile file before x11 xephyr command.
694+
.br
695+
696+
.br
697+
Example:
698+
.br
699+
700+
.br
701+
xephyr-extra-params -grayscale
702+
.br
703+
x11 xephyr
690704
#endif
691705
#ifdef HAVE_DBUSPROXY
692706
.SH DBus filtering

src/man/firejail.1.in

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3467,6 +3467,18 @@ Example:
34673467
.br
34683468
$ firejail --net=eth0 --x11=xephyr --xephyr-screen=640x480 /usr/bin/firefox
34693469
.br
3470+
3471+
.TP
3472+
\fB\-\-xephyr-extra-params=OPTIONS
3473+
Set Xephyr server command extra parameters for x11 --x11=xephyr. The setting will overwrite the default set in /etc/firejail/firejail.config
3474+
for the current sandbox. Run Xephyr -help to get a list of available options.
3475+
.br
3476+
3477+
.br
3478+
Example:
3479+
.br
3480+
$ firejail --net=eth0 --x11=xephyr --xephyr-extra-params="-title firefox" firefox
3481+
.br
34703482
#endif
34713483
.\" Note: Keep this in sync with invalid_name() in src/firejail/util.c.
34723484
#ifdef HAVE_APPARMOR

src/zsh_completion/_firejail.in

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -271,6 +271,7 @@ _firejail_args=(
271271
'--x11[enable X11 sandboxing. The software checks first if Xpra is installed, then it checks if Xephyr is installed. If all fails, it will attempt to use X11 security extension]'
272272
'--x11=-[disable or enable specific X11 server]: :(none xephyr xorg xpra xvfb)'
273273
'--xephyr-screen=-[set screen size for --x11=xephyr]: :(WIDTHxHEIGHT)'
274+
'--xephyr-extra-params=-[set Xephyr command server extra parameters for --x11=xephyr]: :(OPTIONS)'
274275
#endif
275276
)
276277

0 commit comments

Comments
 (0)