From 6ac6111f5f3bc18360c5b80bf1ade95b2a06f2c8 Mon Sep 17 00:00:00 2001 From: netblue30 Date: Wed, 2 Mar 2016 08:49:50 -0500 Subject: cleanup --- src/firejail/bandwidth.c | 5 +---- src/firejail/caps.c | 4 ---- src/firejail/fs_logger.c | 4 ---- src/firejail/join.c | 4 ---- src/firejail/main.c | 4 ---- src/firejail/network_main.c | 4 ---- src/firejail/protocol.c | 4 ---- src/firejail/seccomp.c | 4 ---- src/firejail/shutdown.c | 4 ---- src/lib/common.c | 9 +++++---- 10 files changed, 6 insertions(+), 40 deletions(-) (limited to 'src') 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 exit(1); } - // remove \n and check for firejail sandbox - char *ptr = strchr(comm, '\n'); - if (ptr) - *ptr = '\0'; + // check for firejail sandbox if (strcmp(comm, "firejail") != 0) { fprintf(stderr, "Error: cannot find sandbox\n"); 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) { // if the pid is that of a firejail process, use the pid of the first child process char *comm = pid_proc_comm(pid); if (comm) { - // remove \n - char *ptr = strchr(comm, '\n'); - if (ptr) - *ptr = '\0'; if (strcmp(comm, "firejail") == 0) { pid_t child; 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) { // if the pid is that of a firejail process, use the pid of the first child process char *comm = pid_proc_comm(pid); if (comm) { - // remove \n - char *ptr = strchr(comm, '\n'); - if (ptr) - *ptr = '\0'; if (strcmp(comm, "firejail") == 0) { pid_t child; 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) { // if the pid is that of a firejail process, use the pid of the first child process char *comm = pid_proc_comm(pid); if (comm) { - // remove \n - char *ptr = strchr(comm, '\n'); - if (ptr) - *ptr = '\0'; if (strcmp(comm, "firejail") == 0) { pid_t child; 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) { pid_t ppid = getppid(); char *comm = pid_proc_comm(ppid); if (comm) { - // remove \n - char *ptr = strchr(comm, '\n'); - if (ptr) - *ptr = '\0'; if (strcmp(comm, "sshd") == 0) parent_sshd = 1; 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) { // if the pid is that of a firejail process, use the pid of the first child process char *comm = pid_proc_comm(pid); if (comm) { - // remove \n - char *ptr = strchr(comm, '\n'); - if (ptr) - *ptr = '\0'; if (strcmp(comm, "firejail") == 0) { pid_t child; 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) { // if the pid is that of a firejail process, use the pid of the first child process char *comm = pid_proc_comm(pid); if (comm) { - // remove \n - char *ptr = strchr(comm, '\n'); - if (ptr) - *ptr = '\0'; if (strcmp(comm, "firejail") == 0) { pid_t child; 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) { // if the pid is that of a firejail process, use the pid of the first child process char *comm = pid_proc_comm(pid); if (comm) { - // remove \n - char *ptr = strchr(comm, '\n'); - if (ptr) - *ptr = '\0'; if (strcmp(comm, "firejail") == 0) { pid_t child; 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) { // if the pid is that of a firejail process, use the pid of a child process inside the sandbox char *comm = pid_proc_comm(pid); if (comm) { - // remove \n - char *ptr = strchr(comm, '\n'); - if (ptr) - *ptr = '\0'; if (strcmp(comm, "firejail") == 0) { pid_t child; 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) { // check if this is a firejail executable char *comm = pid_proc_comm(newpid); if (comm) { - // remove \n - char *ptr = strchr(comm, '\n'); - if (ptr) - *ptr = '\0'; if (strcmp(comm, "firejail")) { free(comm); continue; @@ -150,6 +146,11 @@ char *pid_proc_comm(const pid_t pid) { buffer[len] = '\0'; close(fd); + // remove \n + char *ptr = strchr(buffer, '\n'); + if (ptr) + *ptr = '\0'; + // return a malloc copy of the command line char *rv = strdup((char *) buffer); if (strlen(rv) == 0) { -- cgit v1.2.3-54-g00ecf