diff options
author | Fred-Barclay <Fred-Barclay@users.noreply.github.com> | 2017-11-19 15:02:42 -0600 |
---|---|---|
committer | Fred-Barclay <Fred-Barclay@users.noreply.github.com> | 2017-11-19 15:02:42 -0600 |
commit | b936e5ab77dfa0b54b2f6f6dd53762a8244e4230 (patch) | |
tree | edb7237ba54d7c2a85a8531c8901d6466c5e0e4d /src/fbuilder/build_home.c | |
parent | More qtox profile tightening (diff) | |
download | firejail-b936e5ab77dfa0b54b2f6f6dd53762a8244e4230.tar.gz firejail-b936e5ab77dfa0b54b2f6f6dd53762a8244e4230.tar.zst firejail-b936e5ab77dfa0b54b2f6f6dd53762a8244e4230.zip |
strip trailing whitespace
Diffstat (limited to 'src/fbuilder/build_home.c')
-rw-r--r-- | src/fbuilder/build_home.c | 30 |
1 files changed, 15 insertions, 15 deletions
diff --git a/src/fbuilder/build_home.c b/src/fbuilder/build_home.c index 9bbd2c258..18bf5d702 100644 --- a/src/fbuilder/build_home.c +++ b/src/fbuilder/build_home.c | |||
@@ -29,7 +29,7 @@ static void load_whitelist_common(void) { | |||
29 | fprintf(stderr, "Error: cannot open whitelist-common.inc\n"); | 29 | fprintf(stderr, "Error: cannot open whitelist-common.inc\n"); |
30 | exit(1); | 30 | exit(1); |
31 | } | 31 | } |
32 | 32 | ||
33 | char buf[MAX_BUF]; | 33 | char buf[MAX_BUF]; |
34 | while (fgets(buf, MAX_BUF, fp)) { | 34 | while (fgets(buf, MAX_BUF, fp)) { |
35 | if (strncmp(buf, "whitelist ~/", 12) != 0) | 35 | if (strncmp(buf, "whitelist ~/", 12) != 0) |
@@ -39,33 +39,33 @@ static void load_whitelist_common(void) { | |||
39 | if (!ptr) | 39 | if (!ptr) |
40 | continue; | 40 | continue; |
41 | *ptr = '\0'; | 41 | *ptr = '\0'; |
42 | 42 | ||
43 | // add the file to skip list | 43 | // add the file to skip list |
44 | db_skip = filedb_add(db_skip, fn); | 44 | db_skip = filedb_add(db_skip, fn); |
45 | } | 45 | } |
46 | 46 | ||
47 | fclose(fp); | 47 | fclose(fp); |
48 | } | 48 | } |
49 | 49 | ||
50 | void process_home(const char *fname, char *home, int home_len) { | 50 | void process_home(const char *fname, char *home, int home_len) { |
51 | assert(fname); | 51 | assert(fname); |
52 | assert(home); | 52 | assert(home); |
53 | assert(home_len); | 53 | assert(home_len); |
54 | 54 | ||
55 | // process trace file | 55 | // process trace file |
56 | FILE *fp = fopen(fname, "r"); | 56 | FILE *fp = fopen(fname, "r"); |
57 | if (!fp) { | 57 | if (!fp) { |
58 | fprintf(stderr, "Error: cannot open %s\n", fname); | 58 | fprintf(stderr, "Error: cannot open %s\n", fname); |
59 | exit(1); | 59 | exit(1); |
60 | } | 60 | } |
61 | 61 | ||
62 | char buf[MAX_BUF]; | 62 | char buf[MAX_BUF]; |
63 | while (fgets(buf, MAX_BUF, fp)) { | 63 | while (fgets(buf, MAX_BUF, fp)) { |
64 | // remove \n | 64 | // remove \n |
65 | char *ptr = strchr(buf, '\n'); | 65 | char *ptr = strchr(buf, '\n'); |
66 | if (ptr) | 66 | if (ptr) |
67 | *ptr = '\0'; | 67 | *ptr = '\0'; |
68 | 68 | ||
69 | // parse line: 4:galculator:access /etc/fonts/conf.d:0 | 69 | // parse line: 4:galculator:access /etc/fonts/conf.d:0 |
70 | // number followed by : | 70 | // number followed by : |
71 | ptr = buf; | 71 | ptr = buf; |
@@ -107,8 +107,8 @@ void process_home(const char *fname, char *home, int home_len) { | |||
107 | if (strcmp(ptr, home) == 0) | 107 | if (strcmp(ptr, home) == 0) |
108 | continue; | 108 | continue; |
109 | ptr += home_len + 1; | 109 | ptr += home_len + 1; |
110 | 110 | ||
111 | // skip files handled automatically by firejail | 111 | // skip files handled automatically by firejail |
112 | if (strcmp(ptr, ".Xauthority") == 0 || | 112 | if (strcmp(ptr, ".Xauthority") == 0 || |
113 | strcmp(ptr, ".Xdefaults-debian") == 0 || | 113 | strcmp(ptr, ".Xdefaults-debian") == 0 || |
114 | strncmp(ptr, ".config/pulse/", 13) == 0 || | 114 | strncmp(ptr, ".config/pulse/", 13) == 0 || |
@@ -116,8 +116,8 @@ void process_home(const char *fname, char *home, int home_len) { | |||
116 | strncmp(ptr, ".bash_hist", 10) == 0 || | 116 | strncmp(ptr, ".bash_hist", 10) == 0 || |
117 | strcmp(ptr, ".bashrc") == 0) | 117 | strcmp(ptr, ".bashrc") == 0) |
118 | continue; | 118 | continue; |
119 | 119 | ||
120 | 120 | ||
121 | // try to find the relevant directory for this file | 121 | // try to find the relevant directory for this file |
122 | char *dir = extract_dir(ptr); | 122 | char *dir = extract_dir(ptr); |
123 | char *toadd = (dir)? dir: ptr; | 123 | char *toadd = (dir)? dir: ptr; |
@@ -160,7 +160,7 @@ void process_home(const char *fname, char *home, int home_len) { | |||
160 | // process fname, fname.1, fname.2, fname.3, fname.4, fname.5 | 160 | // process fname, fname.1, fname.2, fname.3, fname.4, fname.5 |
161 | void build_home(const char *fname, FILE *fp) { | 161 | void build_home(const char *fname, FILE *fp) { |
162 | assert(fname); | 162 | assert(fname); |
163 | 163 | ||
164 | // load whitelist common | 164 | // load whitelist common |
165 | load_whitelist_common(); | 165 | load_whitelist_common(); |
166 | 166 | ||
@@ -172,10 +172,10 @@ void build_home(const char *fname, FILE *fp) { | |||
172 | if (!home) | 172 | if (!home) |
173 | errExit("getpwuid"); | 173 | errExit("getpwuid"); |
174 | int home_len = strlen(home); | 174 | int home_len = strlen(home); |
175 | 175 | ||
176 | // run fname | 176 | // run fname |
177 | process_home(fname, home, home_len); | 177 | process_home(fname, home, home_len); |
178 | 178 | ||
179 | // run all the rest | 179 | // run all the rest |
180 | struct stat s; | 180 | struct stat s; |
181 | int i; | 181 | int i; |
@@ -187,7 +187,7 @@ void build_home(const char *fname, FILE *fp) { | |||
187 | process_home(newname, home, home_len); | 187 | process_home(newname, home, home_len); |
188 | free(newname); | 188 | free(newname); |
189 | } | 189 | } |
190 | 190 | ||
191 | // print the out list if any | 191 | // print the out list if any |
192 | if (db_out) { | 192 | if (db_out) { |
193 | filedb_print(db_out, "whitelist ~/", fp); | 193 | filedb_print(db_out, "whitelist ~/", fp); |