diff options
author | 2021-03-03 11:42:48 +0100 | |
---|---|---|
committer | 2021-03-03 11:42:48 +0100 | |
commit | 0672a2e12d1385061a35e810649ec2af93c9faa9 (patch) | |
tree | b76a6dbe5a5eefea5ab4c3e094bb0075fdbb0179 | |
parent | Merge pull request #4016 from pirate486743186/patch-5 (diff) | |
parent | Use strerror(errno) instead of %m (diff) | |
download | firejail-0672a2e12d1385061a35e810649ec2af93c9faa9.tar.gz firejail-0672a2e12d1385061a35e810649ec2af93c9faa9.tar.zst firejail-0672a2e12d1385061a35e810649ec2af93c9faa9.zip |
Merge pull request #4035 from Tomin1/few_fixes
Improve error messages
-rw-r--r-- | src/firejail/fs_etc.c | 10 | ||||
-rw-r--r-- | src/firejail/sandbox.c | 4 |
2 files changed, 8 insertions, 6 deletions
diff --git a/src/firejail/fs_etc.c b/src/firejail/fs_etc.c index b9ed81db3..d093d5637 100644 --- a/src/firejail/fs_etc.c +++ b/src/firejail/fs_etc.c | |||
@@ -18,6 +18,7 @@ | |||
18 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. | 18 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. |
19 | */ | 19 | */ |
20 | #include "firejail.h" | 20 | #include "firejail.h" |
21 | #include <errno.h> | ||
21 | #include <sys/mount.h> | 22 | #include <sys/mount.h> |
22 | #include <sys/stat.h> | 23 | #include <sys/stat.h> |
23 | #include <sys/types.h> | 24 | #include <sys/types.h> |
@@ -147,7 +148,7 @@ void fs_private_dir_copy(const char *private_dir, const char *private_run_dir, c | |||
147 | struct stat s; | 148 | struct stat s; |
148 | if (stat(private_dir, &s) == -1) { | 149 | if (stat(private_dir, &s) == -1) { |
149 | if (arg_debug) | 150 | if (arg_debug) |
150 | printf("Cannot find %s\n", private_dir); | 151 | printf("Cannot find %s: %s\n", private_dir, strerror(errno)); |
151 | return; | 152 | return; |
152 | } | 153 | } |
153 | 154 | ||
@@ -191,16 +192,17 @@ void fs_private_dir_mount(const char *private_dir, const char *private_run_dir) | |||
191 | assert(private_dir); | 192 | assert(private_dir); |
192 | assert(private_run_dir); | 193 | assert(private_run_dir); |
193 | 194 | ||
195 | if (arg_debug) | ||
196 | printf("Mount-bind %s on top of %s\n", private_run_dir, private_dir); | ||
197 | |||
194 | // nothing to do if directory does not exist | 198 | // nothing to do if directory does not exist |
195 | struct stat s; | 199 | struct stat s; |
196 | if (stat(private_dir, &s) == -1) { | 200 | if (stat(private_dir, &s) == -1) { |
197 | if (arg_debug) | 201 | if (arg_debug) |
198 | printf("Cannot find %s\n", private_dir); | 202 | printf("Cannot find %s: %s\n", private_dir, strerror(errno)); |
199 | return; | 203 | return; |
200 | } | 204 | } |
201 | 205 | ||
202 | if (arg_debug) | ||
203 | printf("Mount-bind %s on top of %s\n", private_run_dir, private_dir); | ||
204 | if (mount(private_run_dir, private_dir, NULL, MS_BIND|MS_REC, NULL) < 0) | 206 | if (mount(private_run_dir, private_dir, NULL, MS_BIND|MS_REC, NULL) < 0) |
205 | errExit("mount bind"); | 207 | errExit("mount bind"); |
206 | fs_logger2("mount", private_dir); | 208 | fs_logger2("mount", private_dir); |
diff --git a/src/firejail/sandbox.c b/src/firejail/sandbox.c index a04551ed4..a97ca0abb 100644 --- a/src/firejail/sandbox.c +++ b/src/firejail/sandbox.c | |||
@@ -975,10 +975,10 @@ int sandbox(void* sandbox_arg) { | |||
975 | fs_private_dir_copy("/usr/etc", RUN_USR_ETC_DIR, cfg.etc_private_keep); // openSUSE | 975 | fs_private_dir_copy("/usr/etc", RUN_USR_ETC_DIR, cfg.etc_private_keep); // openSUSE |
976 | 976 | ||
977 | if (umount2("/etc/group", MNT_DETACH) == -1) | 977 | if (umount2("/etc/group", MNT_DETACH) == -1) |
978 | fprintf(stderr, "/etc/group: unmount: %m\n"); | 978 | fprintf(stderr, "/etc/group: unmount: %s\n", strerror(errno)); |
979 | 979 | ||
980 | if (umount2("/etc/passwd", MNT_DETACH) == -1) | 980 | if (umount2("/etc/passwd", MNT_DETACH) == -1) |
981 | fprintf(stderr, "/etc/passwd: unmount: %m\n"); | 981 | fprintf(stderr, "/etc/passwd: unmount: %s\n", strerror(errno)); |
982 | 982 | ||
983 | fs_private_dir_mount("/etc", RUN_ETC_DIR); | 983 | fs_private_dir_mount("/etc", RUN_ETC_DIR); |
984 | fs_private_dir_mount("/usr/etc", RUN_USR_ETC_DIR); | 984 | fs_private_dir_mount("/usr/etc", RUN_USR_ETC_DIR); |