// The name of the composefs metadata root
#define OSTREE_COMPOSEFS_NAME ".ostree.cfs"
+
+// The file written in the initramfs which contains an a{sv} of metadata
+// from ostree-prepare-root.
+#define OTCORE_RUN_BOOTED "/run/ostree-booted"
+// This key will be present if composefs was successfully used.
+#define OTCORE_RUN_BOOTED_KEY_COMPOSEFS "composefs"
+// This key if present contains the public key successfully used
+// to verify the signature.
+#define OTCORE_RUN_BOOTED_KEY_COMPOSEFS_SIGNATURE "composefs.signed"
if (chdir (deploy_path) < 0)
err (EXIT_FAILURE, "failed to chdir to deploy_path");
+ GVariantBuilder metadata_builder;
+ g_variant_builder_init (&metadata_builder, G_VARIANT_TYPE ("a{sv}"));
bool using_composefs = false;
/* We construct the new sysroot in /sysroot.tmp, which is either the composfs
errx (EXIT_FAILURE, "No valid signatures found for public key");
g_print ("Validated commit signature using '%s'\n", composefs_pubkey);
+ g_variant_builder_add (&metadata_builder, "{sv}",
+ OTCORE_RUN_BOOTED_KEY_COMPOSEFS_SIGNATURE,
+ g_variant_new_string (composefs_pubkey));
g_autoptr (GVariant) metadata = g_variant_get_child_value (commit, 0);
g_autoptr (GVariant) cfs_digest_v = g_variant_lookup_value (
(void)close (fd);
using_composefs = 1;
+ g_variant_builder_add (&metadata_builder, "{sv}", OTCORE_RUN_BOOTED_KEY_COMPOSEFS,
+ g_variant_new_boolean (true));
}
else
{
}
/* This can be used by other things to signal ostree is in use */
- touch_run_ostree ();
+ {
+ g_autoptr (GVariant) metadata = g_variant_ref_sink (g_variant_builder_end (&metadata_builder));
+ const guint8 *buf = g_variant_get_data (metadata) ?: (guint8 *)"";
+ if (!glnx_file_replace_contents_at (AT_FDCWD, OTCORE_RUN_BOOTED, buf,
+ g_variant_get_size (metadata), 0, NULL, &error))
+ errx (EXIT_FAILURE, "Writing %s: %s", OTCORE_RUN_BOOTED, error->message);
+ }
if (chdir (TMP_SYSROOT) < 0)
err (EXIT_FAILURE, "failed to chdir to " TMP_SYSROOT);
use anyhow::Result;
+use ostree_ext::glib;
use xshell::cmd;
pub(crate) fn itest_composefs() -> Result<()> {
let fstype = cmd!(sh, "findmnt -n -o FSTYPE /").read()?;
assert_eq!(fstype.as_str(), "overlay");
+ let metadata = std::fs::read("/run/ostree-booted")?;
+ let metadata = glib::Variant::from_bytes::<glib::VariantDict>(&glib::Bytes::from(&metadata));
+ let metadata = glib::VariantDict::new(Some(&metadata));
+
+ assert_eq!(metadata.lookup::<bool>("composefs").unwrap(), Some(true));
+
Ok(())
}