Expose /var/usrlocal if "--filesystem=host" is specified.

As /usr/local points to ../var/usrlocal on Silverblue,
/run/host/usr/local was previously a broken link inside the
sandbox. This patch checks if /var/usrlocal exists and bind-mounts it
to /run/host/var/usrlocal.

See bug #4010.
This commit is contained in:
Casey Jao
2020-12-07 08:18:56 -05:00
committed by Alexander Larsson
parent 9311ae9b4d
commit 3aaea7d206

View File

@@ -385,6 +385,13 @@ flatpak_exports_append_bwrap_args (FlatpakExports *exports,
flatpak_bwrap_add_args (bwrap,
os_bind_mode, "/usr", "/run/host/usr", NULL);
/* /usr/local points to ../var/usrlocal on ostree systems,
so bind-mount that too. */
if (flatpak_exports_stat_in_host (exports, "/var/usrlocal", &buf, 0, NULL) &&
S_ISDIR (buf.st_mode))
flatpak_bwrap_add_args (bwrap,
os_bind_mode, "/var/usrlocal", "/run/host/var/usrlocal", NULL);
for (i = 0; flatpak_abs_usrmerged_dirs[i] != NULL; i++)
{
const char *subdir = flatpak_abs_usrmerged_dirs[i];