From e6c50240f9f2033a896df5a06c6fc7c1529d5442 Mon Sep 17 00:00:00 2001 From: netblue30 Date: Sun, 20 Feb 2022 08:05:33 -0500 Subject: --tab: enable shell tab completion --- src/firejail/firejail.h | 1 + src/firejail/fs_home.c | 4 +++- src/firejail/main.c | 3 +++ src/firejail/profile.c | 4 ++++ src/firejail/usage.c | 2 ++ src/man/firejail.txt | 7 +++++++ 6 files changed, 20 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/firejail/firejail.h b/src/firejail/firejail.h index f1fa66707..316518534 100644 --- a/src/firejail/firejail.h +++ b/src/firejail/firejail.h @@ -365,6 +365,7 @@ extern DbusPolicy arg_dbus_system; // --dbus-system extern int arg_dbus_log_user; extern int arg_dbus_log_system; extern const char *arg_dbus_log_file; +extern int arg_tab; extern int login_shell; extern int parent_to_child_fds[2]; diff --git a/src/firejail/fs_home.c b/src/firejail/fs_home.c index 6a554dc89..061461590 100644 --- a/src/firejail/fs_home.c +++ b/src/firejail/fs_home.c @@ -34,8 +34,10 @@ #endif static void disable_tab_completion(const char *homedir) { - char *fname; + if (arg_tab) + return; + char *fname; if (asprintf(&fname, "%s/.inputrc", homedir) == -1) errExit("asprintf"); diff --git a/src/firejail/main.c b/src/firejail/main.c index d614ae1ac..4b01ea0a5 100644 --- a/src/firejail/main.c +++ b/src/firejail/main.c @@ -155,6 +155,7 @@ DbusPolicy arg_dbus_system = DBUS_POLICY_ALLOW; // --dbus-system const char *arg_dbus_log_file = NULL; int arg_dbus_log_user = 0; int arg_dbus_log_system = 0; +int arg_tab = 0; int login_shell = 0; int parent_to_child_fds[2]; @@ -2798,6 +2799,8 @@ int main(int argc, char **argv, char **envp) { else if (strcmp(argv[i], "--deterministic-shutdown") == 0) { arg_deterministic_shutdown = 1; } + else if (strcmp(argv[i], "--tab") == 0) + arg_tab = 1; else { // double dash - positional params to follow if (strcmp(argv[i], "--") == 0) { diff --git a/src/firejail/profile.c b/src/firejail/profile.c index 794668dc6..0b258e6bb 100644 --- a/src/firejail/profile.c +++ b/src/firejail/profile.c @@ -389,6 +389,10 @@ int profile_check_line(char *ptr, int lineno, const char *fname) { #endif return 0; } + else if (strcmp(ptr, "tab") == 0) { + arg_tab = 1; + return 0; + } else if (strcmp(ptr, "private-cwd") == 0) { cfg.cwd = NULL; arg_private_cwd = 1; diff --git a/src/firejail/usage.c b/src/firejail/usage.c index 0b24467be..2dd913b5e 100644 --- a/src/firejail/usage.c +++ b/src/firejail/usage.c @@ -245,6 +245,8 @@ static char *usage_str = " --shell=none - run the program directly without a user shell.\n" " --shell=program - set default user shell.\n" " --shutdown=name|pid - shutdown the sandbox identified by name or PID.\n" + " --tab - enable shell tab completion in sandboxes using private or\n" + "\twhitelisted home directories.\n" " --timeout=hh:mm:ss - kill the sandbox automatically after the time\n" "\thas elapsed.\n" " --tmpfs=dirname - mount a tmpfs filesystem on directory dirname.\n" diff --git a/src/man/firejail.txt b/src/man/firejail.txt index 4cbe7f13d..a3dfb14ac 100644 --- a/src/man/firejail.txt +++ b/src/man/firejail.txt @@ -2683,6 +2683,13 @@ $ firejail \-\-list .br $ firejail \-\-shutdown=3272 .TP +\fB\-\-tab +Enable bash completion in sandboxes using private or whitelisted home directories. +.br + +.br +$ firejail \-\-private --tab +.TP \fB\-\-timeout=hh:mm:ss Kill the sandbox automatically after the time has elapsed. The time is specified in hours/minutes/seconds format. .br -- cgit v1.2.3-70-g09d2