From: Daan De Meyer Date: Sun, 10 Dec 2023 16:02:38 +0000 (+0100) Subject: kernel-install: Fix inspect with --root= when no version is specified X-Git-Tag: v256-rc1~1523 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=dbab00564571ca47d77aa86b5cd0b1a43420c7b6;p=thirdparty%2Fsystemd.git kernel-install: Fix inspect with --root= when no version is specified Using the kernel version from the host is incorrect in this case, so fix the logic so it handles no version being specified correctly with --root=. --- diff --git a/src/kernel-install/kernel-install.c b/src/kernel-install/kernel-install.c index 2387eb07fa1..45f0c1e7a8c 100644 --- a/src/kernel-install/kernel-install.c +++ b/src/kernel-install/kernel-install.c @@ -306,7 +306,7 @@ static int context_set_uki_generator(Context *c, const char *s, const char *sour static int context_set_version(Context *c, const char *s) { assert(c); - if (!filename_is_valid(s)) + if (s && !filename_is_valid(s)) return log_error_errno(SYNTHETIC_ERRNO(EINVAL), "Invalid version specified: %s", s); return context_set_string(s, "command line", "kernel version", &c->version); @@ -1355,12 +1355,12 @@ static int verb_inspect(int argc, char *argv[], void *userdata) { (argc > 1 ? empty_or_dash_to_null(argv[1]) : NULL); initrds = strv_skip(argv, 3); - if (!version) { + if (!version && !arg_root) { assert_se(uname(&un) >= 0); version = un.release; } - if (!kernel) { + if (!kernel && version) { r = kernel_from_version(version, &vmlinuz); if (r < 0) return r;