Commit b8a86a6a authored by Leigh B Stoller's avatar Leigh B Stoller
Browse files

Stop leaving temp files behind.

parent 2b42f5ec
...@@ -25,7 +25,7 @@ use English; ...@@ -25,7 +25,7 @@ use English;
use strict; use strict;
use Getopt::Std; use Getopt::Std;
use XML::Simple; use XML::Simple;
use File::Temp qw(tempfile :POSIX ); use File::Temp qw(tempfile :mktemp :POSIX);
use Data::Dumper; use Data::Dumper;
use CGI; use CGI;
use POSIX ":sys_wait_h"; use POSIX ":sys_wait_h";
...@@ -638,7 +638,7 @@ sub ModifyProfileInternal($$$) ...@@ -638,7 +638,7 @@ sub ModifyProfileInternal($$$)
# For a Parameterized Profile, need to generate and store the form # For a Parameterized Profile, need to generate and store the form
# data. Only python scripts of course. # data. Only python scripts of course.
# #
my ($fh, $filename) = tempfile(); my ($fh, $filename) = tempfile(UNLINK => 1);
if (!defined($fh)) { if (!defined($fh)) {
$$pmsg = "Could not open temporary file for script"; $$pmsg = "Could not open temporary file for script";
return -1; return -1;
...@@ -890,7 +890,7 @@ sub UpdateProfileFromRepo() ...@@ -890,7 +890,7 @@ sub UpdateProfileFromRepo()
# Convert the script. If it fails we are not going to change the profile. # Convert the script. If it fails we are not going to change the profile.
# #
if (defined($script)) { if (defined($script)) {
my ($fh, $filename) = tempfile(); my ($fh, $filename) = tempfile(UNLINK => 1);
if (!defined($fh)) { if (!defined($fh)) {
$profile->Unlock(); $profile->Unlock();
fatal("Could not open temporary file for script"); fatal("Could not open temporary file for script");
...@@ -948,7 +948,7 @@ sub HandleScript($) ...@@ -948,7 +948,7 @@ sub HandleScript($)
return undef return undef
if ($script !~ /^import/m); if ($script !~ /^import/m);
my ($fh, $filename) = tempfile(); my ($fh, $filename) = tempfile(UNLINK => 1);
fatal("Could not open temporary file for script") fatal("Could not open temporary file for script")
if (!defined($fh)); if (!defined($fh));
print $fh $script; print $fh $script;
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment