[Tools] winetest: Don't count on $TMPDIR staying set.

Francois Gouget fgouget at codeweavers.com
Wed Feb 8 01:07:43 CST 2017


The BEGIN code block will be run the first time the web server loads
the CGI script. However the web server may use caching techniques that
result in the script being run a second time while skipping the BEGIN
code block. Furthermore $TMPDIR may have been unset which will cause
tempdir(DIR => "") to fail with a permission denied error.
Perl variables are preserved however so use them instead.
Still set $TMPDIR so the CGI temporary file will be on the right
filesystem, resulting in a faster move operation.

Signed-off-by: Francois Gouget <fgouget at codeweavers.com>
---
 winetest/winetest.cgi | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/winetest/winetest.cgi b/winetest/winetest.cgi
index 93906bf8..93afee52 100755
--- a/winetest/winetest.cgi
+++ b/winetest/winetest.cgi
@@ -22,7 +22,6 @@ use vars qw/$queuedir $maxfilesize/;
 
 BEGIN {
     require "winetest.conf";
-    $ENV{TMPDIR} = $queuedir;
 }
 
 use File::Copy;
@@ -30,6 +29,7 @@ use File::Temp qw(tempdir);
 use CGI qw(:standard);
 # Cater for some overhead
 $CGI::POST_MAX = $maxfilesize + 1024;
+$ENV{TMPDIR} = $queuedir;
 
 my $name = param ("reportfile");
 my $error = cgi_error ();
@@ -47,7 +47,7 @@ sub move_file($)
 {
     my ($filename) = @_;
     my $orig = tmpFileName($filename);
-    my $tmpdir = tempdir ("repXXXXX", DIR=>$ENV{TMPDIR});
+    my $tmpdir = tempdir ("repXXXXX", DIR => $queuedir);
     chmod 0777, $tmpdir;
     chmod 0666&~umask, $orig;
     my $size = -s $orig;
-- 
2.11.0




More information about the wine-patches mailing list