Harald Hoyer 9f8738
From c1ab36139d416e580e768c29f2addf7ccbc2c612 Mon Sep 17 00:00:00 2001
Harald Hoyer 9f8738
From: Marcos Mello <marcosfrm@gmail.com>
Harald Hoyer 9f8738
Date: Thu, 20 May 2021 15:41:26 -0300
Harald Hoyer 9f8738
Subject: [PATCH] fix(install): sane default --kerneldir
Harald Hoyer 9f8738
Harald Hoyer 9f8738
If --kerneldir is not specified, use /lib/modules/$(uname -r).
Harald Hoyer 9f8738
Harald Hoyer 9f8738
Fixes #1505
Harald Hoyer 9f8738
---
Harald Hoyer 9f8738
 src/install/dracut-install.c | 5 ++++-
Harald Hoyer 9f8738
 1 file changed, 4 insertions(+), 1 deletion(-)
Harald Hoyer 9f8738
Harald Hoyer 9f8738
diff --git a/src/install/dracut-install.c b/src/install/dracut-install.c
Harald Hoyer 9f8738
index 9f044ae0..3fd70fc8 100644
Harald Hoyer 9f8738
--- a/src/install/dracut-install.c
Harald Hoyer 9f8738
+++ b/src/install/dracut-install.c
Harald Hoyer 9f8738
@@ -1167,7 +1167,10 @@ static int parse_argv(int argc, char *argv[])
Harald Hoyer 9f8738
         if (!kerneldir) {
Harald Hoyer 9f8738
                 struct utsname buf;
Harald Hoyer 9f8738
                 uname(&buf;;
Harald Hoyer 9f8738
-                kerneldir = strdup(buf.version);
Harald Hoyer 9f8738
+                if (asprintf(&kerneldir, "%s%s", "/lib/modules/", buf.release) < 0) {
Harald Hoyer 9f8738
+                        log_error("Out of memory!");
Harald Hoyer 9f8738
+                        exit(EXIT_FAILURE);
Harald Hoyer 9f8738
+                }
Harald Hoyer 9f8738
         }
Harald Hoyer 9f8738
 
Harald Hoyer 9f8738
         if (arg_modalias) {
Harald Hoyer 9f8738