mirror of
https://git.postgresql.org/git/postgresql.git
synced 2025-02-17 19:30:00 +08:00
Create temporary files securely.
This commit is contained in:
parent
a809899680
commit
0f7a2a5fbe
@ -10,12 +10,23 @@
|
||||
# Caution: you may need to use GNU awk.
|
||||
AWK=${AWK:-awk}
|
||||
|
||||
INPUTFILE="tmp$$a"
|
||||
DUPSFILE="tmp$$b"
|
||||
NONDUPSFILE="tmp$$c"
|
||||
rm -f $INPUTFILE $DUPSFILE $NONDUPSFILE
|
||||
TMP="/tmp/$$"
|
||||
trap "rm -rf $TMP" 0 1 2 3 15
|
||||
|
||||
trap "rm -f $INPUTFILE $DUPSFILE $NONDUPSFILE" 0 1 2 3 15
|
||||
# Create a temporary directory with the proper permissions so no one can
|
||||
# intercept our temporary files and cause a security breach.
|
||||
OMASK="`umask`"
|
||||
umask 077
|
||||
if ! mkdir $TMP
|
||||
then echo "Can't create temporary directory $TMP." 1>&2
|
||||
exit 1
|
||||
fi
|
||||
umask "$OMASK"
|
||||
unset OMASK
|
||||
|
||||
INPUTFILE="$TMP/a"
|
||||
DUPSFILE="$TMP/b"
|
||||
NONDUPSFILE="$TMP/c"
|
||||
|
||||
# Read input
|
||||
cat "$@" >$INPUTFILE
|
||||
|
Loading…
Reference in New Issue
Block a user