提交 0f7a2a5f 编写于 作者: B Bruce Momjian

Create temporary files securely.

上级 a8098996
......@@ -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
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册