Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve error messages #4035

Merged
merged 2 commits into from
Mar 3, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 6 additions & 4 deletions src/firejail/fs_etc.c
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
#include "firejail.h"
#include <errno.h>
#include <sys/mount.h>
#include <sys/stat.h>
#include <sys/types.h>
Expand Down Expand Up @@ -147,7 +148,7 @@ void fs_private_dir_copy(const char *private_dir, const char *private_run_dir, c
struct stat s;
if (stat(private_dir, &s) == -1) {
if (arg_debug)
printf("Cannot find %s\n", private_dir);
printf("Cannot find %s: %s\n", private_dir, strerror(errno));
return;
}

Expand Down Expand Up @@ -191,16 +192,17 @@ void fs_private_dir_mount(const char *private_dir, const char *private_run_dir)
assert(private_dir);
assert(private_run_dir);

if (arg_debug)
printf("Mount-bind %s on top of %s\n", private_run_dir, private_dir);

// nothing to do if directory does not exist
struct stat s;
if (stat(private_dir, &s) == -1) {
if (arg_debug)
printf("Cannot find %s\n", private_dir);
printf("Cannot find %s: %s\n", private_dir, strerror(errno));
return;
}

if (arg_debug)
printf("Mount-bind %s on top of %s\n", private_run_dir, private_dir);
if (mount(private_run_dir, private_dir, NULL, MS_BIND|MS_REC, NULL) < 0)
errExit("mount bind");
fs_logger2("mount", private_dir);
Expand Down
4 changes: 2 additions & 2 deletions src/firejail/sandbox.c
Original file line number Diff line number Diff line change
Expand Up @@ -975,10 +975,10 @@ int sandbox(void* sandbox_arg) {
fs_private_dir_copy("/usr/etc", RUN_USR_ETC_DIR, cfg.etc_private_keep); // openSUSE

if (umount2("/etc/group", MNT_DETACH) == -1)
fprintf(stderr, "/etc/group: unmount: %m\n");
fprintf(stderr, "/etc/group: unmount: %s\n", strerror(errno));

if (umount2("/etc/passwd", MNT_DETACH) == -1)
fprintf(stderr, "/etc/passwd: unmount: %m\n");
fprintf(stderr, "/etc/passwd: unmount: %s\n", strerror(errno));

fs_private_dir_mount("/etc", RUN_ETC_DIR);
fs_private_dir_mount("/usr/etc", RUN_USR_ETC_DIR);
Expand Down