Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit a171fc1

Browse files
committed
Use temp files in current directory, not /tmp, to reduce security risk
while running this script.
1 parent fb22b32 commit a171fc1

File tree

1 file changed

+14
-9
lines changed

1 file changed

+14
-9
lines changed

contrib/findoidjoins/make_oidjoins_check

+14-9
Original file line numberDiff line numberDiff line change
@@ -10,27 +10,32 @@
1010
# Caution: you may need to use GNU awk.
1111
AWK=${AWK:-awk}
1212

13-
trap "rm -f /tmp/$$ /tmp/$$a /tmp/$$b" 0 1 2 3 15
13+
INPUTFILE="tmp$$a"
14+
DUPSFILE="tmp$$b"
15+
NONDUPSFILE="tmp$$c"
16+
rm -f $INPUTFILE $DUPSFILE $NONDUPSFILE
17+
18+
trap "rm -f $INPUTFILE $DUPSFILE $NONDUPSFILE" 0 1 2 3 15
1419

1520
# Read input
16-
cat "$@" >/tmp/$$
21+
cat "$@" >$INPUTFILE
1722

1823
# Look for fields with multiple references.
19-
cat /tmp/$$ | cut -d' ' -f2 | sort | uniq -d >/tmp/$$a
20-
if [ -s /tmp/$$a ] ; then
24+
cat $INPUTFILE | cut -d' ' -f2 | sort | uniq -d >$DUPSFILE
25+
if [ -s $DUPSFILE ] ; then
2126
echo "Ignoring these fields that link to multiple tables:" 1>&2
22-
cat /tmp/$$a 1>&2
27+
cat $DUPSFILE 1>&2
2328
fi
2429

2530
# Get the non-multiply-referenced fields.
26-
cat /tmp/$$ | while read LINE
31+
cat $INPUTFILE | while read LINE
2732
do
2833
set -- $LINE
29-
grep "^$2\$" /tmp/$$a >/dev/null 2>&1 || echo $LINE
30-
done >/tmp/$$b
34+
grep "^$2\$" $DUPSFILE >/dev/null 2>&1 || echo $LINE
35+
done >$NONDUPSFILE
3136

3237
# Generate the output.
33-
cat /tmp/$$b |
38+
cat $NONDUPSFILE |
3439
$AWK -F'[ \.]' '\
3540
BEGIN \
3641
{

0 commit comments

Comments
 (0)