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