Skip to content

Commit 0f7a2a5

Browse files
committed
Create temporary files securely.
1 parent a809899 commit 0f7a2a5

File tree

1 file changed

+16
-5
lines changed

1 file changed

+16
-5
lines changed

contrib/findoidjoins/make_oidjoins_check

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,23 @@
1010
# Caution: you may need to use GNU awk.
1111
AWK=${AWK:-awk}
1212

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

18-
trap "rm -f $INPUTFILE $DUPSFILE $NONDUPSFILE" 0 1 2 3 15
16+
# Create a temporary directory with the proper permissions so no one can
17+
# intercept our temporary files and cause a security breach.
18+
OMASK="`umask`"
19+
umask 077
20+
if ! mkdir $TMP
21+
then echo "Can't create temporary directory $TMP." 1>&2
22+
exit 1
23+
fi
24+
umask "$OMASK"
25+
unset OMASK
26+
27+
INPUTFILE="$TMP/a"
28+
DUPSFILE="$TMP/b"
29+
NONDUPSFILE="$TMP/c"
1930

2031
# Read input
2132
cat "$@" >$INPUTFILE

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy