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