From b2adbe2a74e10859d5f327aa3b7364becc0c2f85 Mon Sep 17 00:00:00 2001 From: Simon McVittie Date: Mon, 20 Jan 2020 18:50:07 +0000 Subject: [PATCH] exports: Only choose bwrap --bind/--ro-bind for host FS once We can choose this once and use it repeatedly, which will be simpler when we add more directories that work this way. Signed-off-by: Simon McVittie --- common/flatpak-exports.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/common/flatpak-exports.c b/common/flatpak-exports.c index 87cc6ad6..31dd7835 100644 --- a/common/flatpak-exports.c +++ b/common/flatpak-exports.c @@ -279,14 +279,17 @@ flatpak_exports_append_bwrap_args (FlatpakExports *exports, if (exports->host_fs != 0) { + const char *host_bind_mode = "--bind"; + + if (exports->host_fs == FLATPAK_FILESYSTEM_MODE_READ_ONLY) + host_bind_mode = "--ro-bind"; + if (g_file_test ("/usr", G_FILE_TEST_IS_DIR)) flatpak_bwrap_add_args (bwrap, - (exports->host_fs == FLATPAK_FILESYSTEM_MODE_READ_ONLY) ? "--ro-bind" : "--bind", - "/usr", "/run/host/usr", NULL); + host_bind_mode, "/usr", "/run/host/usr", NULL); if (g_file_test ("/etc", G_FILE_TEST_IS_DIR)) flatpak_bwrap_add_args (bwrap, - (exports->host_fs == FLATPAK_FILESYSTEM_MODE_READ_ONLY) ? "--ro-bind" : "--bind", - "/etc", "/run/host/etc", NULL); + host_bind_mode, "/etc", "/run/host/etc", NULL); } }