aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorLibravatar netblue30 <netblue30@yahoo.com>2016-08-18 21:13:26 -0400
committerLibravatar netblue30 <netblue30@yahoo.com>2016-08-18 21:13:26 -0400
commit3e4772ecadd9c2c820204c6fc88a48c38b5131fb (patch)
treefc3f8b19119f18cafc966bc772adb7e696f78e48 /src
parentgajim profile integration (diff)
downloadfirejail-3e4772ecadd9c2c820204c6fc88a48c38b5131fb.tar.gz
firejail-3e4772ecadd9c2c820204c6fc88a48c38b5131fb.tar.zst
firejail-3e4772ecadd9c2c820204c6fc88a48c38b5131fb.zip
small fixes for command args
Diffstat (limited to 'src')
-rw-r--r--src/firejail/main.c5
-rw-r--r--src/firejail/no_sandbox.c15
2 files changed, 16 insertions, 4 deletions
diff --git a/src/firejail/main.c b/src/firejail/main.c
index 4946db2bd..8e18ec724 100644
--- a/src/firejail/main.c
+++ b/src/firejail/main.c
@@ -723,7 +723,7 @@ static void detect_quiet(int argc, char **argv) {
723} 723}
724 724
725char *guess_shell(void) { 725char *guess_shell(void) {
726 char *shell; 726 char *shell = NULL;
727 // shells in order of preference 727 // shells in order of preference
728 char *shells[] = {"/bin/bash", "/bin/csh", "/usr/bin/zsh", "/bin/sh", "/bin/ash", NULL }; 728 char *shells[] = {"/bin/bash", "/bin/csh", "/usr/bin/zsh", "/bin/sh", "/bin/ash", NULL };
729 729
@@ -910,7 +910,8 @@ int main(int argc, char **argv) {
910#endif 910#endif
911 911
912 drop_privs(1); 912 drop_privs(1);
913 run_no_sandbox(argc, argv); 913 int rv = system(argv[2]);
914 exit(rv);
914 } 915 }
915 } 916 }
916 } 917 }
diff --git a/src/firejail/no_sandbox.c b/src/firejail/no_sandbox.c
index 090c06761..f7d62f90c 100644
--- a/src/firejail/no_sandbox.c
+++ b/src/firejail/no_sandbox.c
@@ -237,7 +237,7 @@ void run_no_sandbox(int argc, char **argv) {
237 } 237 }
238 // guess shell otherwise 238 // guess shell otherwise
239 if (!arg_shell_none && !cfg.shell) { 239 if (!arg_shell_none && !cfg.shell) {
240 guess_shell(); 240 cfg.shell = guess_shell();
241 if (arg_debug) 241 if (arg_debug)
242 printf("Autoselecting %s as shell\n", cfg.shell); 242 printf("Autoselecting %s as shell\n", cfg.shell);
243 } 243 }
@@ -247,8 +247,19 @@ void run_no_sandbox(int argc, char **argv) {
247 } 247 }
248 248
249 int prog_index = 0; 249 int prog_index = 0;
250 // find first non option arg 250 // find first non option arg:
251 // - first argument not starting wiht --,
252 // - whatever follows after -c (example: firejail -c ls)
251 for (i = 1; i < argc; i++) { 253 for (i = 1; i < argc; i++) {
254 if (strcmp(argv[i], "-c") == 0) {
255 prog_index = i + 1;
256 if (prog_index == argc) {
257 fprintf(stderr, "Error: option -c requires an argument\n");
258 exit(1);
259 }
260 break;
261 }
262 // check first argument not starting with --
252 if (strncmp(argv[i],"--",2) != 0) { 263 if (strncmp(argv[i],"--",2) != 0) {
253 prog_index = i; 264 prog_index = i;
254 break; 265 break;