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