diff options
author | smitsohu <smitsohu@gmail.com> | 2018-11-10 14:57:26 +0100 |
---|---|---|
committer | smitsohu <smitsohu@gmail.com> | 2018-11-10 14:57:26 +0100 |
commit | ff6612fac86e1a79ba264167f0263ff12f62f346 (patch) | |
tree | 3bccb3d20014beaf146da715b6955eabbacfe8f0 /src/lib/firejail_user.c | |
parent | Fixes for brave browser (diff) | |
download | firejail-ff6612fac86e1a79ba264167f0263ff12f62f346.tar.gz firejail-ff6612fac86e1a79ba264167f0263ff12f62f346.tar.zst firejail-ff6612fac86e1a79ba264167f0263ff12f62f346.zip |
unreadable firejail.users database fixes
run firecfg with umask 022 and print a diagnostic message if
the database is not readable.
closes #2225
Diffstat (limited to 'src/lib/firejail_user.c')
-rw-r--r-- | src/lib/firejail_user.c | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/src/lib/firejail_user.c b/src/lib/firejail_user.c index b270db459..03aaa3b4e 100644 --- a/src/lib/firejail_user.c +++ b/src/lib/firejail_user.c | |||
@@ -119,9 +119,13 @@ int firejail_user_check(const char *name) { | |||
119 | } | 119 | } |
120 | 120 | ||
121 | FILE *fp = fopen(fname, "r"); | 121 | FILE *fp = fopen(fname, "r"); |
122 | if (!fp) { | ||
123 | fprintf(stderr, "Error: cannot open %s for reading. " | ||
124 | "See \"man firejail-users\" for more information about this file.\n", fname); | ||
125 | perror("fopen"); | ||
126 | exit(1); | ||
127 | } | ||
122 | free(fname); | 128 | free(fname); |
123 | if (!fp) | ||
124 | return 0; | ||
125 | 129 | ||
126 | char buf[MAXBUF]; | 130 | char buf[MAXBUF]; |
127 | while (fgets(buf, MAXBUF, fp)) { | 131 | while (fgets(buf, MAXBUF, fp)) { |
@@ -165,8 +169,9 @@ void firejail_user_add(const char *name) { | |||
165 | return; | 169 | return; |
166 | } | 170 | } |
167 | } | 171 | } |
172 | else | ||
173 | printf("Creating %s\n", fname); | ||
168 | 174 | ||
169 | printf("%s created\n", fname); | ||
170 | FILE *fp = fopen(fname, "a+"); | 175 | FILE *fp = fopen(fname, "a+"); |
171 | if (!fp) { | 176 | if (!fp) { |
172 | fprintf(stderr, "Error: cannot open %s\n", fname); | 177 | fprintf(stderr, "Error: cannot open %s\n", fname); |