Francois Gouget : winetest: Don't count on $TMPDIR staying set.

Alexandre Julliard julliard at winehq.org
Wed Feb 8 15:23:06 CST 2017


Module: tools
Branch: master
Commit: 9be551efdd99ae2504c089b2b979b15e87779b52
URL:    http://source.winehq.org/git/tools.git/?a=commit;h=9be551efdd99ae2504c089b2b979b15e87779b52

Author: Francois Gouget <fgouget at codeweavers.com>
Date:   Wed Feb  8 08:07:43 2017 +0100

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

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>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>

---

 winetest/winetest.cgi | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/winetest/winetest.cgi b/winetest/winetest.cgi
index 93906bf..93afee5 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;




More information about the wine-cvs mailing list