diff options
author | Marc Espie <espie@cvs.openbsd.org> | 2007-05-07 09:32:52 +0000 |
---|---|---|
committer | Marc Espie <espie@cvs.openbsd.org> | 2007-05-07 09:32:52 +0000 |
commit | d033b65043484e321e35a09517cb5c38a26bf098 (patch) | |
tree | e4e54b4818153d00fff1ed4f1812ab978484a159 /usr.sbin | |
parent | 665a629eb40eb52026e905ec70f149459db5732a (diff) |
make sure all temporary file handling goes through OpenBSD::Temp
Diffstat (limited to 'usr.sbin')
-rw-r--r-- | usr.sbin/pkg_add/OpenBSD/Delete.pm | 6 | ||||
-rw-r--r-- | usr.sbin/pkg_add/OpenBSD/PackageRepository.pm | 8 | ||||
-rw-r--r-- | usr.sbin/pkg_add/OpenBSD/Replace.pm | 7 | ||||
-rw-r--r-- | usr.sbin/pkg_add/OpenBSD/Temp.pm | 12 |
4 files changed, 20 insertions, 13 deletions
diff --git a/usr.sbin/pkg_add/OpenBSD/Delete.pm b/usr.sbin/pkg_add/OpenBSD/Delete.pm index 53d794b5bc0..eeeaba7d43c 100644 --- a/usr.sbin/pkg_add/OpenBSD/Delete.pm +++ b/usr.sbin/pkg_add/OpenBSD/Delete.pm @@ -1,5 +1,5 @@ # ex:ts=8 sw=4: -# $OpenBSD: Delete.pm,v 1.40 2007/05/07 08:34:09 espie Exp $ +# $OpenBSD: Delete.pm,v 1.41 2007/05/07 09:32:51 espie Exp $ # # Copyright (c) 2003-2007 Marc Espie <espie@openbsd.org> # @@ -27,11 +27,11 @@ use File::Basename; sub rename_file_to_temp { my $i = shift; - require File::Temp; + require OpenBSD::Temp; my $n = $i->fullname(); - my ($fh, $j) = File::Temp::mkstemp("$n.XXXXXXXX"); + my ($fh, $j) = OpenBSD::Temp::permanent_file(undef, $n); close $fh; if (rename($n, $j)) { print "Renaming old file $n to $j\n"; diff --git a/usr.sbin/pkg_add/OpenBSD/PackageRepository.pm b/usr.sbin/pkg_add/OpenBSD/PackageRepository.pm index 021f11e77da..1e7f0e108d6 100644 --- a/usr.sbin/pkg_add/OpenBSD/PackageRepository.pm +++ b/usr.sbin/pkg_add/OpenBSD/PackageRepository.pm @@ -1,5 +1,5 @@ # ex:ts=8 sw=4: -# $OpenBSD: PackageRepository.pm,v 1.16 2007/05/02 15:05:30 espie Exp $ +# $OpenBSD: PackageRepository.pm,v 1.17 2007/05/07 09:32:51 espie Exp $ # # Copyright (c) 2003-2006 Marc Espie <espie@openbsd.org> # @@ -356,13 +356,11 @@ sub pkg_copy { my ($self, $in, $object) = @_; - require File::Temp; + require OpenBSD::Temp; my $name = $object->{name}; my $dir = $object->{cache_dir}; - my $template = "$name.XXXXXXXXX"; - my ($copy, $filename) = File::Temp::tempfile($template, - DIR => $dir) or die "Can't write copy to cache"; + my ($copy, $filename) = OpenBSD::Temp::permanent_file($dir, $name) or die "Can't write copy to cache"; chmod 0644, $filename; $object->{tempname} = $filename; my $handler = sub { diff --git a/usr.sbin/pkg_add/OpenBSD/Replace.pm b/usr.sbin/pkg_add/OpenBSD/Replace.pm index bbf7cbfd5ba..49e016cde1d 100644 --- a/usr.sbin/pkg_add/OpenBSD/Replace.pm +++ b/usr.sbin/pkg_add/OpenBSD/Replace.pm @@ -1,5 +1,5 @@ # ex:ts=8 sw=4: -# $OpenBSD: Replace.pm,v 1.8 2007/05/07 08:24:16 espie Exp $ +# $OpenBSD: Replace.pm,v 1.9 2007/05/07 09:32:51 espie Exp $ # # Copyright (c) 2004-2006 Marc Espie <espie@openbsd.org> # @@ -53,7 +53,7 @@ sub unmark_lib } package OpenBSD::PackingElement::FileBase; -use File::Temp qw/tempfile/; +use OpenBSD::Temp; sub extract { @@ -77,8 +77,7 @@ sub extract if (!-e _) { File::Path::mkpath($d); } - my ($fh, $tempname) = tempfile('pkg.XXXXXXXXXX', - DIR => $d); + my ($fh, $tempname) = OpenBSD::Temp::permanent_file($d, "pkg"); print "extracting $tempname\n" if $state->{very_verbose}; $file->{name} = $tempname; diff --git a/usr.sbin/pkg_add/OpenBSD/Temp.pm b/usr.sbin/pkg_add/OpenBSD/Temp.pm index 565b9ad2443..105ba520a52 100644 --- a/usr.sbin/pkg_add/OpenBSD/Temp.pm +++ b/usr.sbin/pkg_add/OpenBSD/Temp.pm @@ -1,5 +1,5 @@ # ex:ts=8 sw=4: -# $OpenBSD: Temp.pm,v 1.7 2007/04/15 10:17:29 espie Exp $ +# $OpenBSD: Temp.pm,v 1.8 2007/05/07 09:32:51 espie Exp $ # # Copyright (c) 2003-2005 Marc Espie <espie@openbsd.org> # @@ -90,4 +90,14 @@ sub list($) return File::Temp::tempfile("list.XXXXXXXXXXX", DIR => shift); } +sub permanent_file +{ + my ($dir, $stem) = @_; + my $template = "$stem.XXXXXXXXXX"; + if (defined $dir) { + $template = "$dir/$template"; + } + return File::Temp::mkstemp($template); +} + 1; |