zsh-workers
 help / color / mirror / code / Atom feed
From: Peter Stephenson <p.stephenson@samsung.com>
To: zsh-workers@zsh.org
Subject: Re: Potential security issue in the zsh tests
Date: Mon, 05 Dec 2016 16:49:41 +0000	[thread overview]
Message-ID: <20161205164941.0f25c84f@pwslap01u.europe.root.pri> (raw)
In-Reply-To: <20161205140725.GA24275@cventin.lip.ens-lyon.fr>

On Mon, 5 Dec 2016 15:07:25 +0100
Vincent Lefevre <vincent@vinc17.net> wrote:
> When building zsh, I notice that zsh writes results of the tests
> directly under /tmp, e.g.

It's easy to do better.

pws

diff --git a/Test/C02cond.ztst b/Test/C02cond.ztst
index 40e4dfb..27a2259 100644
--- a/Test/C02cond.ztst
+++ b/Test/C02cond.ztst
@@ -11,9 +11,9 @@
   typeset -gi isnfs
   [[ "$(find . -prune -fstype nfs 2>/dev/null)" == "." ]] && isnfs=1
   if (( isnfs )) &&
-    (cd -q ${TMPPREFIX:h} >/dev/null 2>&1 &&
+    (cd -q ${ZTST_tmp} >/dev/null 2>&1 &&
      [[ "$(find . -prune -fstype nfs 2>/dev/null)" != "." ]]); then
-    filetmpprefix=${TMPPREFIX}-$$-
+    filetmpprefix=${ZTST_tmp}/condtest-$$-
     isnfs=0
   else
     filetmpprefix=
diff --git a/Test/ztst.zsh b/Test/ztst.zsh
index 8ae06b8..0235095 100755
--- a/Test/ztst.zsh
+++ b/Test/ztst.zsh
@@ -104,19 +104,23 @@ fpath=( $ZTST_srcdir/../Functions/*~*/CVS(/)
         $ZTST_srcdir/../Completion/*/*~*/CVS(/) )
 
 : ${TMPPREFIX:=/tmp/zsh}
+ZTST_tmp=${TMPPREFIX}.ztst.$$
+if ! rm -f $ZTST_tmp || ! mkdir -p $ZTST_tmp || ! chmod go-w $ZTST_tmp; then
+  print "Can't create $ZTST_tmp for exclusive use." >&2
+  exit 1
+fi
 # Temporary files for redirection inside tests.
-ZTST_in=${TMPPREFIX}.ztst.in.$$
+ZTST_in=${ZTST_tmp}/ztst.in
 # hold the expected output
-ZTST_out=${TMPPREFIX}.ztst.out.$$
-ZTST_err=${TMPPREFIX}.ztst.err.$$
+ZTST_out=${ZTST_tmp}/ztst.out
+ZTST_err=${ZTST_tmp}/ztst.err
 # hold the actual output from the test
-ZTST_tout=${TMPPREFIX}.ztst.tout.$$
-ZTST_terr=${TMPPREFIX}.ztst.terr.$$
+ZTST_tout=${ZTST_tmp}/ztst.tout
+ZTST_terr=${ZTST_tmp}/ztst.terr
 
 ZTST_cleanup() {
   cd $ZTST_testdir
-  rm -rf $ZTST_testdir/dummy.tmp $ZTST_testdir/*.tmp(N) \
-    ${TMPPREFIX}.ztst*$$(N)
+  rm -rf $ZTST_testdir/dummy.tmp $ZTST_testdir/*.tmp(N) ${ZTST_tmp}
 }
 
 # This cleanup always gets performed, even if we abort.  Later,


      reply	other threads:[~2016-12-05 16:49 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <CGME20161205140756epcas3p283e3767afd39dc288805be06fb51629b@epcas3p2.samsung.com>
2016-12-05 14:07 ` Vincent Lefevre
2016-12-05 16:49   ` Peter Stephenson [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20161205164941.0f25c84f@pwslap01u.europe.root.pri \
    --to=p.stephenson@samsung.com \
    --cc=zsh-workers@zsh.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).