diff options
author | 2016-01-23 11:04:42 +0900 | |
---|---|---|
committer | 2016-01-23 11:10:36 +0900 | |
commit | cfc3b83b0b7009528f543253e5250502e8e7610b (patch) | |
tree | 83ee22ee16a21fa36f4da1402077767bdee2f864 | |
parent | fixed .asoundrc problems for Debian sid (diff) | |
download | firejail-cfc3b83b0b7009528f543253e5250502e8e7610b.tar.gz firejail-cfc3b83b0b7009528f543253e5250502e8e7610b.tar.zst firejail-cfc3b83b0b7009528f543253e5250502e8e7610b.zip |
Fix symlink invocation for programs placing symlinks in $PATH
-rw-r--r-- | src/firejail/run_symlink.c | 23 |
1 files changed, 18 insertions, 5 deletions
diff --git a/src/firejail/run_symlink.c b/src/firejail/run_symlink.c index 1157cdab4..bc1bb3011 100644 --- a/src/firejail/run_symlink.c +++ b/src/firejail/run_symlink.c | |||
@@ -42,7 +42,11 @@ void run_symlink(int argc, char **argv) { | |||
42 | char *path = strdup(p); | 42 | char *path = strdup(p); |
43 | if (!path) | 43 | if (!path) |
44 | errExit("strdup"); | 44 | errExit("strdup"); |
45 | 45 | ||
46 | char *selfpath = realpath("/proc/self/exe", NULL); | ||
47 | if (!selfpath) | ||
48 | errExit("realpath"); | ||
49 | |||
46 | // look in path for our program | 50 | // look in path for our program |
47 | char *tok = strtok(path, ":"); | 51 | char *tok = strtok(path, ":"); |
48 | int found = 0; | 52 | int found = 0; |
@@ -53,21 +57,30 @@ void run_symlink(int argc, char **argv) { | |||
53 | 57 | ||
54 | struct stat s; | 58 | struct stat s; |
55 | if (stat(name, &s) == 0) { | 59 | if (stat(name, &s) == 0) { |
56 | if (!is_link(name)) { | 60 | char* rp = realpath(name, NULL); |
61 | if (!rp) | ||
62 | errExit("realpath"); | ||
63 | |||
64 | if (strcmp(selfpath, rp) != 0) { | ||
57 | program = strdup(name); | 65 | program = strdup(name); |
58 | found = 1; | 66 | found = 1; |
67 | free(rp); | ||
59 | break; | 68 | break; |
60 | } | 69 | } |
70 | |||
71 | free(rp); | ||
61 | } | 72 | } |
62 | 73 | ||
63 | free(name); | 74 | free(name); |
64 | tok = strtok(NULL, ":"); | 75 | tok = strtok(NULL, ":"); |
65 | } | 76 | } |
66 | if (!found) { | 77 | if (!found) { |
67 | fprintf(stderr, "Error: cannot find the program in the path\n"); | 78 | fprintf(stderr, "Error: cannot find the program in the path\n"); |
68 | exit(1); | 79 | exit(1); |
69 | } | 80 | } |
70 | 81 | ||
82 | free(selfpath); | ||
83 | |||
71 | 84 | ||
72 | // start the argv[0] program in a new sandbox | 85 | // start the argv[0] program in a new sandbox |
73 | char *firejail; | 86 | char *firejail; |