diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/firejail/bandwidth.c | 5 | ||||
-rw-r--r-- | src/firejail/caps.c | 4 | ||||
-rw-r--r-- | src/firejail/fs_logger.c | 4 | ||||
-rw-r--r-- | src/firejail/join.c | 4 | ||||
-rw-r--r-- | src/firejail/main.c | 4 | ||||
-rw-r--r-- | src/firejail/network_main.c | 4 | ||||
-rw-r--r-- | src/firejail/protocol.c | 4 | ||||
-rw-r--r-- | src/firejail/seccomp.c | 4 | ||||
-rw-r--r-- | src/firejail/shutdown.c | 4 | ||||
-rw-r--r-- | src/lib/common.c | 9 |
10 files changed, 6 insertions, 40 deletions
diff --git a/src/firejail/bandwidth.c b/src/firejail/bandwidth.c index da894b321..0be23b9bc 100644 --- a/src/firejail/bandwidth.c +++ b/src/firejail/bandwidth.c | |||
@@ -364,10 +364,7 @@ void bandwidth_pid(pid_t pid, const char *command, const char *dev, int down, in | |||
364 | exit(1); | 364 | exit(1); |
365 | } | 365 | } |
366 | 366 | ||
367 | // remove \n and check for firejail sandbox | 367 | // check for firejail sandbox |
368 | char *ptr = strchr(comm, '\n'); | ||
369 | if (ptr) | ||
370 | *ptr = '\0'; | ||
371 | if (strcmp(comm, "firejail") != 0) { | 368 | if (strcmp(comm, "firejail") != 0) { |
372 | fprintf(stderr, "Error: cannot find sandbox\n"); | 369 | fprintf(stderr, "Error: cannot find sandbox\n"); |
373 | exit(1); | 370 | exit(1); |
diff --git a/src/firejail/caps.c b/src/firejail/caps.c index d623c5fd3..de7c93b48 100644 --- a/src/firejail/caps.c +++ b/src/firejail/caps.c | |||
@@ -419,10 +419,6 @@ void caps_print_filter(pid_t pid) { | |||
419 | // if the pid is that of a firejail process, use the pid of the first child process | 419 | // if the pid is that of a firejail process, use the pid of the first child process |
420 | char *comm = pid_proc_comm(pid); | 420 | char *comm = pid_proc_comm(pid); |
421 | if (comm) { | 421 | if (comm) { |
422 | // remove \n | ||
423 | char *ptr = strchr(comm, '\n'); | ||
424 | if (ptr) | ||
425 | *ptr = '\0'; | ||
426 | if (strcmp(comm, "firejail") == 0) { | 422 | if (strcmp(comm, "firejail") == 0) { |
427 | pid_t child; | 423 | pid_t child; |
428 | if (find_child(pid, &child) == 0) { | 424 | if (find_child(pid, &child) == 0) { |
diff --git a/src/firejail/fs_logger.c b/src/firejail/fs_logger.c index f803982d7..058bcc1c9 100644 --- a/src/firejail/fs_logger.c +++ b/src/firejail/fs_logger.c | |||
@@ -143,10 +143,6 @@ void fs_logger_print_log(pid_t pid) { | |||
143 | // if the pid is that of a firejail process, use the pid of the first child process | 143 | // if the pid is that of a firejail process, use the pid of the first child process |
144 | char *comm = pid_proc_comm(pid); | 144 | char *comm = pid_proc_comm(pid); |
145 | if (comm) { | 145 | if (comm) { |
146 | // remove \n | ||
147 | char *ptr = strchr(comm, '\n'); | ||
148 | if (ptr) | ||
149 | *ptr = '\0'; | ||
150 | if (strcmp(comm, "firejail") == 0) { | 146 | if (strcmp(comm, "firejail") == 0) { |
151 | pid_t child; | 147 | pid_t child; |
152 | if (find_child(pid, &child) == 0) { | 148 | if (find_child(pid, &child) == 0) { |
diff --git a/src/firejail/join.c b/src/firejail/join.c index 4cd315d90..21bb56e9d 100644 --- a/src/firejail/join.c +++ b/src/firejail/join.c | |||
@@ -202,10 +202,6 @@ void join(pid_t pid, const char *homedir, int argc, char **argv, int index) { | |||
202 | // if the pid is that of a firejail process, use the pid of the first child process | 202 | // if the pid is that of a firejail process, use the pid of the first child process |
203 | char *comm = pid_proc_comm(pid); | 203 | char *comm = pid_proc_comm(pid); |
204 | if (comm) { | 204 | if (comm) { |
205 | // remove \n | ||
206 | char *ptr = strchr(comm, '\n'); | ||
207 | if (ptr) | ||
208 | *ptr = '\0'; | ||
209 | if (strcmp(comm, "firejail") == 0) { | 205 | if (strcmp(comm, "firejail") == 0) { |
210 | pid_t child; | 206 | pid_t child; |
211 | if (find_child(pid, &child) == 0) { | 207 | if (find_child(pid, &child) == 0) { |
diff --git a/src/firejail/main.c b/src/firejail/main.c index 05745a3f1..a9fe13c78 100644 --- a/src/firejail/main.c +++ b/src/firejail/main.c | |||
@@ -618,10 +618,6 @@ int main(int argc, char **argv) { | |||
618 | pid_t ppid = getppid(); | 618 | pid_t ppid = getppid(); |
619 | char *comm = pid_proc_comm(ppid); | 619 | char *comm = pid_proc_comm(ppid); |
620 | if (comm) { | 620 | if (comm) { |
621 | // remove \n | ||
622 | char *ptr = strchr(comm, '\n'); | ||
623 | if (ptr) | ||
624 | *ptr = '\0'; | ||
625 | if (strcmp(comm, "sshd") == 0) | 621 | if (strcmp(comm, "sshd") == 0) |
626 | parent_sshd = 1; | 622 | parent_sshd = 1; |
627 | free(comm); | 623 | free(comm); |
diff --git a/src/firejail/network_main.c b/src/firejail/network_main.c index 9ddd56dcd..3fb79b9f4 100644 --- a/src/firejail/network_main.c +++ b/src/firejail/network_main.c | |||
@@ -246,10 +246,6 @@ void net_dns_print(pid_t pid) { | |||
246 | // if the pid is that of a firejail process, use the pid of the first child process | 246 | // if the pid is that of a firejail process, use the pid of the first child process |
247 | char *comm = pid_proc_comm(pid); | 247 | char *comm = pid_proc_comm(pid); |
248 | if (comm) { | 248 | if (comm) { |
249 | // remove \n | ||
250 | char *ptr = strchr(comm, '\n'); | ||
251 | if (ptr) | ||
252 | *ptr = '\0'; | ||
253 | if (strcmp(comm, "firejail") == 0) { | 249 | if (strcmp(comm, "firejail") == 0) { |
254 | pid_t child; | 250 | pid_t child; |
255 | if (find_child(pid, &child) == 0) { | 251 | if (find_child(pid, &child) == 0) { |
diff --git a/src/firejail/protocol.c b/src/firejail/protocol.c index 24fbfc024..3e81f13dc 100644 --- a/src/firejail/protocol.c +++ b/src/firejail/protocol.c | |||
@@ -341,10 +341,6 @@ void protocol_print_filter(pid_t pid) { | |||
341 | // if the pid is that of a firejail process, use the pid of the first child process | 341 | // if the pid is that of a firejail process, use the pid of the first child process |
342 | char *comm = pid_proc_comm(pid); | 342 | char *comm = pid_proc_comm(pid); |
343 | if (comm) { | 343 | if (comm) { |
344 | // remove \n | ||
345 | char *ptr = strchr(comm, '\n'); | ||
346 | if (ptr) | ||
347 | *ptr = '\0'; | ||
348 | if (strcmp(comm, "firejail") == 0) { | 344 | if (strcmp(comm, "firejail") == 0) { |
349 | pid_t child; | 345 | pid_t child; |
350 | if (find_child(pid, &child) == 0) { | 346 | if (find_child(pid, &child) == 0) { |
diff --git a/src/firejail/seccomp.c b/src/firejail/seccomp.c index f9a9df211..a5a77abab 100644 --- a/src/firejail/seccomp.c +++ b/src/firejail/seccomp.c | |||
@@ -820,10 +820,6 @@ void seccomp_print_filter(pid_t pid) { | |||
820 | // if the pid is that of a firejail process, use the pid of the first child process | 820 | // if the pid is that of a firejail process, use the pid of the first child process |
821 | char *comm = pid_proc_comm(pid); | 821 | char *comm = pid_proc_comm(pid); |
822 | if (comm) { | 822 | if (comm) { |
823 | // remove \n | ||
824 | char *ptr = strchr(comm, '\n'); | ||
825 | if (ptr) | ||
826 | *ptr = '\0'; | ||
827 | if (strcmp(comm, "firejail") == 0) { | 823 | if (strcmp(comm, "firejail") == 0) { |
828 | pid_t child; | 824 | pid_t child; |
829 | if (find_child(pid, &child) == 0) { | 825 | if (find_child(pid, &child) == 0) { |
diff --git a/src/firejail/shutdown.c b/src/firejail/shutdown.c index c88683aaa..3671901d0 100644 --- a/src/firejail/shutdown.c +++ b/src/firejail/shutdown.c | |||
@@ -46,10 +46,6 @@ void shut(pid_t pid) { | |||
46 | // if the pid is that of a firejail process, use the pid of a child process inside the sandbox | 46 | // if the pid is that of a firejail process, use the pid of a child process inside the sandbox |
47 | char *comm = pid_proc_comm(pid); | 47 | char *comm = pid_proc_comm(pid); |
48 | if (comm) { | 48 | if (comm) { |
49 | // remove \n | ||
50 | char *ptr = strchr(comm, '\n'); | ||
51 | if (ptr) | ||
52 | *ptr = '\0'; | ||
53 | if (strcmp(comm, "firejail") == 0) { | 49 | if (strcmp(comm, "firejail") == 0) { |
54 | pid_t child; | 50 | pid_t child; |
55 | if (find_child(pid, &child) == 0) { | 51 | if (find_child(pid, &child) == 0) { |
diff --git a/src/lib/common.c b/src/lib/common.c index f321c5a47..fd3ab7071 100644 --- a/src/lib/common.c +++ b/src/lib/common.c | |||
@@ -84,10 +84,6 @@ int name2pid(const char *name, pid_t *pid) { | |||
84 | // check if this is a firejail executable | 84 | // check if this is a firejail executable |
85 | char *comm = pid_proc_comm(newpid); | 85 | char *comm = pid_proc_comm(newpid); |
86 | if (comm) { | 86 | if (comm) { |
87 | // remove \n | ||
88 | char *ptr = strchr(comm, '\n'); | ||
89 | if (ptr) | ||
90 | *ptr = '\0'; | ||
91 | if (strcmp(comm, "firejail")) { | 87 | if (strcmp(comm, "firejail")) { |
92 | free(comm); | 88 | free(comm); |
93 | continue; | 89 | continue; |
@@ -150,6 +146,11 @@ char *pid_proc_comm(const pid_t pid) { | |||
150 | buffer[len] = '\0'; | 146 | buffer[len] = '\0'; |
151 | close(fd); | 147 | close(fd); |
152 | 148 | ||
149 | // remove \n | ||
150 | char *ptr = strchr(buffer, '\n'); | ||
151 | if (ptr) | ||
152 | *ptr = '\0'; | ||
153 | |||
153 | // return a malloc copy of the command line | 154 | // return a malloc copy of the command line |
154 | char *rv = strdup((char *) buffer); | 155 | char *rv = strdup((char *) buffer); |
155 | if (strlen(rv) == 0) { | 156 | if (strlen(rv) == 0) { |