Skip to content
This repository
Browse code

Merge pull request #1 from fingolfin/scripts-in-tmp

Use File::Temp::tempfile() instead of tmpnam() for temporary script fles.
  • Loading branch information...
commit 52bed09e22ba96cd40d751f1629d69c7863e23bb 2 parents 63ae7d5 + 2b911de
Max Horn authored October 28, 2011

Showing 1 changed file with 4 additions and 5 deletions. Show diff stats Hide diff stats

  1. 9  perlmod/Fink/Services.pm
9  perlmod/Fink/Services.pm
@@ -28,7 +28,7 @@ package Fink::Services;
28 28
 use Fink::Command	qw(&rm_f);
29 29
 use Fink::CLI		qw(&word_wrap &get_term_width &print_breaking_stderr);
30 30
 
31  
-use POSIX qw(:errno_h uname tmpnam);
  31
+use POSIX qw(:errno_h uname);
32 32
 use Fcntl qw(:flock);
33 33
 use Getopt::Long;
34 34
 use Data::Dumper;
@@ -647,10 +647,9 @@ sub prepare_script {
647 647
 		$$script .= "\n" if $$script !~ /\n$/;  # require have trailing newline
648 648
 
649 649
 		# Put the script into a temporary file
650  
-		my $tempfile = tmpnam() or die "unable to get temporary file: $!";
651  
-		open (OUT, ">$tempfile") or die "unable to write to $tempfile: $!";
652  
-		print OUT $$script;
653  
-		close (OUT) or die "an unexpected error occurred closing $tempfile: $!";
  650
+		my ($fh, $tempfile) = tempfile("fink.XXXXX") or die "unable to get temporary file: $!";
  651
+		print $fh $$script;
  652
+		close ($fh) or die "an unexpected error occurred closing $tempfile: $!";
654 653
 		chmod(0755, $tempfile);
655 654
 
656 655
 		# tempfile filename is handle to whole script

0 notes on commit 52bed09

Please sign in to comment.
Something went wrong with that request. Please try again.