diff options
author | Fred Barclay <Fred-Barclay@users.noreply.github.com> | 2017-05-24 14:13:52 -0500 |
---|---|---|
committer | Fred Barclay <Fred-Barclay@users.noreply.github.com> | 2017-05-24 14:13:52 -0500 |
commit | 96c920e166b40bbe50f216e294f2efac154a1cb2 (patch) | |
tree | fa80a34e81863ab897f2f2b8ec4124b10d023516 /src/ftee | |
parent | remove trailing whitespace from etc/ (diff) | |
download | firejail-96c920e166b40bbe50f216e294f2efac154a1cb2.tar.gz firejail-96c920e166b40bbe50f216e294f2efac154a1cb2.tar.zst firejail-96c920e166b40bbe50f216e294f2efac154a1cb2.zip |
Remove trailing whitespace from src/
Diffstat (limited to 'src/ftee')
-rw-r--r-- | src/ftee/Makefile.in | 1 | ||||
-rw-r--r-- | src/ftee/ftee.h | 2 | ||||
-rw-r--r-- | src/ftee/main.c | 32 |
3 files changed, 17 insertions, 18 deletions
diff --git a/src/ftee/Makefile.in b/src/ftee/Makefile.in index ad508cadd..0f14a7bd4 100644 --- a/src/ftee/Makefile.in +++ b/src/ftee/Makefile.in | |||
@@ -24,4 +24,3 @@ clean:; rm -f *.o ftee *.gcov *.gcda *.gcno | |||
24 | 24 | ||
25 | distclean: clean | 25 | distclean: clean |
26 | rm -fr Makefile | 26 | rm -fr Makefile |
27 | |||
diff --git a/src/ftee/ftee.h b/src/ftee/ftee.h index b663f1f38..5070cf12e 100644 --- a/src/ftee/ftee.h +++ b/src/ftee/ftee.h | |||
@@ -21,4 +21,4 @@ | |||
21 | #define FTEE_H | 21 | #define FTEE_H |
22 | #include "../include/common.h" | 22 | #include "../include/common.h" |
23 | 23 | ||
24 | #endif \ No newline at end of file | 24 | #endif |
diff --git a/src/ftee/main.c b/src/ftee/main.c index d425be07c..2628a77c5 100644 --- a/src/ftee/main.c +++ b/src/ftee/main.c | |||
@@ -47,7 +47,7 @@ static void log_rotate(const char *fname) { | |||
47 | strcpy(name1, fname); | 47 | strcpy(name1, fname); |
48 | strcpy(name2, fname); | 48 | strcpy(name2, fname); |
49 | fflush(0); | 49 | fflush(0); |
50 | 50 | ||
51 | // delete filename.5 | 51 | // delete filename.5 |
52 | sprintf(name1 + index, ".5"); | 52 | sprintf(name1 + index, ".5"); |
53 | if (stat(name1, &s) == 0) { | 53 | if (stat(name1, &s) == 0) { |
@@ -55,7 +55,7 @@ static void log_rotate(const char *fname) { | |||
55 | if (rv == -1) | 55 | if (rv == -1) |
56 | perror("unlink"); | 56 | perror("unlink"); |
57 | } | 57 | } |
58 | 58 | ||
59 | // move files 1 to 4 down one position | 59 | // move files 1 to 4 down one position |
60 | sprintf(name2 + index, ".4"); | 60 | sprintf(name2 + index, ".4"); |
61 | if (stat(name2, &s) == 0) { | 61 | if (stat(name2, &s) == 0) { |
@@ -96,14 +96,14 @@ static void log_rotate(const char *fname) { | |||
96 | if (rv == -1) | 96 | if (rv == -1) |
97 | perror("rename"); | 97 | perror("rename"); |
98 | } | 98 | } |
99 | 99 | ||
100 | free(name1); | 100 | free(name1); |
101 | free(name2); | 101 | free(name2); |
102 | } | 102 | } |
103 | 103 | ||
104 | static void log_write(const unsigned char *str, int len, const char *fname) { | 104 | static void log_write(const unsigned char *str, int len, const char *fname) { |
105 | assert(fname); | 105 | assert(fname); |
106 | 106 | ||
107 | if (out_fp == NULL) { | 107 | if (out_fp == NULL) { |
108 | out_fp = fopen(fname, "w"); | 108 | out_fp = fopen(fname, "w"); |
109 | if (!out_fp) { | 109 | if (!out_fp) { |
@@ -112,7 +112,7 @@ static void log_write(const unsigned char *str, int len, const char *fname) { | |||
112 | } | 112 | } |
113 | out_cnt = 0; | 113 | out_cnt = 0; |
114 | } | 114 | } |
115 | 115 | ||
116 | // rotate files | 116 | // rotate files |
117 | out_cnt += len; | 117 | out_cnt += len; |
118 | if (out_cnt >= out_max) { | 118 | if (out_cnt >= out_max) { |
@@ -127,9 +127,9 @@ static void log_write(const unsigned char *str, int len, const char *fname) { | |||
127 | exit(1); | 127 | exit(1); |
128 | } | 128 | } |
129 | out_cnt = len; | 129 | out_cnt = len; |
130 | } | 130 | } |
131 | 131 | ||
132 | fwrite(str, len, 1, out_fp); | 132 | fwrite(str, len, 1, out_fp); |
133 | fflush(0); | 133 | fflush(0); |
134 | } | 134 | } |
135 | 135 | ||
@@ -139,7 +139,7 @@ static int is_dir(const char *fname) { | |||
139 | assert(fname); | 139 | assert(fname); |
140 | if (*fname == '\0') | 140 | if (*fname == '\0') |
141 | return 0; | 141 | return 0; |
142 | 142 | ||
143 | // if fname doesn't end in '/', add one | 143 | // if fname doesn't end in '/', add one |
144 | int rv; | 144 | int rv; |
145 | struct stat s; | 145 | struct stat s; |
@@ -150,14 +150,14 @@ static int is_dir(const char *fname) { | |||
150 | if (asprintf(&tmp, "%s/", fname) == -1) { | 150 | if (asprintf(&tmp, "%s/", fname) == -1) { |
151 | fprintf(stderr, "Error: cannot allocate memory, %s:%d\n", __FILE__, __LINE__); | 151 | fprintf(stderr, "Error: cannot allocate memory, %s:%d\n", __FILE__, __LINE__); |
152 | exit(1); | 152 | exit(1); |
153 | } | 153 | } |
154 | rv = stat(tmp, &s); | 154 | rv = stat(tmp, &s); |
155 | free(tmp); | 155 | free(tmp); |
156 | } | 156 | } |
157 | 157 | ||
158 | if (rv == -1) | 158 | if (rv == -1) |
159 | return 0; | 159 | return 0; |
160 | 160 | ||
161 | if (S_ISDIR(s.st_mode)) | 161 | if (S_ISDIR(s.st_mode)) |
162 | return 1; | 162 | return 1; |
163 | 163 | ||
@@ -199,13 +199,13 @@ int main(int argc, char **argv) { | |||
199 | // do not accept directories, links, and files with ".." | 199 | // do not accept directories, links, and files with ".." |
200 | if (strstr(fname, "..") || is_link(fname) || is_dir(fname)) | 200 | if (strstr(fname, "..") || is_link(fname) || is_dir(fname)) |
201 | goto errexit; | 201 | goto errexit; |
202 | 202 | ||
203 | struct stat s; | 203 | struct stat s; |
204 | if (stat(fname, &s) == 0) { | 204 | if (stat(fname, &s) == 0) { |
205 | // check permissions | 205 | // check permissions |
206 | if (s.st_uid != getuid() || s.st_gid != getgid()) | 206 | if (s.st_uid != getuid() || s.st_gid != getgid()) |
207 | goto errexit; | 207 | goto errexit; |
208 | 208 | ||
209 | // check hard links | 209 | // check hard links |
210 | if (s.st_nlink != 1) | 210 | if (s.st_nlink != 1) |
211 | goto errexit; | 211 | goto errexit; |
@@ -229,11 +229,11 @@ int main(int argc, char **argv) { | |||
229 | continue; | 229 | continue; |
230 | if (n <= 0) | 230 | if (n <= 0) |
231 | break; | 231 | break; |
232 | 232 | ||
233 | fwrite(buf, n, 1, stdout); | 233 | fwrite(buf, n, 1, stdout); |
234 | log_write(buf, n, fname); | 234 | log_write(buf, n, fname); |
235 | } | 235 | } |
236 | 236 | ||
237 | log_close(); | 237 | log_close(); |
238 | return 0; | 238 | return 0; |
239 | 239 | ||