diff options
Diffstat (limited to 'src/firejail/checkcfg.c')
-rw-r--r-- | src/firejail/checkcfg.c | 36 |
1 files changed, 18 insertions, 18 deletions
diff --git a/src/firejail/checkcfg.c b/src/firejail/checkcfg.c index 3c0c1b9ac..f4e28f084 100644 --- a/src/firejail/checkcfg.c +++ b/src/firejail/checkcfg.c | |||
@@ -49,33 +49,33 @@ int checkcfg(int val) { | |||
49 | cfg_val[CFG_FIREJAIL_PROMPT] = 0; | 49 | cfg_val[CFG_FIREJAIL_PROMPT] = 0; |
50 | cfg_val[CFG_FOLLOW_SYMLINK_PRIVATE_BIN] = 0; | 50 | cfg_val[CFG_FOLLOW_SYMLINK_PRIVATE_BIN] = 0; |
51 | cfg_val[CFG_DISABLE_MNT] = 0; | 51 | cfg_val[CFG_DISABLE_MNT] = 0; |
52 | 52 | ||
53 | // open configuration file | 53 | // open configuration file |
54 | const char *fname = SYSCONFDIR "/firejail.config"; | 54 | const char *fname = SYSCONFDIR "/firejail.config"; |
55 | fp = fopen(fname, "r"); | 55 | fp = fopen(fname, "r"); |
56 | if (!fp) { | 56 | if (!fp) { |
57 | #ifdef HAVE_GLOBALCFG | 57 | #ifdef HAVE_GLOBALCFG |
58 | fprintf(stderr, "Error: Firejail configuration file %s not found\n", fname); | 58 | fprintf(stderr, "Error: Firejail configuration file %s not found\n", fname); |
59 | exit(1); | 59 | exit(1); |
60 | #else | 60 | #else |
61 | initialized = 1; | 61 | initialized = 1; |
62 | return cfg_val[val]; | 62 | return cfg_val[val]; |
63 | #endif | 63 | #endif |
64 | } | 64 | } |
65 | 65 | ||
66 | // read configuration file | 66 | // read configuration file |
67 | char buf[MAX_READ]; | 67 | char buf[MAX_READ]; |
68 | while (fgets(buf,MAX_READ, fp)) { | 68 | while (fgets(buf,MAX_READ, fp)) { |
69 | line++; | 69 | line++; |
70 | if (*buf == '#' || *buf == '\n') | 70 | if (*buf == '#' || *buf == '\n') |
71 | continue; | 71 | continue; |
72 | 72 | ||
73 | // parse line | 73 | // parse line |
74 | ptr = line_remove_spaces(buf); | 74 | ptr = line_remove_spaces(buf); |
75 | if (!ptr) | 75 | if (!ptr) |
76 | continue; | 76 | continue; |
77 | 77 | ||
78 | // file transfer | 78 | // file transfer |
79 | else if (strncmp(ptr, "file-transfer ", 14) == 0) { | 79 | else if (strncmp(ptr, "file-transfer ", 14) == 0) { |
80 | if (strcmp(ptr + 14, "yes") == 0) | 80 | if (strcmp(ptr + 14, "yes") == 0) |
81 | cfg_val[CFG_FILE_TRANSFER] = 1; | 81 | cfg_val[CFG_FILE_TRANSFER] = 1; |
@@ -209,14 +209,14 @@ int checkcfg(int val) { | |||
209 | char *end = strchr(fname, ' '); | 209 | char *end = strchr(fname, ' '); |
210 | if (end) | 210 | if (end) |
211 | *end = '\0'; | 211 | *end = '\0'; |
212 | 212 | ||
213 | // is the file present? | 213 | // is the file present? |
214 | struct stat s; | 214 | struct stat s; |
215 | if (stat(fname, &s) == -1) { | 215 | if (stat(fname, &s) == -1) { |
216 | fprintf(stderr, "Error: netfilter-default file %s not available\n", fname); | 216 | fprintf(stderr, "Error: netfilter-default file %s not available\n", fname); |
217 | exit(1); | 217 | exit(1); |
218 | } | 218 | } |
219 | 219 | ||
220 | if (netfilter_default) | 220 | if (netfilter_default) |
221 | goto errout; | 221 | goto errout; |
222 | netfilter_default = strdup(fname); | 222 | netfilter_default = strdup(fname); |
@@ -225,7 +225,7 @@ int checkcfg(int val) { | |||
225 | if (arg_debug) | 225 | if (arg_debug) |
226 | printf("netfilter default file %s\n", fname); | 226 | printf("netfilter default file %s\n", fname); |
227 | } | 227 | } |
228 | 228 | ||
229 | // Xephyr screen size | 229 | // Xephyr screen size |
230 | else if (strncmp(ptr, "xephyr-screen ", 14) == 0) { | 230 | else if (strncmp(ptr, "xephyr-screen ", 14) == 0) { |
231 | // expecting two numbers and an x between them | 231 | // expecting two numbers and an x between them |
@@ -237,7 +237,7 @@ int checkcfg(int val) { | |||
237 | if (asprintf(&xephyr_screen, "%dx%d", n1, n2) == -1) | 237 | if (asprintf(&xephyr_screen, "%dx%d", n1, n2) == -1) |
238 | errExit("asprintf"); | 238 | errExit("asprintf"); |
239 | } | 239 | } |
240 | 240 | ||
241 | // xephyr window title | 241 | // xephyr window title |
242 | else if (strncmp(ptr, "xephyr-window-title ", 20) == 0) { | 242 | else if (strncmp(ptr, "xephyr-window-title ", 20) == 0) { |
243 | if (strcmp(ptr + 20, "yes") == 0) | 243 | if (strcmp(ptr + 20, "yes") == 0) |
@@ -247,7 +247,7 @@ int checkcfg(int val) { | |||
247 | else | 247 | else |
248 | goto errout; | 248 | goto errout; |
249 | } | 249 | } |
250 | 250 | ||
251 | // Xephyr command extra parameters | 251 | // Xephyr command extra parameters |
252 | else if (strncmp(ptr, "xephyr-extra-params ", 20) == 0) { | 252 | else if (strncmp(ptr, "xephyr-extra-params ", 20) == 0) { |
253 | if (*xephyr_extra_params != '\0') | 253 | if (*xephyr_extra_params != '\0') |
@@ -256,7 +256,7 @@ int checkcfg(int val) { | |||
256 | if (!xephyr_extra_params) | 256 | if (!xephyr_extra_params) |
257 | errExit("strdup"); | 257 | errExit("strdup"); |
258 | } | 258 | } |
259 | 259 | ||
260 | // xpra server extra parameters | 260 | // xpra server extra parameters |
261 | else if (strncmp(ptr, "xpra-extra-params ", 18) == 0) { | 261 | else if (strncmp(ptr, "xpra-extra-params ", 18) == 0) { |
262 | if (*xpra_extra_params != '\0') | 262 | if (*xpra_extra_params != '\0') |
@@ -287,7 +287,7 @@ int checkcfg(int val) { | |||
287 | if (!xvfb_extra_params) | 287 | if (!xvfb_extra_params) |
288 | errExit("strdup"); | 288 | errExit("strdup"); |
289 | } | 289 | } |
290 | 290 | ||
291 | // quiet by default | 291 | // quiet by default |
292 | else if (strncmp(ptr, "quiet-by-default ", 17) == 0) { | 292 | else if (strncmp(ptr, "quiet-by-default ", 17) == 0) { |
293 | if (strcmp(ptr + 17, "yes") == 0) | 293 | if (strcmp(ptr + 17, "yes") == 0) |
@@ -355,9 +355,9 @@ int checkcfg(int val) { | |||
355 | fclose(fp); | 355 | fclose(fp); |
356 | initialized = 1; | 356 | initialized = 1; |
357 | } | 357 | } |
358 | 358 | ||
359 | return cfg_val[val]; | 359 | return cfg_val[val]; |
360 | 360 | ||
361 | errout: | 361 | errout: |
362 | assert(ptr); | 362 | assert(ptr); |
363 | free(ptr); | 363 | free(ptr); |
@@ -477,5 +477,5 @@ void print_compiletime_support(void) { | |||
477 | "disabled" | 477 | "disabled" |
478 | #endif | 478 | #endif |
479 | ); | 479 | ); |
480 | 480 | ||
481 | } | 481 | } |