Skip to content

Commit 95b13de

Browse files
committed
Always generate composefs blob, don't enable runtime by default
Followup to 9a0acd7 Basically our composefs enablement flag has long had a tension between trying to do two things: - Enable generating the composefs blob (at deployment time) - Enable at runtime in prepare-root And we've hit issues in "ratcheting" enabling composefs across upgrades because of this. This change builds on the previous one, and now it's really simple to talk about: - If composefs is enabled at build time, we *always* generate a composefs blob at deplyment time - Configuring the prepare-root config now mostly only affects the runtime state. There is one detail though: in order to handle the verity requirement at deploy time, we do still parse the config then. But for the basic "is composefs enabled at all at runtime" that is now fully keyed off the config, not the build time or (worse) whether the deployment happened to have a composefs blob. For users who want composefs on, they need to do so in the base image configuration. Signed-off-by: Colin Walters <walters@verbum.org>
1 parent 8049711 commit 95b13de

File tree

5 files changed

+44
-45
lines changed

5 files changed

+44
-45
lines changed

docs/composefs.md

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -21,22 +21,20 @@ At the current time, integration of composefs and ostree is experimental.
2121

2222
### Enabling composefs (unsigned)
2323

24-
When building a disk image *or* to transition an existing system, run:
24+
If ostree is compiled with composefs support, then a composefs file
25+
corresponding to the deployment tree will be generated by default.
26+
27+
The `ostree-prepare-root` binary will look for `ostree/prepare-root.conf` in `/etc` and
28+
`/usr/lib` in the initramfs. Using that configuration file you can enable composefs.
29+
This configuration will enable an "unsigned" mode, which does not require fsverity,
30+
but does make the system more resilient to accidental mutation.
2531

2632
```
27-
ostree config --repo=/ostree/repo set ex-integrity.composefs true
33+
[composefs]
34+
enabled = yes
2835
```
2936

30-
This will ensure that any future deployments (e.g. created by `ostree admin upgrade`)
31-
have a `.ostree.cfs` file in the deployment directory which is a mountable
32-
composefs metadata file, with a "backing store" directory that is
33-
shared with the current `/ostree/repo/objects`.
34-
35-
### composefs configuration
36-
37-
The `ostree-prepare-root` binary will look for `ostree/prepare-root.conf` in `/etc` and
38-
`/usr/lib` in the initramfs. Using that configuration file you can enable composefs,
39-
and specify an Ed25519 public key to validate the booted commit.
37+
You can also specify an Ed25519 public key to validate the booted commit.
4038

4139
See the manpage for `ostree-prepare-root` for details of how to configure it.
4240

man/ostree-prepare-root.xml

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,12 @@ License along with this library. If not, see <https://www.gnu.org/licenses/>.
151151
the integrity of its backing OSTree object is validated by the digest stored in the image.
152152
Additionally, if set to <literal>signed</literal>, boot will fail if the image cannot be
153153
validated by a public key.
154-
Setting this to <literal>maybe</literal> is currently equivalent to <literal>no</literal>.
154+
Setting this to <literal>maybe</literal> will cause composefs to be used at runtime only
155+
if the deployment has a composefs generated, which causes unpredicable and confusing semantics
156+
and is not recommended. In practice with the <emphasis>current</emphasis> version of ostree,
157+
in the case where composefs is enabled at build time for both the version that made the
158+
deployment (often an older OS version), this will be equivalent to <literal>yes</literal>.
159+
But in general one either wants composefs or not, so choose an explicit value for that.
155160
</para></listitem>
156161
</varlistentry>
157162
<varlistentry>

src/libostree/ostree-sysroot-deploy.c

Lines changed: 22 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -669,33 +669,28 @@ checkout_deployment_tree (OstreeSysroot *sysroot, OstreeRepo *repo, OstreeDeploy
669669
guint64 composefs_start_time = 0;
670670
guint64 composefs_end_time = 0;
671671
#ifdef HAVE_COMPOSEFS
672-
if (composefs_enabled != OT_TRISTATE_NO)
673-
{
674-
composefs_start_time = g_get_monotonic_time ();
675-
// TODO: Clean up our mess around composefs/fsverity...we have duplication
676-
// between the repo config and the sysroot config, *and* we need to better
677-
// handle skew between repo config and repo state (e.g. "post-copy" should
678-
// support transitioning verity on and off in general).
679-
// For now we configure things such that the fsverity digest is only added
680-
// if present on disk in the unsigned case, and in the signed case unconditionally
681-
// require it.
682-
g_auto (GVariantBuilder) cfs_checkout_opts_builder
683-
= G_VARIANT_BUILDER_INIT (G_VARIANT_TYPE_VARDICT);
684-
guint32 composefs_requested = 1;
685-
if (composefs_config->require_verity)
686-
composefs_requested = 2;
687-
g_variant_builder_add (&cfs_checkout_opts_builder, "{sv}", "verity",
688-
g_variant_new_uint32 (composefs_requested));
689-
g_debug ("composefs requested: %u", composefs_requested);
690-
g_autoptr (GVariant) cfs_checkout_opts
691-
= g_variant_ref_sink (g_variant_builder_end (&cfs_checkout_opts_builder));
692-
if (!ostree_repo_checkout_composefs (repo, cfs_checkout_opts, ret_deployment_dfd,
693-
OSTREE_COMPOSEFS_NAME, csum, cancellable, error))
694-
return FALSE;
695-
composefs_end_time = g_get_monotonic_time ();
696-
}
697-
else
698-
g_debug ("not using composefs");
672+
composefs_start_time = g_get_monotonic_time ();
673+
// TODO: Clean up our mess around composefs/fsverity...we have duplication
674+
// between the repo config and the sysroot config, *and* we need to better
675+
// handle skew between repo config and repo state (e.g. "post-copy" should
676+
// support transitioning verity on and off in general).
677+
// For now we configure things such that the fsverity digest is only added
678+
// if present on disk in the unsigned case, and in the signed case unconditionally
679+
// require it.
680+
g_auto (GVariantBuilder) cfs_checkout_opts_builder
681+
= G_VARIANT_BUILDER_INIT (G_VARIANT_TYPE_VARDICT);
682+
guint32 composefs_requested = 1;
683+
if (composefs_config->require_verity)
684+
composefs_requested = 2;
685+
g_variant_builder_add (&cfs_checkout_opts_builder, "{sv}", "verity",
686+
g_variant_new_uint32 (composefs_requested));
687+
g_debug ("composefs requested: %u", composefs_requested);
688+
g_autoptr (GVariant) cfs_checkout_opts
689+
= g_variant_ref_sink (g_variant_builder_end (&cfs_checkout_opts_builder));
690+
if (!ostree_repo_checkout_composefs (repo, cfs_checkout_opts, ret_deployment_dfd,
691+
OSTREE_COMPOSEFS_NAME, csum, cancellable, error))
692+
return FALSE;
693+
composefs_end_time = g_get_monotonic_time ();
699694
#else
700695
if (composefs_enabled == OT_TRISTATE_YES)
701696
return glnx_throw (error, "composefs: enabled at runtime, but support is not compiled in");

src/libotcore/otcore-prepare-root.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,7 @@ otcore_load_composefs_config (const char *cmdline, GKeyFile *config, gboolean lo
189189
}
190190
else if (!ot_keyfile_get_tristate_with_default (config, OTCORE_PREPARE_ROOT_COMPOSEFS_KEY,
191191
OTCORE_PREPARE_ROOT_ENABLED_KEY,
192-
OT_TRISTATE_MAYBE, &ret->enabled, error))
192+
OT_TRISTATE_NO, &ret->enabled, error))
193193
return NULL;
194194

195195
// Look for a key - we default to the initramfs binding path.

tests/test-admin-deploy-composefs.sh

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,10 +38,10 @@ cd -
3838
${CMD_PREFIX} ostree --repo=${test_tmpdir}/testos-repo commit --add-metadata-string version=1.composefs -b testos/buildmain/x86_64-runtime osdata
3939
${CMD_PREFIX} ostree --repo=sysroot/ostree/repo pull-local --remote=testos testos-repo testos/buildmain/x86_64-runtime
4040

41+
# We generate the blob now, even if it's explicitly runtime disabled
4142
${CMD_PREFIX} ostree admin deploy --os=testos --karg=root=LABEL=foo --karg=testkarg=1 testos:testos/buildmain/x86_64-runtime
42-
if test -f sysroot/ostree/deploy/testos/deploy/*.0/.ostree.cfs; then
43-
fatal "found composefs unexpectedly"
44-
fi
43+
cfs_count=$(ls sysroot/ostree/deploy/testos/deploy/*.0/.ostree.cfs | wc -l)
44+
assert_streq "${cfs_count}" "1"
4545

4646
# check explicit enablement
4747
cd osdata
@@ -55,7 +55,8 @@ ${CMD_PREFIX} ostree --repo=${test_tmpdir}/testos-repo commit --add-metadata-str
5555
${CMD_PREFIX} ostree --repo=sysroot/ostree/repo pull-local --remote=testos testos-repo testos/buildmain/x86_64-runtime
5656

5757
${CMD_PREFIX} ostree admin deploy --os=testos --karg=root=LABEL=foo --karg=testkarg=1 testos:testos/buildmain/x86_64-runtime
58-
ls sysroot/ostree/deploy/testos/deploy/*.0/.ostree.cfs
58+
cfs_count=$(ls sysroot/ostree/deploy/testos/deploy/*.0/.ostree.cfs | wc -l)
59+
assert_streq "${cfs_count}" "2"
5960

6061
tap_ok composefs
6162

0 commit comments

Comments
 (0)