Skip to content
Snippets Groups Projects
Commit 0f7a2a5f authored by Bruce Momjian's avatar Bruce Momjian
Browse files

Create temporary files securely.

parent a8098996
No related branches found
No related tags found
No related merge requests found
......@@ -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
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment