28ab1c
From eaba11eff1156f7a0324a1aa46e43396c7ec3628 Mon Sep 17 00:00:00 2001
28ab1c
From: =?UTF-8?q?Renaud=20M=C3=A9trich?= <rmetrich@redhat.com>
28ab1c
Date: Mon, 1 Mar 2021 17:43:10 +0100
28ab1c
Subject: [PATCH] fix(dracut.sh): harden dracut against GZIP environment
28ab1c
 variable
28ab1c
MIME-Version: 1.0
28ab1c
Content-Type: text/plain; charset=UTF-8
28ab1c
Content-Transfer-Encoding: 8bit
28ab1c
28ab1c
When a GZIP environment variable is set, this leads to various breakage:
28ab1c
28ab1c
In case 'pigz' is installed and GZIP is defined as a path, e.g.
28ab1c
/usr/local/bin/gzip, then dracut will fail with the following message:
28ab1c
28ab1c
   "
28ab1c
   pigz: abort: cannot provide files in GZIP environment variable
28ab1c
   "
28ab1c
28ab1c
In case 'pigz' isn't installed and regular 'gzip' is used and GZIP is
28ab1c
defined as a path, e.g. /usr/local/bin/gzip, then the path will be
28ab1c
zipped and dracut will fail for no obvious reason.  Trying again, dracut
28ab1c
will then fail with following message:
28ab1c
28ab1c
   "
28ab1c
   gzip: /usr/local/bin/gzip.gz already exists;	not overwritten
28ab1c
   "
28ab1c
28ab1c
In any case, GZIP environment should be unset to avoid breakage or
28ab1c
unwanted behaviour. This variable is anyway obsolescent, from gzip(1)
28ab1c
manpage.
28ab1c
28ab1c
Signed-off-by: Renaud Métrich <rmetrich@redhat.com>
28ab1c
(cherry picked from commit d8e47e201af4646e2a82e11220ea9c993bd2ed48)
28ab1c
28ab1c
Resolves: #1933773
28ab1c
---
28ab1c
 dracut.sh | 1 +
28ab1c
 1 file changed, 1 insertion(+)
28ab1c
28ab1c
diff --git a/dracut.sh b/dracut.sh
28ab1c
index 01abe7a4..4340e646 100755
28ab1c
--- a/dracut.sh
28ab1c
+++ b/dracut.sh
28ab1c
@@ -24,6 +24,7 @@
28ab1c
 # store for logging
28ab1c
 
28ab1c
 unset BASH_ENV
28ab1c
+unset GZIP
28ab1c
 
28ab1c
 # Verify bash version, current minimum is 4
28ab1c
 if (( BASH_VERSINFO[0] < 4 )); then
28ab1c