From 5fb55ea2926080ff910b2d74b96b5a019b03e5a1 Mon Sep 17 00:00:00 2001 From: Peter Valchev Date: Sat, 8 Feb 2003 10:15:08 +0000 Subject: fix /tmp races; this no longer leaves files around. ok millert jason henric --- sys/arch/sparc64/stand/bootblk/genassym.sh | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) (limited to 'sys/arch/sparc64/stand') diff --git a/sys/arch/sparc64/stand/bootblk/genassym.sh b/sys/arch/sparc64/stand/bootblk/genassym.sh index dd065b096a1..e2c84314041 100644 --- a/sys/arch/sparc64/stand/bootblk/genassym.sh +++ b/sys/arch/sparc64/stand/bootblk/genassym.sh @@ -1,4 +1,4 @@ -# $OpenBSD: genassym.sh,v 1.1 2001/08/18 04:16:37 jason Exp $ +# $OpenBSD: genassym.sh,v 1.2 2003/02/08 10:15:07 pvalchev Exp $ # $NetBSD: genassym.sh,v 1.1 2000/08/20 14:58:45 mrg Exp $ # @@ -36,6 +36,13 @@ # compile it and execute the result. awk=${AWK:-awk} +TMP1=`mktemp /tmp/genassym1.XXXXXX` || exit 1 +TMP2=`mktemp /tmp/genassym2.XXXXXX` || { + rm -f $TMP1 + exit 1 +} + +trap 'rm -f $TMP1 $TMP2' 0 1 2 3 13 15 if [ $1 = '-c' ] ; then shift @@ -44,8 +51,6 @@ else ccode=0 fi -#trap "rm -f /tmp/$$.c /tmp/genassym.$$" 0 1 2 3 15 - $awk ' BEGIN { printf("#ifndef _KERNEL\n#define _KERNEL\n#endif\n"); @@ -158,13 +163,13 @@ END { printf("return(0); }\n"); } } -' ccode=$ccode > /tmp/$$.c || exit 1 +' ccode=$ccode > $TMP1 || exit 1 if [ $ccode = 1 ] ; then - "$@" /tmp/$$.c -o /tmp/genassym.$$ && /tmp/genassym.$$ + "$@" -x c $TMP1 -o $TMP2 && $TMP2 else # Kill all of the "#" and "$" modifiers; locore.s already # prepends the correct "constant" modifier. - "$@" -S /tmp/$$.c -o -| sed -e 's/\$//g' | \ - sed -n 's/.*XYZZY//gp' + "$@" -x c -S ${TMP1} -o ${TMP2} || exit 1 + sed 's/\$//g' ${TMP2} | sed -n 's/.*XYZZY//gp' fi -- cgit v1.2.3