Print version on startup for firejail/firecfg

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).
This commit is contained in:
Kelvin M. Klann 2023-05-11 21:02:46 -03:00
parent 15ad8696c7
commit f019f0ec3f
2 changed files with 6 additions and 0 deletions

View file

@ -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());

View file

@ -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();