aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorLibravatar netblue30 <netblue30@yahoo.com>2016-08-26 09:29:44 -0400
committerLibravatar netblue30 <netblue30@yahoo.com>2016-08-26 09:29:44 -0400
commit949070a1dd728e58ab04c8e02f08cef422ddf7d9 (patch)
tree0c15162d0e69973da7d6f3d2cea20aad47afbb40 /src
parentadded back strings profile (diff)
downloadfirejail-949070a1dd728e58ab04c8e02f08cef422ddf7d9.tar.gz
firejail-949070a1dd728e58ab04c8e02f08cef422ddf7d9.tar.zst
firejail-949070a1dd728e58ab04c8e02f08cef422ddf7d9.zip
shell fixes
Diffstat (limited to 'src')
-rw-r--r--src/firejail/bandwidth.c7
-rw-r--r--src/firejail/env.c2
-rw-r--r--src/firejail/join.c28
3 files changed, 31 insertions, 6 deletions
diff --git a/src/firejail/bandwidth.c b/src/firejail/bandwidth.c
index 22be5b23c..4a1df9c67 100644
--- a/src/firejail/bandwidth.c
+++ b/src/firejail/bandwidth.c
@@ -450,7 +450,12 @@ void bandwidth_pid(pid_t pid, const char *command, const char *dev, int down, in
450 if (setregid(0, 0)) 450 if (setregid(0, 0))
451 errExit("setregid"); 451 errExit("setregid");
452 452
453 assert(cfg.shell); 453 if (!cfg.shell)
454 cfg.shell = guess_shell();
455 if (!cfg.shell) {
456 fprintf(stderr, "Error: no POSIX shell found, please use --shell command line option\n");
457 exit(1);
458 }
454 459
455 char *arg[4]; 460 char *arg[4];
456 arg[0] = cfg.shell; 461 arg[0] = cfg.shell;
diff --git a/src/firejail/env.c b/src/firejail/env.c
index 2c8be3852..2cc65e464 100644
--- a/src/firejail/env.c
+++ b/src/firejail/env.c
@@ -121,6 +121,8 @@ void env_defaults(void) {
121 errExit("setenv"); 121 errExit("setenv");
122 if (setenv("container", "firejail", 1) < 0) // LXC sets container=lxc, 122 if (setenv("container", "firejail", 1) < 0) // LXC sets container=lxc,
123 errExit("setenv"); 123 errExit("setenv");
124 if (!cfg.shell)
125 cfg.shell = guess_shell();
124 if (cfg.shell && setenv("SHELL", cfg.shell, 1) < 0) 126 if (cfg.shell && setenv("SHELL", cfg.shell, 1) < 0)
125 errExit("setenv"); 127 errExit("setenv");
126 128
diff --git a/src/firejail/join.c b/src/firejail/join.c
index 37bac7e65..948c7ef71 100644
--- a/src/firejail/join.c
+++ b/src/firejail/join.c
@@ -319,10 +319,13 @@ void join(pid_t pid, int argc, char **argv, int index) {
319 caps_set(caps); 319 caps_set(caps);
320 320
321 // set prompt color to green 321 // set prompt color to green
322 //export PS1='\[\e[1;32m\][\u@\h \W]\$\[\e[0m\] ' 322 char *prompt = getenv("FIREJAIL_PROMPT");
323 if (setenv("PROMPT_COMMAND", "export PS1=\"\\[\\e[1;32m\\][\\u@\\h \\W]\\$\\[\\e[0m\\] \"", 1) < 0) 323 if (prompt && strcmp(prompt, "yes") == 0) {
324 errExit("setenv"); 324 //export PS1='\[\e[1;32m\][\u@\h \W]\$\[\e[0m\] '
325 325 if (setenv("PROMPT_COMMAND", "export PS1=\"\\[\\e[1;32m\\][\\u@\\h \\W]\\$\\[\\e[0m\\] \"", 1) < 0)
326 errExit("setenv");
327 }
328
326 // set nice 329 // set nice
327 if (arg_nice) { 330 if (arg_nice) {
328 errno = 0; 331 errno = 0;
@@ -336,7 +339,22 @@ void join(pid_t pid, int argc, char **argv, int index) {
336 339
337 // run cmdline trough shell 340 // run cmdline trough shell
338 if (cfg.command_line == NULL) { 341 if (cfg.command_line == NULL) {
339 assert(cfg.shell); 342 // if the sandbox was started with --shell=none, it is possible we don't have a shell
343 // inside the sandbox
344 if (cfg.shell == NULL) {
345 cfg.shell = guess_shell();
346 if (!cfg.shell) {
347 fprintf(stderr, "Error: no POSIX shell found, please use --shell command line option\n");
348 exit(1);
349 }
350 }
351
352 struct stat s;
353 if (stat(cfg.shell, &s) == -1) {
354 fprintf(stderr, "Error: %s shell not found inside the sandbox\n", cfg.shell);
355 exit(1);
356 }
357
340 cfg.command_line = cfg.shell; 358 cfg.command_line = cfg.shell;
341 cfg.window_title = cfg.shell; 359 cfg.window_title = cfg.shell;
342 } 360 }