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