diff options
author | 2016-08-14 13:33:22 +0300 | |
---|---|---|
committer | 2016-08-14 13:33:22 +0300 | |
commit | 9f5dfa5964f82fa03b5b86c705b1f599c9887316 (patch) | |
tree | cf242f1ef649bbd3cdbd0a7b454fad3afceeddc6 /src | |
parent | small fix (diff) | |
download | firejail-9f5dfa5964f82fa03b5b86c705b1f599c9887316.tar.gz firejail-9f5dfa5964f82fa03b5b86c705b1f599c9887316.tar.zst firejail-9f5dfa5964f82fa03b5b86c705b1f599c9887316.zip |
join fixes
Diffstat (limited to 'src')
-rw-r--r-- | src/firejail/firejail.h | 2 | ||||
-rw-r--r-- | src/firejail/fs_home.c | 5 | ||||
-rw-r--r-- | src/firejail/join.c | 18 | ||||
-rw-r--r-- | src/firejail/main.c | 25 |
4 files changed, 19 insertions, 31 deletions
diff --git a/src/firejail/firejail.h b/src/firejail/firejail.h index 0de2a354d..c45b324fc 100644 --- a/src/firejail/firejail.h +++ b/src/firejail/firejail.h | |||
@@ -222,8 +222,6 @@ extern int arg_nonetwork; // --net=none | |||
222 | extern int arg_command; // -c | 222 | extern int arg_command; // -c |
223 | extern int arg_overlay; // overlay option | 223 | extern int arg_overlay; // overlay option |
224 | extern int arg_overlay_keep; // place overlay diff directory in ~/.firejail | 224 | extern int arg_overlay_keep; // place overlay diff directory in ~/.firejail |
225 | extern int arg_zsh; // use zsh as default shell | ||
226 | extern int arg_csh; // use csh as default shell | ||
227 | 225 | ||
228 | extern int arg_seccomp; // enable default seccomp filter | 226 | extern int arg_seccomp; // enable default seccomp filter |
229 | 227 | ||
diff --git a/src/firejail/fs_home.c b/src/firejail/fs_home.c index c1e983c16..d328d5f1c 100644 --- a/src/firejail/fs_home.c +++ b/src/firejail/fs_home.c | |||
@@ -32,8 +32,9 @@ | |||
32 | 32 | ||
33 | static void skel(const char *homedir, uid_t u, gid_t g) { | 33 | static void skel(const char *homedir, uid_t u, gid_t g) { |
34 | char *fname; | 34 | char *fname; |
35 | |||
35 | // zsh | 36 | // zsh |
36 | if (arg_zsh) { | 37 | if (!arg_shell_none && (strcmp(cfg.shell,"/usr/bin/zsh") == 0 || strcmp(cfg.shell,"/bin/zsh") == 0)) { |
37 | // copy skel files | 38 | // copy skel files |
38 | if (asprintf(&fname, "%s/.zshrc", homedir) == -1) | 39 | if (asprintf(&fname, "%s/.zshrc", homedir) == -1) |
39 | errExit("asprintf"); | 40 | errExit("asprintf"); |
@@ -63,7 +64,7 @@ static void skel(const char *homedir, uid_t u, gid_t g) { | |||
63 | free(fname); | 64 | free(fname); |
64 | } | 65 | } |
65 | // csh | 66 | // csh |
66 | else if (arg_csh) { | 67 | else if (!arg_shell_none && strcmp(cfg.shell,"/bin/csh") == 0) { |
67 | // copy skel files | 68 | // copy skel files |
68 | if (asprintf(&fname, "%s/.cshrc", homedir) == -1) | 69 | if (asprintf(&fname, "%s/.cshrc", homedir) == -1) |
69 | errExit("asprintf"); | 70 | errExit("asprintf"); |
diff --git a/src/firejail/join.c b/src/firejail/join.c index 80ed1dc51..632715fea 100644 --- a/src/firejail/join.c +++ b/src/firejail/join.c | |||
@@ -332,13 +332,7 @@ void join(pid_t pid, int argc, char **argv, int index) { | |||
332 | 332 | ||
333 | // run cmdline trough shell | 333 | // run cmdline trough shell |
334 | if (cfg.command_line == NULL) { | 334 | if (cfg.command_line == NULL) { |
335 | cfg.shell = guess_shell(); | 335 | assert(cfg.shell); |
336 | if (!cfg.shell) { | ||
337 | fprintf(stderr, "Error: unable to guess your shell, please set explicitly by using --shell option.\n"); | ||
338 | exit(1); | ||
339 | } | ||
340 | if (arg_debug) | ||
341 | printf("Autoselecting %s as shell\n", cfg.shell); | ||
342 | 336 | ||
343 | // replace the process with a shell | 337 | // replace the process with a shell |
344 | execlp(cfg.shell, cfg.shell, NULL); | 338 | execlp(cfg.shell, cfg.shell, NULL); |
@@ -387,14 +381,8 @@ void join(pid_t pid, int argc, char **argv, int index) { | |||
387 | execvp(cfg.original_argv[cfg.original_program_index], &cfg.original_argv[cfg.original_program_index]); | 381 | execvp(cfg.original_argv[cfg.original_program_index], &cfg.original_argv[cfg.original_program_index]); |
388 | exit(1); | 382 | exit(1); |
389 | } else { | 383 | } else { |
390 | // assert(cfg.shell); | 384 | assert(cfg.shell); |
391 | cfg.shell = guess_shell(); | 385 | |
392 | if (!cfg.shell) { | ||
393 | fprintf(stderr, "Error: unable to guess your shell, please set explicitly by using --shell option.\n"); | ||
394 | exit(1); | ||
395 | } | ||
396 | if (arg_debug) | ||
397 | printf("Autoselecting %s as shell\n", cfg.shell); | ||
398 | char *arg[5]; | 386 | char *arg[5]; |
399 | arg[0] = cfg.shell; | 387 | arg[0] = cfg.shell; |
400 | arg[1] = "-c"; | 388 | arg[1] = "-c"; |
diff --git a/src/firejail/main.c b/src/firejail/main.c index 87c8389ad..e0f2a676c 100644 --- a/src/firejail/main.c +++ b/src/firejail/main.c | |||
@@ -60,8 +60,6 @@ int arg_nonetwork = 0; // --net=none | |||
60 | int arg_command = 0; // -c | 60 | int arg_command = 0; // -c |
61 | int arg_overlay = 0; // overlay option | 61 | int arg_overlay = 0; // overlay option |
62 | int arg_overlay_keep = 0; // place overlay diff directory in ~/.firejail | 62 | int arg_overlay_keep = 0; // place overlay diff directory in ~/.firejail |
63 | int arg_zsh = 0; // use zsh as default shell | ||
64 | int arg_csh = 0; // use csh as default shell | ||
65 | 63 | ||
66 | int arg_seccomp = 0; // enable default seccomp filter | 64 | int arg_seccomp = 0; // enable default seccomp filter |
67 | 65 | ||
@@ -565,7 +563,18 @@ static void run_cmd_and_exit(int i, int argc, char **argv) { | |||
565 | #endif | 563 | #endif |
566 | else if (strncmp(argv[i], "--join=", 7) == 0) { | 564 | else if (strncmp(argv[i], "--join=", 7) == 0) { |
567 | logargs(argc, argv); | 565 | logargs(argc, argv); |
568 | 566 | ||
567 | if (arg_shell_none) { | ||
568 | if (argc <= (i+1)) { | ||
569 | fprintf(stderr, "Error: --shell=none set, but no command specified\n"); | ||
570 | exit(1); | ||
571 | } | ||
572 | cfg.original_program_index = i + 1; | ||
573 | } | ||
574 | |||
575 | if (!cfg.shell && !arg_shell_none) | ||
576 | cfg.shell = guess_shell(); | ||
577 | |||
569 | // join sandbox by pid or by name | 578 | // join sandbox by pid or by name |
570 | pid_t pid; | 579 | pid_t pid; |
571 | if (read_pid(argv[i] + 7, &pid) == 0) | 580 | if (read_pid(argv[i] + 7, &pid) == 0) |
@@ -573,6 +582,7 @@ static void run_cmd_and_exit(int i, int argc, char **argv) { | |||
573 | else | 582 | else |
574 | join_name(argv[i] + 7, argc, argv, i + 1); | 583 | join_name(argv[i] + 7, argc, argv, i + 1); |
575 | exit(0); | 584 | exit(0); |
585 | |||
576 | } | 586 | } |
577 | #ifdef HAVE_NETWORK | 587 | #ifdef HAVE_NETWORK |
578 | else if (strncmp(argv[i], "--join-network=", 15) == 0) { | 588 | else if (strncmp(argv[i], "--join-network=", 15) == 0) { |
@@ -725,13 +735,6 @@ char *guess_shell(void) { | |||
725 | i++; | 735 | i++; |
726 | } | 736 | } |
727 | 737 | ||
728 | |||
729 | // FIXME get rid of arg_csh and arg_zsh completely | ||
730 | if (strcmp(shell,"/bin/csh")) | ||
731 | arg_csh = 1; | ||
732 | if (strcmp(shell,"/usr/bin/zsh") || strcmp(shell,"/bin/zsh")) | ||
733 | arg_zsh = 1; | ||
734 | |||
735 | return shell; | 738 | return shell; |
736 | } | 739 | } |
737 | 740 | ||
@@ -1887,7 +1890,6 @@ int main(int argc, char **argv) { | |||
1887 | fprintf(stderr, "Error: only one default user shell can be specified\n"); | 1890 | fprintf(stderr, "Error: only one default user shell can be specified\n"); |
1888 | return 1; | 1891 | return 1; |
1889 | } | 1892 | } |
1890 | arg_csh = 1; | ||
1891 | cfg.shell = "/bin/csh"; | 1893 | cfg.shell = "/bin/csh"; |
1892 | } | 1894 | } |
1893 | else if (strcmp(argv[i], "--zsh") == 0) { | 1895 | else if (strcmp(argv[i], "--zsh") == 0) { |
@@ -1899,7 +1901,6 @@ int main(int argc, char **argv) { | |||
1899 | fprintf(stderr, "Error: only one default user shell can be specified\n"); | 1901 | fprintf(stderr, "Error: only one default user shell can be specified\n"); |
1900 | return 1; | 1902 | return 1; |
1901 | } | 1903 | } |
1902 | arg_zsh = 1; | ||
1903 | cfg.shell = "/bin/zsh"; | 1904 | cfg.shell = "/bin/zsh"; |
1904 | } | 1905 | } |
1905 | else if (strcmp(argv[i], "--shell=none") == 0) { | 1906 | else if (strcmp(argv[i], "--shell=none") == 0) { |