From owner-svn-src-all@FreeBSD.ORG Sun Jan 10 20:26:03 2010 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id D0E61106566C; Sun, 10 Jan 2010 20:26:03 +0000 (UTC) (envelope-from harti@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id A89248FC18; Sun, 10 Jan 2010 20:26:03 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id o0AKQ3WZ032020; Sun, 10 Jan 2010 20:26:03 GMT (envelope-from harti@svn.freebsd.org) Received: (from harti@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id o0AKQ34o032018; Sun, 10 Jan 2010 20:26:03 GMT (envelope-from harti@svn.freebsd.org) Message-Id: <201001102026.o0AKQ34o032018@svn.freebsd.org> From: Hartmut Brandt Date: Sun, 10 Jan 2010 20:26:03 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r202045 - head/usr.bin/make X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 10 Jan 2010 20:26:03 -0000 Author: harti Date: Sun Jan 10 20:26:03 2010 New Revision: 202045 URL: http://svn.freebsd.org/changeset/base/202045 Log: Make make respect the TMPDIR environment variable. PR: bin/115447 Submitted by: Eugene Grosbein Modified: head/usr.bin/make/job.c Modified: head/usr.bin/make/job.c ============================================================================== --- head/usr.bin/make/job.c Sun Jan 10 20:22:05 2010 (r202044) +++ head/usr.bin/make/job.c Sun Jan 10 20:26:03 2010 (r202045) @@ -114,6 +114,7 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include #include #include @@ -137,7 +138,8 @@ __FBSDID("$FreeBSD$"); #include "util.h" #include "var.h" -#define TMPPAT "/tmp/makeXXXXXXXXXX" +#define TMPPAT "makeXXXXXXXXXX" +#define TMPDIR "/tmp" #ifndef USE_KQUEUE /* @@ -236,7 +238,7 @@ typedef struct Job { */ struct { /* Name of file to which shell output was rerouted */ - char of_outFile[sizeof(TMPPAT)]; + char of_outFile[PATH_MAX]; /* * Stream open to the output file. Used to funnel all @@ -1566,7 +1568,8 @@ JobStart(GNode *gn, int flags, Job *prev Boolean noExec; /* Set true if we decide not to run the job */ int tfd; /* File descriptor for temp file */ LstNode *ln; - char tfile[sizeof(TMPPAT)]; + char tfile[PATH_MAX]; + const char *tdir; if (interrupted) { JobPassSig(interrupted); @@ -1607,6 +1610,9 @@ JobStart(GNode *gn, int flags, Job *prev cmdsOK = TRUE; } + if ((tdir = getenv("TMPDIR")) == NULL) + tdir = TMPDIR; + /* * If the -n flag wasn't given, we open up OUR (not the child's) * temporary file to stuff commands in it. The thing is rd/wr so we @@ -1622,7 +1628,7 @@ JobStart(GNode *gn, int flags, Job *prev DieHorribly(); } - strcpy(tfile, TMPPAT); + snprintf(tfile, sizeof(tfile), "%s/%s", tdir, TMPPAT); if ((tfd = mkstemp(tfile)) == -1) Punt("Cannot create temp file: %s", strerror(errno)); job->cmdFILE = fdopen(tfd, "w+"); @@ -1801,7 +1807,10 @@ JobStart(GNode *gn, int flags, Job *prev } else { fprintf(stdout, "Remaking `%s'\n", gn->name); fflush(stdout); - strcpy(job->outFile, TMPPAT); + if ((tdir = getenv("TMPDIR")) == NULL) + tdir = TMPDIR; + snprintf(job->outFile, sizeof(job->outFile), "%s/%s", + tdir, TMPPAT); if ((job->outFd = mkstemp(job->outFile)) == -1) Punt("cannot create temp file: %s", strerror(errno));