diff options
author | Simon McVittie <smcv@collabora.com> | 2022-12-12 14:29:47 +0000 |
---|---|---|
committer | Simon McVittie <smcv@debian.org> | 2023-01-12 15:13:34 +0000 |
commit | e3507918c0e496b0d111653e0e15e74108dbce16 (patch) | |
tree | 4a3d5fbb9986c24feaf8a765e6b963a826428653 | |
parent | a747e2c0c49d53b4f978da9f7b296b7c99d2d8db (diff) | |
download | flatpak-e3507918c0e496b0d111653e0e15e74108dbce16.tar.gz |
exports: Don't export parent or ancestor of reserved directories
Previously, --filesystem=/run would prevent apps from starting by
breaking our ability to set up /run/flatpak and /run/host. Now it is
ignored, with a diagnostic message, resolving #5205 and #5207.
Similarly, --filesystem=/symlink-to-root (or --filesystem=host) would
have prevented apps from starting if a symlink like
`/symlink-to-root -> /` or `/symlink-to-root -> .` exists, and refusing
to export the target of that symlink avoids that failure mode,
resolving #1357.
Resolves: https://github.com/flatpak/flatpak/issues/1357
Resolves: https://github.com/flatpak/flatpak/issues/5205
Resolves: https://github.com/flatpak/flatpak/issues/5207
Signed-off-by: Simon McVittie <smcv@collabora.com>
-rw-r--r-- | common/flatpak-exports.c | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/common/flatpak-exports.c b/common/flatpak-exports.c index c7041313..ce7b28ec 100644 --- a/common/flatpak-exports.c +++ b/common/flatpak-exports.c @@ -972,6 +972,19 @@ _exports_path_expose (FlatpakExports *exports, dont_export_in[i]); return FALSE; } + + /* Also don't expose directories that are a parent of a directory + * that is "owned" by the sandboxing framework. For example, because + * Flatpak controls /run/host and /run/flatpak, we cannot allow + * --filesystem=/run, which would prevent us from creating the + * contents of /run/host and /run/flatpak. */ + if (flatpak_has_path_prefix (dont_export_in[i], path)) + { + g_set_error (error, G_IO_ERROR, G_IO_ERROR_NOT_MOUNTABLE_FILE, + _("Path \"%s\" is reserved by Flatpak"), + dont_export_in[i]); + return FALSE; + } } for (i = 0; flatpak_abs_usrmerged_dirs[i] != NULL; i++) |