Skip to content

Commit

Permalink
unreadable firejail.users database fixes
Browse files Browse the repository at this point in the history
run firecfg with umask 022 and print a diagnostic message if
the database is not readable.

closes #2225
  • Loading branch information
smitsohu committed Nov 10, 2018
1 parent a41b201 commit ff6612f
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
3 changes: 3 additions & 0 deletions src/firecfg/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -316,6 +316,9 @@ int main(int argc, char **argv) {
int i;
int bindir_set = 0;

// set umask
umask(022);

// user setup
char *user = get_user();
assert(user);
Expand Down
11 changes: 8 additions & 3 deletions src/lib/firejail_user.c
Original file line number Diff line number Diff line change
Expand Up @@ -119,9 +119,13 @@ int firejail_user_check(const char *name) {
}

FILE *fp = fopen(fname, "r");
if (!fp) {
fprintf(stderr, "Error: cannot open %s for reading. "
"See \"man firejail-users\" for more information about this file.\n", fname);
perror("fopen");
exit(1);
}
free(fname);
if (!fp)
return 0;

char buf[MAXBUF];
while (fgets(buf, MAXBUF, fp)) {
Expand Down Expand Up @@ -165,8 +169,9 @@ void firejail_user_add(const char *name) {
return;
}
}
else
printf("Creating %s\n", fname);

printf("%s created\n", fname);
FILE *fp = fopen(fname, "a+");
if (!fp) {
fprintf(stderr, "Error: cannot open %s\n", fname);
Expand Down

0 comments on commit ff6612f

Please sign in to comment.