diff options
Diffstat (limited to 'src/firejail/util.c')
-rw-r--r-- | src/firejail/util.c | 26 |
1 files changed, 23 insertions, 3 deletions
diff --git a/src/firejail/util.c b/src/firejail/util.c index a8763b194..d7964ccb8 100644 --- a/src/firejail/util.c +++ b/src/firejail/util.c | |||
@@ -398,9 +398,29 @@ int find_child(pid_t parent, pid_t *child) { | |||
398 | 398 | ||
399 | 399 | ||
400 | 400 | ||
401 | void extract_command_name(const char *str) { | 401 | void extract_command_name(int index, char **argv) { |
402 | assert(str); | 402 | assert(argv); |
403 | cfg.command_name = strdup(str); | 403 | assert(argv[index]); |
404 | |||
405 | |||
406 | // configure command index | ||
407 | cfg.original_program_index = index; | ||
408 | |||
409 | char *str = strdup(argv[index]); | ||
410 | if (!str) | ||
411 | errExit("strdup"); | ||
412 | |||
413 | // if we have a symbolic link, use the real path to extract the name | ||
414 | if (is_link(argv[index])) { | ||
415 | char*newname = realpath(argv[index], NULL); | ||
416 | if (newname) { | ||
417 | free(str); | ||
418 | str = newname; | ||
419 | } | ||
420 | } | ||
421 | |||
422 | // configure command name | ||
423 | cfg.command_name = str; | ||
404 | if (!cfg.command_name) | 424 | if (!cfg.command_name) |
405 | errExit("strdup"); | 425 | errExit("strdup"); |
406 | 426 | ||