File 0005-rescan-scsi-bus.sh-Use-safe-temporary-files.patch of Package sg3_utils.1568
From f02d8b227f337b73fcbb0116b9f1789ca84cbd3d Mon Sep 17 00:00:00 2001
From: Hannes Reinecke <hare@suse.de>
Date: Wed, 25 Nov 2015 11:20:49 +0100
Subject: rescan-scsi-bus.sh: Use safe temporary files
Use 'mktemp' to create a temporary file, or generate one based
on the process ID if mktemp fails.
References: bsc#955856
Signed-off-by: Hannes Reinecke <hare@suse.com>
---
scripts/rescan-scsi-bus.sh | 9 ++++++---
1 file changed, 6 insertions(+), 3 deletions(-)
diff --git a/scripts/rescan-scsi-bus.sh b/scripts/rescan-scsi-bus.sh
index 872dac7..36e2f09 100755
--- a/scripts/rescan-scsi-bus.sh
+++ b/scripts/rescan-scsi-bus.sh
@@ -703,9 +703,12 @@ findremapped()
local mpath_uuid=
local remapped=
mpaths=""
- local tmpfile="/tmp/rescan-scsi-bus-`date +s`"
+ local tmpfile=$(mktemp /tmp/rescan-scsi-bus.XXXXXXXX 2> /dev/null)
- test -f $tmpfile && rm $tmpfile
+ if [ -z "$tmpfile" ] ; then
+ tmpfile="/tmp/rescan-scsi-bus.$$"
+ rm -f $tmpfile
+ fi
# Get all of the ID_SERIAL attributes, after finding their sd node
for hctl in $devs ; do
@@ -754,7 +757,7 @@ findremapped()
echo "$SCSISTR"
incrchgd "$hctl"
done < $tmpfile
- [ -f $tmpfile ] && rm $tmpfile
+ rm -f $tmpfile
if test -n "$mp_enable" -a -n "$mpaths" ; then
echo "Updating multipath device mappings"
--
1.8.4.5