GwenNelson / distcc

Automatically exported from code.google.com/p/distcc
GNU General Public License v2.0
0 stars 0 forks source link

pump should respect $TMPDIR #100

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
distcc 3.2rc1 SVN r755

The pump script should use $TMPDIR if set, in preference to /tmp.

Patch attached.

Original issue reported on code.google.com by kamal@whence.com on 4 Apr 2012 at 4:27

Attachments:

GoogleCodeExporter commented 9 years ago
How about this patch instead?

Index: pump.in
===================================================================
--- pump.in (revision 755)
+++ pump.in (working copy)
@@ -181,7 +181,7 @@
 # $2="-d" to make a directory. The name of the created temp file or
 # directory is written to stdout.
 MakeTmpFile() {
-  if mktemp $2 /tmp/$1.XXXXXX; then
+  if mktemp $2 ${TMPDIR-/tmp}/$1.XXXXXX; then
     :   # mktemp prints the output we want; no need to do more
   else
     echo "$program_name: Could not make temp \"$1\"" 1>&2

Original comment by fergus.h...@gmail.com on 4 Apr 2012 at 5:11

GoogleCodeExporter commented 9 years ago
On Wed, 2012-04-04 at 17:11 +0000, distcc@googlecode.com wrote:
> -  if mktemp $2 /tmp/$1.XXXXXX; then
> +  if mktemp $2 ${TMPDIR-/tmp}/$1.XXXXXX; then 

Looks good.  But on closer inspection, we should protect against TMPDIR="/a dir 
with spaces/" so better wrap that in quotes.  $2 also for good measure...

    if mktemp "$2" "${TMPDIR-/tmp}/$1.XXXXXX"; then 

Original comment by kamal@whence.com on 4 Apr 2012 at 5:23

GoogleCodeExporter commented 9 years ago
> Looks good.  But on closer inspection, we should protect against TMPDIR="/a 
dir with spaces/" so better wrap that in quotes. 

Done.

> $2 also for good measure...

We need to leave $2 unquoted in order to correctly handle the case when the 
caller passes in only a single argument.

I'll go ahead and submit the following patch.  Thanks.

Index: pump.in
===================================================================
--- pump.in (revision 755)
+++ pump.in (working copy)
@@ -181,7 +181,7 @@
 # $2="-d" to make a directory. The name of the created temp file or
 # directory is written to stdout.
 MakeTmpFile() {
-  if mktemp $2 /tmp/$1.XXXXXX; then
+  if mktemp $2 "${TMPDIR-/tmp}/$1.XXXXXX"; then
     :   # mktemp prints the output we want; no need to do more
   else
     echo "$program_name: Could not make temp \"$1\"" 1>&2

Original comment by fergus.h...@gmail.com on 4 Apr 2012 at 5:36

GoogleCodeExporter commented 9 years ago
Fixed in revision 756.

Original comment by fergus.h...@gmail.com on 4 Apr 2012 at 5:52