Skip to content

Commit 907916d

Browse files
committed
modif: check for --version during early init
Move it from `run_cmd_and_exit()` to right after the --quiet/--debug checks. This simplifies the sandbox check code by removing its own --version check. See also commit 5cd597e ("fix --version", 2016-06-28). This is a follow-up to #6969.
1 parent 7cd56fa commit 907916d

File tree

1 file changed

+6
-9
lines changed

1 file changed

+6
-9
lines changed

src/firejail/main.c

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -375,10 +375,6 @@ static void run_cmd_and_exit(int i, int argc, char **argv) {
375375
usage();
376376
exit(0);
377377
}
378-
else if (strcmp(argv[i], "--version") == 0) {
379-
print_version_full();
380-
exit(0);
381-
}
382378
#ifdef HAVE_OVERLAYFS
383379
else if (strcmp(argv[i], "--overlay-clean") == 0) {
384380
if (checkcfg(CFG_OVERLAYFS)) {
@@ -1092,6 +1088,12 @@ int main(int argc, char **argv, char **envp) {
10921088
arg_quiet = 0;
10931089
}
10941090

1091+
// process --version
1092+
if (check_arg(argc, argv, "--version", 1)) {
1093+
print_version_full();
1094+
exit(0);
1095+
}
1096+
10951097
// initialize values from firejail.config (needed for arg/env checks)
10961098
checkcfg(0);
10971099

@@ -1144,11 +1146,6 @@ int main(int argc, char **argv, char **envp) {
11441146
int rv = check_kernel_procs();
11451147
EUID_USER();
11461148
if (rv == 0) {
1147-
if (check_arg(argc, argv, "--version", 1)) {
1148-
print_version_full();
1149-
exit(0);
1150-
}
1151-
11521149
// start the program directly without sandboxing
11531150
run_no_sandbox(argc, argv);
11541151
__builtin_unreachable();

0 commit comments

Comments
 (0)