Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
Already on GitHub? Sign in to your account
cmd: add helpers for mounting / unmounting #2827
d60e9a5
012d89c
c9b0079
2ef2dd3
8bb848e
f21c6b3
6573f69
9e24bee
5bee328
cmd/libsnap: constrain mount debug to -debug builds
In the non-debug build of snap-confine (the one that is setuid-root) we will only print mount/umount debug data when we're about to die and privileges are dropped. In the -debug build we generate such messages (with all the added complexity) depending on the runtime switch via the environment variable (SNAP_CONFINE_DEBUG=yes) The -debug build is not currently installed but we can eventually install it (without any security elevation mechanism) and come up with a way to use it (e.g. via a bind mount). Signed-off-by: Zygmunt Krynicki <zygmunt.krynicki@canonical.com>
- Loading branch information...
| @@ -261,7 +261,11 @@ void sc_do_mount(const char *source, const char *target, | ||
| } | ||
| if (sc_is_debug_enabled()) { | ||
zyga
Contributor
|
||
| +#ifdef SNAP_CONFINE_DEBUG_BUILD | ||
| ensure_mount_cmd(); | ||
| +#else | ||
| + mount_cmd = "(disabled) use debug build to see details"; | ||
| +#endif | ||
| debug("performing operation: %s", mount_cmd); | ||
| } | ||
|
|
||
| if (sc_faulty("mount", NULL) | ||
| @@ -295,7 +299,11 @@ void sc_do_umount(const char *target, int flags) | ||
| } | ||
| if (sc_is_debug_enabled()) { | ||
| +#ifdef SNAP_CONFINE_DEBUG_BUILD | ||
| ensure_umount_cmd(); | ||
| +#else | ||
| + umount_cmd = "(disabled) use debug build to see details"; | ||
| +#endif | ||
| debug("performing operation: %s", umount_cmd); | ||
| } | ||
| if (sc_faulty("umount", NULL) || umount2(target, flags) < 0) { | ||
Note that sc_is_debug_enabled() is still only looking at SNAP_CONFINE_DEBUG, so an attacker can set that and have the whole string handling attack surface. I thought there were plans to make this compile time?