From: Mike Swanson Date: Sat, 8 Nov 2014 22:28:10 +0000 (-0800) Subject: srctest: use umask and mktemp for secure file names X-Git-Tag: 0.3~26 X-Git-Url: http://thyrsus.com/gitweb/?a=commitdiff_plain;h=8d24c51ac527e735a49c6311f0fe1ad09fd71b53;p=src.git srctest: use umask and mktemp for secure file names Just avoids some potential attacks from other users, either security or simply messing up the testing. --- diff --git a/srctest b/srctest index 77641db..49a32af 100755 --- a/srctest +++ b/srctest @@ -3,8 +3,12 @@ # Regression tester for SRC. # -# Needs to not be a subdirectory of here, or git gets confused -SANDBOX=/tmp/src-sandbox +# Set the umask for a bit of defensiveness +umask 0077 + +# Needs to not be a subdirectory of here, or git gets confused. Use +# -u so that `src init` will work. +SANDBOX=$(mktemp -u /tmp/.src_XXXXXXXX) trap "rm -fr testfile* testrev* newname* $SANDBOX" 0 1 2 15 @@ -17,8 +21,6 @@ check() { TESTOPTS="-T -S $SANDBOX $*" -rm -fr $SANDBOX - # Catches dumb and obvious case of code having a Python syntax error src $TESTOPTS init check "init" @@ -195,4 +197,6 @@ EOF src $TESTOPTS ls | diff -u testfile16 - check "ls" +rm -fr $SANDBOX + # end