From 1738719c3ef519821f020dfe0e0bbbcd2baf9e8c Mon Sep 17 00:00:00 2001 From: smitsohu Date: Tue, 27 Nov 2018 17:41:35 +0100 Subject: firecfg: small tweaks, fixes, man page update --- src/firecfg/main.c | 17 ++++++++++++++--- src/firecfg/sound.c | 7 +++++-- src/man/firecfg.txt | 5 +++++ 3 files changed, 24 insertions(+), 5 deletions(-) (limited to 'src') 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) { static void list(void) { DIR *dir = opendir(arg_bindir); if (!dir) { + perror("opendir"); fprintf(stderr, "Error: cannot open %s directory\n", arg_bindir); exit(1); } @@ -103,6 +104,7 @@ static void clean(void) { DIR *dir = opendir(arg_bindir); if (!dir) { + perror("opendir"); fprintf(stderr, "Error: cannot open %s directory\n", arg_bindir); exit(1); } @@ -182,6 +184,7 @@ static void set_links_firecfg(void) { // parse /usr/lib/firejail/firecfg.cfg file FILE *fp = fopen(cfgfile, "r"); if (!fp) { + perror("fopen"); fprintf(stderr, "Error: cannot open %s\n", cfgfile); exit(1); } @@ -247,7 +250,8 @@ static void set_links_homedir(const char *homedir) { DIR *dir = opendir(dirname); if (!dir) { - fprintf(stderr, "Error: cannot open ~/.config/firejail directory\n"); + perror("opendir"); + fprintf(stderr, "Error: cannot open %s directory\n", dirname); free(dirname); return; } @@ -337,7 +341,12 @@ int main(int argc, char **argv) { // exit if the directory does not exist, or if we don't have access to it if (access(arg_bindir, R_OK | W_OK | X_OK)) { - fprintf(stderr, "Error: directory %s not found\n", arg_bindir); + if (errno == EACCES) + fprintf(stderr, "Error: cannot access directory %s: full permissions required\n", arg_bindir); + else { + perror("access"); + fprintf(stderr, "Error: cannot access directory %s\n", arg_bindir); + } exit(1); } } @@ -407,6 +416,7 @@ int main(int argc, char **argv) { } else if (bindir_set == 0) { // create /usr/local directory if it doesn't exist (Solus distro) + mode_t orig_umask = umask(022); // temporarily set the umask struct stat s; if (stat("/usr/local", &s) != 0) { printf("Creating /usr/local directory\n"); @@ -417,13 +427,14 @@ int main(int argc, char **argv) { } } if (stat(arg_bindir, &s) != 0) { - printf("Creating /usr/local directory\n"); + printf("Creating %s directory\n", arg_bindir); int rv = mkdir(arg_bindir, 0755); if (rv != 0) { fprintf(stderr, "Error: cannot create %s directory\n", arg_bindir); return 1; } } + umask(orig_umask); } // 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) { char *fname; if (asprintf(&fname, "%s/.config/pulse/client.conf", home) == -1) errExit("asprintf"); + printf("Writing file %s\n", fname); FILE *fpout = fopen(fname, "w"); - free(fname); - if (!fpout) + if (!fpout) { + perror("fopen"); goto errexit; + } + free(fname); // copy default config 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 @@ -54,6 +54,11 @@ Example: .br $ sudo firecfg --add-users dustin lucas mike eleven +.TP +\fB\-\-bindir=directory +Create and search symbolic links in directory instead of the default location /user/local/bin. +Directory should precede /usr/bin and /bin in the PATH environment variable. + .TP \fB\-\-clean Remove all firejail symbolic links. -- cgit v1.2.3-54-g00ecf