prepare-root: Default sysroot.readonly=true if composefs
authorColin Walters <walters@verbum.org>
Sun, 23 Jul 2023 18:33:51 +0000 (14:33 -0400)
committerColin Walters <walters@verbum.org>
Tue, 25 Jul 2023 13:15:11 +0000 (09:15 -0400)
Not because it's logically required or anything, but because
it's just a good idea.

src/switchroot/ostree-prepare-root.c

index dfac5481342888f8b8ebd4f57349e449c4c42fb2..c0f9d7537888532b062ace4e968ef3810ce276b2 100644 (file)
@@ -344,8 +344,18 @@ main (int argc, char *argv[])
     errx (EXIT_FAILURE, "Failed to parse config: %s", error->message);
 
   gboolean sysroot_readonly = FALSE;
-  if (!ot_keyfile_get_boolean_with_default (config, SYSROOT_KEY, READONLY_KEY, FALSE,
-                                            &sysroot_readonly, &error))
+
+  // We always parse the composefs config, because we want to detect and error
+  // out if it's enabled, but not supported at compile time.
+  g_autoptr (ComposefsConfig) composefs_config = load_composefs_config (&error);
+  if (!composefs_config)
+    errx (EXIT_FAILURE, "%s", error->message);
+
+  // If composefs is enabled, that also implies sysroot.readonly=true because it's
+  // the new default we want to use (not because it's actually required)
+  const bool sysroot_readonly_default = composefs_config->enabled == OT_TRISTATE_YES;
+  if (!ot_keyfile_get_boolean_with_default (config, SYSROOT_KEY, READONLY_KEY,
+                                            sysroot_readonly_default, &sysroot_readonly, &error))
     errx (EXIT_FAILURE, "Failed to parse sysroot.readonly value: %s", error->message);
 
   /* This is the final target where we should prepare the rootfs.  The usual
@@ -398,11 +408,6 @@ main (int argc, char *argv[])
   GVariantBuilder metadata_builder;
   g_variant_builder_init (&metadata_builder, G_VARIANT_TYPE ("a{sv}"));
 
-  // We always parse the composefs config, because we want to detect and error
-  // out if it's enabled, but not supported at compile time.
-  g_autoptr (ComposefsConfig) composefs_config = load_composefs_config (&error);
-  if (!composefs_config)
-    errx (EXIT_FAILURE, "%s", error->message);
   // Tracks if we did successfully enable it at runtime
   bool using_composefs = false;