From: Colin Walters Date: Wed, 28 Jun 2023 15:45:15 +0000 (-0400) Subject: Fix return value of generator on non-ostree systems X-Git-Tag: archive/raspbian/2023.7-3+rpi1~1^2~9^2~1^2~2^2 X-Git-Url: https://dgit.raspbian.org/?a=commitdiff_plain;h=3c76d03af24de5ac8fa3a834fde8e8d11179021c;p=ostree.git Fix return value of generator on non-ostree systems Commit aa72caffb540114a0e8635ab2990b9c8b0b8f9db regressed the `ostree-system-generator` on non-ostree systems. If there's no `ostree=` karg, we need to just exit 0. Closes: https://github.com/ostreedev/ostree/issues/2909 Fixes: aa72caffb540114a0e8635ab2990b9c8b0b8f9db --- diff --git a/src/switchroot/ostree-mount-util.h b/src/switchroot/ostree-mount-util.h index cc3a7742..7c7c6ce1 100644 --- a/src/switchroot/ostree-mount-util.h +++ b/src/switchroot/ostree-mount-util.h @@ -153,7 +153,7 @@ get_ostree_target (void) autofree char *ostree_cmdline = read_proc_cmdline_key ("ostree"); if (!ostree_cmdline) - errx (EXIT_FAILURE, "No ostree= cmdline"); + return NULL; if (strcmp (ostree_cmdline, "aboot") == 0) return get_aboot_root_slot (); diff --git a/src/switchroot/ostree-prepare-root.c b/src/switchroot/ostree-prepare-root.c index be772a3f..d41bdfb2 100644 --- a/src/switchroot/ostree-prepare-root.c +++ b/src/switchroot/ostree-prepare-root.c @@ -157,6 +157,8 @@ resolve_deploy_path (const char *root_mountpoint) struct stat stbuf; char *deploy_path; autofree char *ostree_target = get_ostree_target (); + if (!ostree_target) + errx (EXIT_FAILURE, "No ostree= cmdline"); if (snprintf (destpath, sizeof (destpath), "%s/%s", root_mountpoint, ostree_target) < 0) err (EXIT_FAILURE, "failed to assemble ostree target path"); diff --git a/src/switchroot/ostree-system-generator.c b/src/switchroot/ostree-system-generator.c index 6dabba6d..ecae432a 100644 --- a/src/switchroot/ostree-system-generator.c +++ b/src/switchroot/ostree-system-generator.c @@ -64,6 +64,8 @@ main (int argc, char *argv[]) * is PID 1 (and so hasn't created /run/ostree-booted). */ autofree char *ostree_target = get_ostree_target (); + if (!ostree_target) + exit (EXIT_SUCCESS); /* See comments in ostree-prepare-root.c for this. *