Blob Blame History Raw
From a8018a5553bfccfbd28ea77e06207d68f60f12e6 Mon Sep 17 00:00:00 2001
From: Pavel Valena <pvalena@redhat.com>
Date: Fri, 25 Mar 2022 16:20:16 +0100
Subject: [PATCH] fix(dracut-install): do not fail when SOURCE is optional and
 missing

When running dracut-install with '-o' (optional source), and nullglob
at the same time, when all of the arguments evaluate <null>, dracut-install
should not fail even when the source is not specified.

Resolves: #2047654
---
 src/install/dracut-install.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/src/install/dracut-install.c b/src/install/dracut-install.c
index 9a40e022..ad16b98f 100644
--- a/src/install/dracut-install.c
+++ b/src/install/dracut-install.c
@@ -1199,8 +1199,12 @@ static int parse_argv(int argc, char *argv[])
         }
 
         if (!optind || optind == argc) {
-                log_error("No SOURCE argument given");
-                usage(EXIT_FAILURE);
+                if (!arg_optional) {
+                        log_error("No SOURCE argument given");
+                        usage(EXIT_FAILURE);
+                } else {
+                        exit(EXIT_SUCCESS);
+                }
         }
 
         return 1;