From 96c920e166b40bbe50f216e294f2efac154a1cb2 Mon Sep 17 00:00:00 2001 From: Fred Barclay Date: Wed, 24 May 2017 14:13:52 -0500 Subject: Remove trailing whitespace from src/ --- src/lib/Makefile.in | 2 +- src/lib/common.c | 21 +++++++++------------ src/lib/libnetlink.c | 16 ++++++++-------- src/lib/pid.c | 32 ++++++++++++++++---------------- 4 files changed, 34 insertions(+), 37 deletions(-) (limited to 'src/lib') diff --git a/src/lib/Makefile.in b/src/lib/Makefile.in index 5549aca11..06ba3fee9 100644 --- a/src/lib/Makefile.in +++ b/src/lib/Makefile.in @@ -10,7 +10,7 @@ C_FILE_LIST = $(sort $(wildcard *.c)) OBJS = $(C_FILE_LIST:.c=.o) BINOBJS = $(foreach file, $(OBJS), $file) CFLAGS += -ggdb $(HAVE_FATAL_WARNINGS) -O2 -DVERSION='"$(VERSION)"' $(HAVE_GCOV) -fstack-protector-all -D_FORTIFY_SOURCE=2 -fPIC -Wformat -Wformat-security -LDFLAGS:=-pic -Wl,-z,relro -Wl,-z,now +LDFLAGS:=-pic -Wl,-z,relro -Wl,-z,now all: $(OBJS) diff --git a/src/lib/common.c b/src/lib/common.c index 6f2cebf12..98cb48abf 100644 --- a/src/lib/common.c +++ b/src/lib/common.c @@ -37,7 +37,7 @@ int join_namespace(pid_t pid, char *type) { char *path; if (asprintf(&path, "/proc/%u/ns/%s", pid, type) == -1) errExit("asprintf"); - + int fd = open(path, O_RDONLY); if (fd < 0) goto errout; @@ -55,14 +55,14 @@ errout: free(path); fprintf(stderr, "Error: cannot join namespace %s\\n", type); return -1; - + } // return 1 if error // this function requires root access - todo: fix it! int name2pid(const char *name, pid_t *pid) { pid_t parent = getpid(); - + DIR *dir; if (!(dir = opendir("/proc"))) { // sleep 2 seconds and try again @@ -72,7 +72,7 @@ int name2pid(const char *name, pid_t *pid) { exit(1); } } - + struct dirent *entry; char *end; while ((entry = readdir(dir))) { @@ -91,7 +91,7 @@ int name2pid(const char *name, pid_t *pid) { } free(comm); } - + // look for the sandbox name in /run/firejail/name/ // todo: use RUN_FIREJAIL_NAME_DIR define from src/firejail/firejail.h char *fname; @@ -249,10 +249,10 @@ int pid_proc_cmdline_x11_xpra_xephyr(const pid_t pid) { break; if (strncmp(arg, "--", 2) != 0) break; - + if (strcmp(arg, "--x11=xorg") == 0) return 0; - + // check x11 xpra or xephyr if (strncmp(arg, "--x11", 5) == 0) return 1; @@ -267,7 +267,7 @@ int pid_hidepid(void) { FILE *fp = fopen("/proc/mounts", "r"); if (!fp) return 1; - + char buf[BUFLEN]; while (fgets(buf, BUFLEN, fp)) { if (strstr(buf, "proc /proc proc")) { @@ -278,10 +278,7 @@ int pid_hidepid(void) { return 0; } } - + fclose(fp); return 0; } - - - diff --git a/src/lib/libnetlink.c b/src/lib/libnetlink.c index 417ef2c5f..d2975bd57 100644 --- a/src/lib/libnetlink.c +++ b/src/lib/libnetlink.c @@ -1,16 +1,16 @@ /* file extracted from iproute2 software package * * Original source code: - * + * * Information: * http://www.linuxfoundation.org/collaborate/workgroups/networking/iproute2 - * + * * Download: * http://www.kernel.org/pub/linux/utils/net/iproute2/ - * + * * Repository: * git://git.kernel.org/pub/scm/linux/kernel/git/shemminger/iproute2.git - * + * * License: GPL v2 * * Original copyright header @@ -166,7 +166,7 @@ int rtnl_send_check(struct rtnl_handle *rth, const void *buf, int len) struct nlmsgerr *err = (struct nlmsgerr*)NLMSG_DATA(h); if (h->nlmsg_len < NLMSG_LENGTH(sizeof(struct nlmsgerr))) fprintf(stderr, "ERROR truncated\n"); - else + else errno = -err->error; return -1; } @@ -600,7 +600,7 @@ if (type == IFLA_LINK) { for (i = 0; i < alen; i++) printf("%02x, ", *((unsigned char *)data + i)); printf("\n"); -} +} else if (type == IFLA_IFNAME) { printf("IFLA_IFNAME\n"); printf("\tdata - #%s#\n", data); @@ -615,8 +615,8 @@ else if (type == IFLA_ADDRESS) { printf("\n"); } else if (type == IFLA_BROADCAST) printf("IFLA_BROADCAST or IFLA_INFO_DATA\n"); - -printf("\tdata length: %d\n", alen); + +printf("\tdata length: %d\n", alen); #endif int len = RTA_LENGTH(alen); diff --git a/src/lib/pid.c b/src/lib/pid.c index 7ae5a8d3e..ed1e7b375 100644 --- a/src/lib/pid.c +++ b/src/lib/pid.c @@ -24,7 +24,7 @@ #include #include #include - + #define PIDS_BUFLEN 4096 //Process pids[max_pids]; Process *pids = NULL; @@ -36,14 +36,14 @@ void pid_getmem(unsigned pid, unsigned *rss, unsigned *shared) { char *file; if (asprintf(&file, "/proc/%u/statm", pid) == -1) errExit("asprintf"); - + FILE *fp = fopen(file, "r"); if (!fp) { free(file); return; } free(file); - + unsigned a, b, c; if (3 != fscanf(fp, "%u %u %u", &a, &b, &c)) { fclose(fp); @@ -67,7 +67,7 @@ void pid_get_cpu_time(unsigned pid, unsigned *utime, unsigned *stime) { return; } free(file); - + char line[PIDS_BUFLEN]; if (fgets(line, PIDS_BUFLEN - 1, fp)) { char *ptr = line; @@ -84,7 +84,7 @@ void pid_get_cpu_time(unsigned pid, unsigned *utime, unsigned *stime) { goto myexit; } -myexit: +myexit: fclose(fp); } @@ -100,7 +100,7 @@ unsigned long long pid_get_start_time(unsigned pid) { return 0; } free(file); - + char line[PIDS_BUFLEN]; unsigned long long retval = 0; if (fgets(line, PIDS_BUFLEN - 1, fp)) { @@ -117,7 +117,7 @@ unsigned long long pid_get_start_time(unsigned pid) { if (1 != sscanf(ptr, "%llu", &retval)) goto myexit; } - + myexit: fclose(fp); return retval; @@ -154,12 +154,12 @@ uid_t pid_get_uid(pid_t pid) { } if (*ptr == '\0') goto doexit; - + rv = atoi(ptr); break; // break regardless! } } -doexit: +doexit: fclose(fp); free(file); return rv; @@ -187,7 +187,7 @@ static void print_elem(unsigned index, int nowrap) { if (user ==NULL) user = ""; if (cmd) { - if (col < 4 || nowrap) + if (col < 4 || nowrap) printf("%s%u:%s:%s\n", indent, index, user, cmd); else { char *out; @@ -201,7 +201,7 @@ static void print_elem(unsigned index, int nowrap) { printf("%s", out); free(out); } - + free(cmd); } else { @@ -220,7 +220,7 @@ void pid_print_tree(unsigned index, unsigned parent, int nowrap) { // Remove unused parameter warning (void)parent; - + unsigned i; for (i = index + 1; i < (unsigned)max_pids; i++) { if (pids[i].parent == (pid_t)index) @@ -246,13 +246,13 @@ void pid_store_cpu(unsigned index, unsigned parent, unsigned *utime, unsigned *s // Remove unused parameter warning (void)parent; - + unsigned utmp = 0; unsigned stmp = 0; pid_get_cpu_time(index, &utmp, &stmp); *utime += utmp; *stime += stmp; - + unsigned i; for (i = index + 1; i < (unsigned)max_pids; i++) { if (pids[i].parent == (pid_t)index) @@ -293,7 +293,7 @@ void pid_read(pid_t mon_pid) { exit(1); } } - + pid_t child = -1; struct dirent *entry; char *end; @@ -308,7 +308,7 @@ void pid_read(pid_t mon_pid) { // skip PID 1 just in case we run a sandbox-in-sandbox if (pid == 1) continue; - + // open stat file char *file; if (asprintf(&file, "/proc/%u/status", pid) == -1) -- cgit v1.2.3-54-g00ecf