Skip to content

Commit

Permalink
Print version on startup for firejail/firecfg
Browse files Browse the repository at this point in the history
It is not too uncommon for the firejail version to be missing when
issues are reported; this commit makes it more likely that any posted
logs will contain the program version.

Do so just for firejail and firecfg for now because they are the most
common user-facing programs.

Print the version after argument parsing, in order to avoid printing the
program version more than once and to avoid interfering with commands
that generate machine-readable output (like `firejail --list` and
`firecfg --list`).  Also, only print it after all profiles have been
loaded, because a profile may contain `quiet`.

Note: This does not cover the case where the program exits before the
end of argument/profile parsing (such as when an error occurs).
  • Loading branch information
kmk3 committed May 14, 2023
1 parent 15ad869 commit f019f0e
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/firecfg/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -413,6 +413,7 @@ int main(int argc, char **argv) {
}
}

print_version();
if (arg_debug)
printf("%s %d %d %d %d\n", user, getuid(), getgid(), geteuid(), getegid());

Expand Down
5 changes: 5 additions & 0 deletions src/firejail/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -3010,6 +3010,11 @@ int main(int argc, char **argv, char **envp) {
}
EUID_ASSERT();

// Note: Only attempt to print non-debug information to stdout after
// all profiles have been loaded (because a profile may set arg_quiet)
if (!arg_quiet)
print_version();

// block X11 sockets
if (arg_x11_block)
x11_block();
Expand Down

0 comments on commit f019f0e

Please sign in to comment.