diff options
-rw-r--r-- | src/firecfg/main.c | 17 | ||||
-rw-r--r-- | src/firecfg/sound.c | 7 | ||||
-rw-r--r-- | src/man/firecfg.txt | 5 |
3 files changed, 24 insertions, 5 deletions
diff --git a/src/firecfg/main.c b/src/firecfg/main.c index 84f6a5f77..96ae37bd0 100644 --- a/src/firecfg/main.c +++ b/src/firecfg/main.c | |||
@@ -66,6 +66,7 @@ static void usage(void) { | |||
66 | static void list(void) { | 66 | static void list(void) { |
67 | DIR *dir = opendir(arg_bindir); | 67 | DIR *dir = opendir(arg_bindir); |
68 | if (!dir) { | 68 | if (!dir) { |
69 | perror("opendir"); | ||
69 | fprintf(stderr, "Error: cannot open %s directory\n", arg_bindir); | 70 | fprintf(stderr, "Error: cannot open %s directory\n", arg_bindir); |
70 | exit(1); | 71 | exit(1); |
71 | } | 72 | } |
@@ -103,6 +104,7 @@ static void clean(void) { | |||
103 | 104 | ||
104 | DIR *dir = opendir(arg_bindir); | 105 | DIR *dir = opendir(arg_bindir); |
105 | if (!dir) { | 106 | if (!dir) { |
107 | perror("opendir"); | ||
106 | fprintf(stderr, "Error: cannot open %s directory\n", arg_bindir); | 108 | fprintf(stderr, "Error: cannot open %s directory\n", arg_bindir); |
107 | exit(1); | 109 | exit(1); |
108 | } | 110 | } |
@@ -182,6 +184,7 @@ static void set_links_firecfg(void) { | |||
182 | // parse /usr/lib/firejail/firecfg.cfg file | 184 | // parse /usr/lib/firejail/firecfg.cfg file |
183 | FILE *fp = fopen(cfgfile, "r"); | 185 | FILE *fp = fopen(cfgfile, "r"); |
184 | if (!fp) { | 186 | if (!fp) { |
187 | perror("fopen"); | ||
185 | fprintf(stderr, "Error: cannot open %s\n", cfgfile); | 188 | fprintf(stderr, "Error: cannot open %s\n", cfgfile); |
186 | exit(1); | 189 | exit(1); |
187 | } | 190 | } |
@@ -247,7 +250,8 @@ static void set_links_homedir(const char *homedir) { | |||
247 | 250 | ||
248 | DIR *dir = opendir(dirname); | 251 | DIR *dir = opendir(dirname); |
249 | if (!dir) { | 252 | if (!dir) { |
250 | fprintf(stderr, "Error: cannot open ~/.config/firejail directory\n"); | 253 | perror("opendir"); |
254 | fprintf(stderr, "Error: cannot open %s directory\n", dirname); | ||
251 | free(dirname); | 255 | free(dirname); |
252 | return; | 256 | return; |
253 | } | 257 | } |
@@ -337,7 +341,12 @@ int main(int argc, char **argv) { | |||
337 | 341 | ||
338 | // exit if the directory does not exist, or if we don't have access to it | 342 | // exit if the directory does not exist, or if we don't have access to it |
339 | if (access(arg_bindir, R_OK | W_OK | X_OK)) { | 343 | if (access(arg_bindir, R_OK | W_OK | X_OK)) { |
340 | fprintf(stderr, "Error: directory %s not found\n", arg_bindir); | 344 | if (errno == EACCES) |
345 | fprintf(stderr, "Error: cannot access directory %s: full permissions required\n", arg_bindir); | ||
346 | else { | ||
347 | perror("access"); | ||
348 | fprintf(stderr, "Error: cannot access directory %s\n", arg_bindir); | ||
349 | } | ||
341 | exit(1); | 350 | exit(1); |
342 | } | 351 | } |
343 | } | 352 | } |
@@ -407,6 +416,7 @@ int main(int argc, char **argv) { | |||
407 | } | 416 | } |
408 | else if (bindir_set == 0) { | 417 | else if (bindir_set == 0) { |
409 | // create /usr/local directory if it doesn't exist (Solus distro) | 418 | // create /usr/local directory if it doesn't exist (Solus distro) |
419 | mode_t orig_umask = umask(022); // temporarily set the umask | ||
410 | struct stat s; | 420 | struct stat s; |
411 | if (stat("/usr/local", &s) != 0) { | 421 | if (stat("/usr/local", &s) != 0) { |
412 | printf("Creating /usr/local directory\n"); | 422 | printf("Creating /usr/local directory\n"); |
@@ -417,13 +427,14 @@ int main(int argc, char **argv) { | |||
417 | } | 427 | } |
418 | } | 428 | } |
419 | if (stat(arg_bindir, &s) != 0) { | 429 | if (stat(arg_bindir, &s) != 0) { |
420 | printf("Creating /usr/local directory\n"); | 430 | printf("Creating %s directory\n", arg_bindir); |
421 | int rv = mkdir(arg_bindir, 0755); | 431 | int rv = mkdir(arg_bindir, 0755); |
422 | if (rv != 0) { | 432 | if (rv != 0) { |
423 | fprintf(stderr, "Error: cannot create %s directory\n", arg_bindir); | 433 | fprintf(stderr, "Error: cannot create %s directory\n", arg_bindir); |
424 | return 1; | 434 | return 1; |
425 | } | 435 | } |
426 | } | 436 | } |
437 | umask(orig_umask); | ||
427 | } | 438 | } |
428 | 439 | ||
429 | // clear all symlinks | 440 | // clear all symlinks |
diff --git a/src/firecfg/sound.c b/src/firecfg/sound.c index a4151e405..38b43af62 100644 --- a/src/firecfg/sound.c +++ b/src/firecfg/sound.c | |||
@@ -41,10 +41,13 @@ void sound(void) { | |||
41 | char *fname; | 41 | char *fname; |
42 | if (asprintf(&fname, "%s/.config/pulse/client.conf", home) == -1) | 42 | if (asprintf(&fname, "%s/.config/pulse/client.conf", home) == -1) |
43 | errExit("asprintf"); | 43 | errExit("asprintf"); |
44 | printf("Writing file %s\n", fname); | ||
44 | FILE *fpout = fopen(fname, "w"); | 45 | FILE *fpout = fopen(fname, "w"); |
45 | free(fname); | 46 | if (!fpout) { |
46 | if (!fpout) | 47 | perror("fopen"); |
47 | goto errexit; | 48 | goto errexit; |
49 | } | ||
50 | free(fname); | ||
48 | 51 | ||
49 | // copy default config | 52 | // copy default config |
50 | char buf[MAX_BUF]; | 53 | char buf[MAX_BUF]; |
diff --git a/src/man/firecfg.txt b/src/man/firecfg.txt index 80cb201d9..b418faa15 100644 --- a/src/man/firecfg.txt +++ b/src/man/firecfg.txt | |||
@@ -55,6 +55,11 @@ Example: | |||
55 | $ sudo firecfg --add-users dustin lucas mike eleven | 55 | $ sudo firecfg --add-users dustin lucas mike eleven |
56 | 56 | ||
57 | .TP | 57 | .TP |
58 | \fB\-\-bindir=directory | ||
59 | Create and search symbolic links in directory instead of the default location /user/local/bin. | ||
60 | Directory should precede /usr/bin and /bin in the PATH environment variable. | ||
61 | |||
62 | .TP | ||
58 | \fB\-\-clean | 63 | \fB\-\-clean |
59 | Remove all firejail symbolic links. | 64 | Remove all firejail symbolic links. |
60 | 65 | ||