9f65cc
From 090aa276b8d4b5041472743ea7472a3a1d398a92 Mon Sep 17 00:00:00 2001
9f65cc
From: Kairui Song <kasong@redhat.com>
9f65cc
Date: Tue, 10 Aug 2021 17:37:08 +0800
9f65cc
Subject: [PATCH] fix(lsinitrd): TMP_DIR doesn't exist in RHEL8
9f65cc
9f65cc
lsinitrd should create a seperate temp file for extracting squash image
9f65cc
when squash module is enabled.
9f65cc
9f65cc
Signed-off-by: Kairui Song <kasong@redhat.com>
9f65cc
(cherry picked from commit 52fcd3373f0cf715b3744f832643dc3170aefbf5)
9f65cc
9f65cc
Resolves: #1991647
9f65cc
---
9f65cc
 lsinitrd.sh | 4 ++--
9f65cc
 1 file changed, 2 insertions(+), 2 deletions(-)
9f65cc
9f65cc
diff --git a/lsinitrd.sh b/lsinitrd.sh
9f65cc
index 04ce9e8b..85981e58 100755
9f65cc
--- a/lsinitrd.sh
9f65cc
+++ b/lsinitrd.sh
9f65cc
@@ -163,8 +163,8 @@ list_files()
9f65cc
 list_squash_content()
9f65cc
 {
9f65cc
     SQUASH_IMG="squash-root.img"
9f65cc
-    SQUASH_TMPFILE="$TMPDIR/initrd.root.sqsh"
9f65cc
-
9f65cc
+    SQUASH_TMPFILE="$(mktemp -t --suffix=.root.sqsh lsinitrd.XXXXXX)"
9f65cc
+    trap "rm -f '$SQUASH_TMPFILE'" EXIT
9f65cc
     $CAT "$image" 2>/dev/null | cpio --extract --verbose --quiet --to-stdout -- \
9f65cc
         $SQUASH_IMG > "$SQUASH_TMPFILE" 2>/dev/null
9f65cc
     if [[ -s $SQUASH_TMPFILE ]]; then
9f65cc