git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: David Aguilar <davvid@gmail.com>
To: Paul Mackerras <paulus@samba.org>
Cc: git@vger.kernel.org,
	"brian m. carlson" <sandals@crustytoothpaste.net>,
	Pat Thoyts <patthoyts@users.sourceforge.net>
Subject: [PATCH] gitk: avoid mkdtemp on Windows
Date: Sun, 15 Jun 2014 15:23:56 -0700	[thread overview]
Message-ID: <1402871036-1389-1-git-send-email-davvid@gmail.com> (raw)

105b5d3fbb1c00bb0aeaf9d3e0fbe26a7b1993fc introduced a dependency
on mkdtemp, which is not available on Windows.

Restore the original temporary directory behavior for Windows so
that gitk creates temporary directories in the current
repository.

The Unix code path retains new TMPDIR behavior.

Reported-by: Pat Thoyts <patthoyts@users.sourceforge.net>
Helped-by: brian m. carlson <sandals@crustytoothpaste.net>
Signed-off-by: David Aguilar <davvid@gmail.com>
---
 gitk | 21 ++++++++++++++-------
 1 file changed, 14 insertions(+), 7 deletions(-)

diff --git a/gitk b/gitk
index 41e5071..66d8c9e 100755
--- a/gitk
+++ b/gitk
@@ -3496,15 +3496,22 @@ proc gitknewtmpdir {} {
     global diffnum gitktmpdir gitdir env
 
     if {![info exists gitktmpdir]} {
-	if {[info exists env(GITK_TMPDIR)]} {
-	    set tmpdir $env(GITK_TMPDIR)
-	} elseif {[info exists env(TMPDIR)]} {
-	    set tmpdir $env(TMPDIR)
+	if {$::tcl_platform(platform) eq {windows}} {
+	    # Windows does not have mkdtemp so use the current directory
+	    # to avoid using an unsafe pattern in a world-writeable
+	    # temporary directory.
+	    set gitktmpdir [file join $gitdir [format ".gitk-tmp.%s" [pid]]]
 	} else {
-	    set tmpdir $gitdir
+	    if {[info exists env(GITK_TMPDIR)]} {
+		set tmpdir $env(GITK_TMPDIR)
+	    } elseif {[info exists env(TMPDIR)]} {
+		set tmpdir $env(TMPDIR)
+	    } else {
+		set tmpdir $gitdir
+	    }
+	    set gitktmpformat [file join $tmpdir ".gitk-tmp.XXXXXX"]
+	    set gitktmpdir [exec mktemp -d $gitktmpformat]
 	}
-	set gitktmpformat [file join $tmpdir ".gitk-tmp.XXXXXX"]
-	set gitktmpdir [exec mktemp -d $gitktmpformat]
 	if {[catch {file mkdir $gitktmpdir} err]} {
 	    error_popup "[mc "Error creating temporary directory %s:" $gitktmpdir] $err"
 	    unset gitktmpdir
-- 
2.0.0.257.g75cc6c6

                 reply	other threads:[~2014-06-15 22:24 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=1402871036-1389-1-git-send-email-davvid@gmail.com \
    --to=davvid@gmail.com \
    --cc=git@vger.kernel.org \
    --cc=patthoyts@users.sourceforge.net \
    --cc=paulus@samba.org \
    --cc=sandals@crustytoothpaste.net \
    /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.
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).