]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
kernel-install: Fix inspect with --root= when no version is specified
authorDaan De Meyer <daan.j.demeyer@gmail.com>
Sun, 10 Dec 2023 16:02:38 +0000 (17:02 +0100)
committerLuca Boccassi <luca.boccassi@gmail.com>
Mon, 11 Dec 2023 12:06:51 +0000 (12:06 +0000)
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=.

src/kernel-install/kernel-install.c

index 2387eb07fa1a9472d53efc78600da619b42d58d6..45f0c1e7a8cc297f67a751599097d7ae4470fda1 100644 (file)
@@ -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;