diff options
author | netblue30 <netblue30@yahoo.com> | 2016-08-18 21:13:26 -0400 |
---|---|---|
committer | netblue30 <netblue30@yahoo.com> | 2016-08-18 21:13:26 -0400 |
commit | 3e4772ecadd9c2c820204c6fc88a48c38b5131fb (patch) | |
tree | fc3f8b19119f18cafc966bc772adb7e696f78e48 /src/firejail/no_sandbox.c | |
parent | gajim profile integration (diff) | |
download | firejail-3e4772ecadd9c2c820204c6fc88a48c38b5131fb.tar.gz firejail-3e4772ecadd9c2c820204c6fc88a48c38b5131fb.tar.zst firejail-3e4772ecadd9c2c820204c6fc88a48c38b5131fb.zip |
small fixes for command args
Diffstat (limited to 'src/firejail/no_sandbox.c')
-rw-r--r-- | src/firejail/no_sandbox.c | 15 |
1 files changed, 13 insertions, 2 deletions
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; |