]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
nspawn: Don't mount read-only if we have a custom mount on root.
authorDaan De Meyer <daan.de_meyer@otnsystems.com>
Mon, 23 Dec 2019 10:50:02 +0000 (11:50 +0100)
committerDaan De Meyer <daan.de_meyer@otnsystems.com>
Fri, 3 Jan 2020 13:06:38 +0000 (14:06 +0100)
src/nspawn/nspawn-mount.c
src/nspawn/nspawn-mount.h
src/nspawn/nspawn.c

index f423f625905ef2fa7bf082d9ffee3ce84bd80e37..6afc31d824b345a3deecd9456a6caf677c9be7dc 100644 (file)
@@ -989,6 +989,19 @@ int mount_custom(
         return 0;
 }
 
+bool has_custom_root_mount(const CustomMount *mounts, size_t n) {
+        size_t i;
+
+        for (i = 0; i < n; i++) {
+                const CustomMount *m = mounts + i;
+
+                if (path_equal(m->destination, "/"))
+                        return true;
+        }
+
+        return false;
+}
+
 static int setup_volatile_state(const char *directory, uid_t uid_shift, const char *selinux_apifs_context) {
 
         _cleanup_free_ char *buf = NULL;
index aabc9e29bef5161e66ca02b03dbae897d3726602..680ff350e5d33a12ccc8480247d8665be79654c7 100644 (file)
@@ -55,6 +55,7 @@ int mount_all(const char *dest, MountSettingsMask mount_settings, uid_t uid_shif
 int mount_sysfs(const char *dest, MountSettingsMask mount_settings);
 
 int mount_custom(const char *dest, CustomMount *mounts, size_t n, uid_t uid_shift, const char *selinux_apifs_context, MountSettingsMask mount_settings);
+bool has_custom_root_mount(const CustomMount *mounts, size_t n);
 
 int setup_volatile_mode(const char *directory, VolatileMode mode, uid_t uid_shift, const char *selinux_apifs_context);
 
index 32294ed00293e31e1daf33c203d1476369c52532..f0f9f6ecebabfaa376adf98c24f88b7c7d7763a2 100644 (file)
@@ -3438,7 +3438,8 @@ static int outer_child(
         if (r < 0)
                 return r;
 
-        if (arg_read_only && arg_volatile_mode == VOLATILE_NO) {
+        if (arg_read_only && arg_volatile_mode == VOLATILE_NO &&
+                !has_custom_root_mount(arg_custom_mounts, arg_n_custom_mounts)) {
                 r = bind_remount_recursive(directory, MS_RDONLY, MS_RDONLY, NULL);
                 if (r < 0)
                         return log_error_errno(r, "Failed to make tree read-only: %m");