diff options
author | Rafael Garcia-Suarez <rgarciasuarez@mandriva.org> | 2005-06-16 01:01:38 +0000 |
---|---|---|
committer | Rafael Garcia-Suarez <rgarciasuarez@mandriva.org> | 2005-06-16 01:01:38 +0000 |
commit | 3e3d964b8581ee68c2efcd7c46d78c693dcb7b79 (patch) | |
tree | 0c8cced6ced1642067415824ad82dd4cb62d462c /Packdrakeng.pm | |
parent | dbcb8beea9a2ee863ec7b043724f3a80607c5f50 (diff) | |
download | rpmtools-3e3d964b8581ee68c2efcd7c46d78c693dcb7b79.tar rpmtools-3e3d964b8581ee68c2efcd7c46d78c693dcb7b79.tar.gz rpmtools-3e3d964b8581ee68c2efcd7c46d78c693dcb7b79.tar.bz2 rpmtools-3e3d964b8581ee68c2efcd7c46d78c693dcb7b79.tar.xz rpmtools-3e3d964b8581ee68c2efcd7c46d78c693dcb7b79.zip |
Create temp file in $TMPDIR instead of $TMP, and warn when creation failed
Diffstat (limited to 'Packdrakeng.pm')
-rw-r--r-- | Packdrakeng.pm | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/Packdrakeng.pm b/Packdrakeng.pm index f46c2b6..ecffd8e 100644 --- a/Packdrakeng.pm +++ b/Packdrakeng.pm @@ -29,14 +29,17 @@ my ($toc_header, $toc_footer) = sub tempfile { my ($count, $fname, $handle) = (0, undef, undef); do { - ++$count > 10 and return (undef, undef); + ++$count > 10 and do { + warn "Can't create temporary file"; + return (undef, undef); + }; $fname = sprintf("%s/packdrakeng.%s.%s", - $ENV{TMP} || '/tmp', + $ENV{TMPDIR} || '/tmp', $$, # Generating an random name join("", map { $_=rand(51); $_ += $_ > 25 && $_ < 32 ? 91 : 65 ; chr($_) } (0 .. 4))); - } while ( ! sysopen($handle, $fname, O_WRONLY | O_APPEND | O_CREAT)); - ($handle, $fname) + } while !sysopen($handle, $fname, O_WRONLY | O_APPEND | O_CREAT); + return ($handle, $fname); } # File::Path hack to not require it |