Blob Blame History Raw
From c1ab36139d416e580e768c29f2addf7ccbc2c612 Mon Sep 17 00:00:00 2001
From: Marcos Mello <marcosfrm@gmail.com>
Date: Thu, 20 May 2021 15:41:26 -0300
Subject: [PATCH] fix(install): sane default --kerneldir

If --kerneldir is not specified, use /lib/modules/$(uname -r).

Fixes #1505
---
 src/install/dracut-install.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/src/install/dracut-install.c b/src/install/dracut-install.c
index 9f044ae0..3fd70fc8 100644
--- a/src/install/dracut-install.c
+++ b/src/install/dracut-install.c
@@ -1167,7 +1167,10 @@ static int parse_argv(int argc, char *argv[])
         if (!kerneldir) {
                 struct utsname buf;
                 uname(&buf);
-                kerneldir = strdup(buf.version);
+                if (asprintf(&kerneldir, "%s%s", "/lib/modules/", buf.release) < 0) {
+                        log_error("Out of memory!");
+                        exit(EXIT_FAILURE);
+                }
         }
 
         if (arg_modalias) {