diff options
author | 2018-04-05 18:40:28 -0400 | |
---|---|---|
committer | 2018-04-05 18:40:28 -0400 | |
commit | 0992ba0b6ea4c01dee0fbcf30068e64be638162b (patch) | |
tree | fba3ab0abc43f95f8c7008540bae9ccd23d639af /src/firecfg/main.c | |
parent | Merge pull request #1864 from glitsj16/enchant (diff) | |
download | firejail-0992ba0b6ea4c01dee0fbcf30068e64be638162b.tar.gz firejail-0992ba0b6ea4c01dee0fbcf30068e64be638162b.tar.zst firejail-0992ba0b6ea4c01dee0fbcf30068e64be638162b.zip |
user access database in /etc/firejail/firejail.users - more to come
Diffstat (limited to 'src/firecfg/main.c')
-rw-r--r-- | src/firecfg/main.c | 24 |
1 files changed, 23 insertions, 1 deletions
diff --git a/src/firecfg/main.c b/src/firecfg/main.c index e636dc385..a54607aec 100644 --- a/src/firecfg/main.c +++ b/src/firecfg/main.c | |||
@@ -19,6 +19,7 @@ | |||
19 | */ | 19 | */ |
20 | 20 | ||
21 | #include "firecfg.h" | 21 | #include "firecfg.h" |
22 | #include "../include/firejail_user.h" | ||
22 | int arg_debug = 0; | 23 | int arg_debug = 0; |
23 | 24 | ||
24 | static char *usage_str = | 25 | static char *usage_str = |
@@ -29,6 +30,7 @@ static char *usage_str = | |||
29 | "The symbolic links are placed in /usr/local/bin. For more information, see\n" | 30 | "The symbolic links are placed in /usr/local/bin. For more information, see\n" |
30 | "DESKTOP INTEGRATION section in man 1 firejail.\n\n" | 31 | "DESKTOP INTEGRATION section in man 1 firejail.\n\n" |
31 | "Usage: firecfg [OPTIONS]\n\n" | 32 | "Usage: firecfg [OPTIONS]\n\n" |
33 | " --add-users user [user] - add the users to Firejail access database\n" | ||
32 | " --clean - remove all firejail symbolic links.\n\n" | 34 | " --clean - remove all firejail symbolic links.\n\n" |
33 | " --debug - print debug messages.\n\n" | 35 | " --debug - print debug messages.\n\n" |
34 | " --fix - fix .desktop files.\n\n" | 36 | " --fix - fix .desktop files.\n\n" |
@@ -315,6 +317,19 @@ int main(int argc, char **argv) { | |||
315 | sound(); | 317 | sound(); |
316 | return 0; | 318 | return 0; |
317 | } | 319 | } |
320 | else if (strcmp(argv[i], "--add-users") == 0) { | ||
321 | int j; | ||
322 | if (getuid() != 0) { | ||
323 | fprintf(stderr, "Error: you need to be root to use this option\n"); | ||
324 | exit(1); | ||
325 | } | ||
326 | |||
327 | for (j = i + 1; j < argc; j++) { | ||
328 | printf("Adding user %s to Firejail access database in %s/firejail.users\n", argv[j], SYSCONFDIR); | ||
329 | firejail_user_add(argv[j]); | ||
330 | } | ||
331 | return 0; | ||
332 | } | ||
318 | else { | 333 | else { |
319 | fprintf(stderr, "Error: invalid command line option\n"); | 334 | fprintf(stderr, "Error: invalid command line option\n"); |
320 | usage(); | 335 | usage(); |
@@ -353,7 +368,7 @@ int main(int argc, char **argv) { | |||
353 | 368 | ||
354 | 369 | ||
355 | 370 | ||
356 | // switch to the local user, and fix desktop files | 371 | // user setup |
357 | char *user = getlogin(); | 372 | char *user = getlogin(); |
358 | if (!user) { | 373 | if (!user) { |
359 | user = getenv("SUDO_USER"); | 374 | user = getenv("SUDO_USER"); |
@@ -362,6 +377,13 @@ int main(int argc, char **argv) { | |||
362 | } | 377 | } |
363 | } | 378 | } |
364 | 379 | ||
380 | // add user to firejail access database | ||
381 | if (user) { | ||
382 | printf("\nAdding user %s to Firejail access database in %s/firejail.users\n", user, SYSCONFDIR); | ||
383 | firejail_user_add(user); | ||
384 | } | ||
385 | |||
386 | // switch to the local user, and fix desktop files | ||
365 | if (user) { | 387 | if (user) { |
366 | // find home directory | 388 | // find home directory |
367 | struct passwd *pw = getpwnam(user); | 389 | struct passwd *pw = getpwnam(user); |