mirror of
https://github.com/postgres/postgres.git
synced 2025-04-29 13:56:47 +03: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.
|
# Caution: you may need to use GNU awk.
|
||||||
AWK=${AWK:-awk}
|
AWK=${AWK:-awk}
|
||||||
|
|
||||||
INPUTFILE="tmp$$a"
|
TMP="/tmp/$$"
|
||||||
DUPSFILE="tmp$$b"
|
trap "rm -rf $TMP" 0 1 2 3 15
|
||||||
NONDUPSFILE="tmp$$c"
|
|
||||||
rm -f $INPUTFILE $DUPSFILE $NONDUPSFILE
|
|
||||||
|
|
||||||
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
|
# Read input
|
||||||
cat "$@" >$INPUTFILE
|
cat "$@" >$INPUTFILE
|
||||||
|
Loading…
x
Reference in New Issue
Block a user