From 5542f1c47340eee7914ae2d9f12749d756e0ec52 Mon Sep 17 00:00:00 2001 From: Kris Kennaway Date: Thu, 2 Nov 2000 06:33:57 +0000 Subject: [PATCH] Don't use a trivially predictable temporary filename and keep recreating it again and again, practically begging the Bad Man to insert his symlink underneath it and send us down the path to oblivion. Noticed by: David Lary --- usr.sbin/periodic/periodic.sh | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/usr.sbin/periodic/periodic.sh b/usr.sbin/periodic/periodic.sh index cd152d8d8454..ce38ba2d6e6f 100644 --- a/usr.sbin/periodic/periodic.sh +++ b/usr.sbin/periodic/periodic.sh @@ -27,7 +27,7 @@ fi host=`hostname` export host -tmp_output=${TMPDIR:-/tmp}/periodic.$$ +tmp_output=`mktemp ${TMPDIR:-/tmp}/periodic.XXXXXXXXXX` # Execute each executable file in the directory list. If the x bit is not # set, assume the user didn't really want us to muck with it (it's a @@ -89,9 +89,10 @@ do esac [ $output = TRUE ] && { cat $tmp_output; empty=FALSE; } fi - rm -f $tmp_output + cp /dev/null $tmp_output fi done + rm -f $tmp_output done if [ $empty = TRUE ] then