]> granicus.if.org Git - postgresql/commitdiff
Use temp files in current directory, not /tmp, to reduce security risk
authorTom Lane <tgl@sss.pgh.pa.us>
Wed, 20 Oct 2004 16:42:46 +0000 (16:42 +0000)
committerTom Lane <tgl@sss.pgh.pa.us>
Wed, 20 Oct 2004 16:42:46 +0000 (16:42 +0000)
while running this script.

contrib/findoidjoins/make_oidjoins_check

index 74a2856778c6654d89a307c99585cf1b5f5f4cb8..5106eb1bfd940c1aefdb59852745616158ba89ad 100755 (executable)
 # Caution: you may need to use GNU awk.
 AWK=${AWK:-awk}
 
-trap "rm -f /tmp/$$ /tmp/$$a /tmp/$$b" 0 1 2 3 15
+INPUTFILE="tmp$$a"
+DUPSFILE="tmp$$b"
+NONDUPSFILE="tmp$$c"
+rm -f $INPUTFILE $DUPSFILE $NONDUPSFILE
+
+trap "rm -f $INPUTFILE $DUPSFILE $NONDUPSFILE" 0 1 2 3 15
 
 # Read input
-cat "$@" >/tmp/$$
+cat "$@" >$INPUTFILE
 
 # Look for fields with multiple references.
-cat /tmp/$$ | cut -d' ' -f2 | sort | uniq -d >/tmp/$$a
-if [ -s /tmp/$$a ] ; then
+cat $INPUTFILE | cut -d' ' -f2 | sort | uniq -d >$DUPSFILE
+if [ -s $DUPSFILE ] ; then
        echo "Ignoring these fields that link to multiple tables:" 1>&2
-       cat /tmp/$$a 1>&2
+       cat $DUPSFILE 1>&2
 fi
 
 # Get the non-multiply-referenced fields.
-cat /tmp/$$ | while read LINE
+cat $INPUTFILE | while read LINE
 do
        set -- $LINE
-       grep "^$2\$" /tmp/$$a >/dev/null 2>&1 || echo $LINE
-done >/tmp/$$b
+       grep "^$2\$" $DUPSFILE >/dev/null 2>&1 || echo $LINE
+done >$NONDUPSFILE
 
 # Generate the output.
-cat /tmp/$$b |
+cat $NONDUPSFILE |
 $AWK -F'[ \.]' '\
        BEGIN \
        {