Skip to content

Commit

Permalink
generator: Restore graceful exit behaviour if ostree karg missing
Browse files Browse the repository at this point in the history
In CoreOS live environments, we do have `/run/ostree` but no `ostree=`
karg; we hackily fool `ostree-prepare-root.service` by bind-mounting
over `/proc/cmdline` so it does the right thing. Presumably, we should
clean this up eventually, but even so we don't want to require PXE users
to add an `ostree=` arg, so we need to tolerate this.

So this assertion would fail there. Restore the behaviour prior to
b9ce0e8 and re-add a more contemporary comment.

Fixes b9ce0e8 ("generator: Exit if there's no `/run/ostree`").
  • Loading branch information
jlebon committed Feb 6, 2024
1 parent 31b804f commit 15ec339
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions src/libostree/ostree-impl-system-generator.c
Original file line number Diff line number Diff line change
Expand Up @@ -260,9 +260,14 @@ _ostree_impl_system_generator (const char *normal_dir, const char *early_dir, co
g_autofree char *cmdline = read_proc_cmdline ();
if (!cmdline)
return glnx_throw (error, "Failed to read /proc/cmdline");

g_autofree char *ostree_cmdline = otcore_find_proc_cmdline_key (cmdline, "ostree");
// SAFETY: If we have /run/ostree, then we must have the ostree= karg
g_assert (ostree_cmdline);

/* This could happen in CoreOS live environments, where we hackily mock
* the `ostree=` karg for `ostree-prepare-root.service` specifically, but
* otherwise that karg doesn't exist on the real command-line. */
if (!ostree_cmdline)
return TRUE;

if (!require_internal_units (normal_dir, early_dir, late_dir, error))
return FALSE;
Expand Down

0 comments on commit 15ec339

Please sign in to comment.