summaryrefslogtreecommitdiff
path: root/systems/texlive/tlnet/tlpkg/tlperl/lib/File/Temp.pm
diff options
context:
space:
mode:
Diffstat (limited to 'systems/texlive/tlnet/tlpkg/tlperl/lib/File/Temp.pm')
-rw-r--r--systems/texlive/tlnet/tlpkg/tlperl/lib/File/Temp.pm105
1 files changed, 70 insertions, 35 deletions
diff --git a/systems/texlive/tlnet/tlpkg/tlperl/lib/File/Temp.pm b/systems/texlive/tlnet/tlpkg/tlperl/lib/File/Temp.pm
index 39e15d5c3c..570f25a561 100644
--- a/systems/texlive/tlnet/tlpkg/tlperl/lib/File/Temp.pm
+++ b/systems/texlive/tlnet/tlpkg/tlperl/lib/File/Temp.pm
@@ -1,7 +1,7 @@
-package File::Temp; # git description: v0.2308-7-g3bb4d88
+package File::Temp; # git description: v0.2310-3-gc7148fe
# ABSTRACT: return name and handle of a temporary file safely
-our $VERSION = '0.2309';
+our $VERSION = '0.2311';
#pod =begin :__INTERNALS
#pod
@@ -307,6 +307,7 @@ my %FILES_CREATED_BY_OBJECT;
# use of the O_TEMPORARY flag to sysopen.
# Usually irrelevant on unix
# "use_exlock" => Indicates that O_EXLOCK should be used. Default is false.
+# "file_permissions" => file permissions for sysopen(). Default is 0600.
# Optionally a reference to a scalar can be passed into the function
# On error this will be used to store the reason for the error
@@ -339,12 +340,13 @@ sub _gettemp {
# Default options
my %options = (
- "open" => 0,
- "mkdir" => 0,
- "suffixlen" => 0,
- "unlink_on_close" => 0,
- "use_exlock" => 0,
- "ErrStr" => \$tempErrStr,
+ "open" => 0,
+ "mkdir" => 0,
+ "suffixlen" => 0,
+ "unlink_on_close" => 0,
+ "use_exlock" => 0,
+ "ErrStr" => \$tempErrStr,
+ "file_permissions" => undef,
);
# Read the template
@@ -480,6 +482,9 @@ sub _gettemp {
}
}
+ my $perms = $options{file_permissions};
+ my $has_perms = defined $perms;
+ $perms = 0600 unless $has_perms;
# Now try MAX_TRIES time to open the file
for (my $i = 0; $i < MAX_TRIES; $i++) {
@@ -502,19 +507,19 @@ sub _gettemp {
my $open_success = undef;
if ( $^O eq 'VMS' and $options{"unlink_on_close"} && !$KEEP_ALL) {
# make it auto delete on close by setting FAB$V_DLT bit
- $fh = VMS::Stdio::vmssysopen($path, $OPENFLAGS, 0600, 'fop=dlt');
+ $fh = VMS::Stdio::vmssysopen($path, $OPENFLAGS, $perms, 'fop=dlt');
$open_success = $fh;
} else {
my $flags = ( ($options{"unlink_on_close"} && !$KEEP_ALL) ?
$OPENTEMPFLAGS :
$OPENFLAGS );
$flags |= $LOCKFLAG if (defined $LOCKFLAG && $options{use_exlock});
- $open_success = sysopen($fh, $path, $flags, 0600);
+ $open_success = sysopen($fh, $path, $flags, $perms);
}
if ( $open_success ) {
# in case of odd umask force rw
- chmod(0600, $path);
+ chmod($perms, $path) unless $has_perms;
# Opened successfully - return file handle and name
return ($fh, $path);
@@ -799,7 +804,7 @@ sub _is_verysafe {
sub _can_unlink_opened_file {
- if (grep { $^O eq $_ } qw/MSWin32 os2 VMS dos MacOS haiku/) {
+ if (grep $^O eq $_, qw/MSWin32 os2 VMS dos MacOS haiku/) {
return 0;
} else {
return 1;
@@ -999,7 +1004,7 @@ sub _can_do_level {
sub _parse_args {
my $leading_template = (scalar(@_) % 2 == 1 ? shift(@_) : '' );
my %args = @_;
- %args = map { uc($_), $args{$_} } keys %args;
+ %args = map +(uc($_) => $args{$_}), keys %args;
# template (store it in an array so that it will
# disappear from the arg list of tempfile)
@@ -1048,7 +1053,8 @@ sub _parse_args {
#pod if UNLINK is set to true (the default).
#pod
#pod Supported arguments are the same as for C<tempfile>: UNLINK
-#pod (defaulting to true), DIR, EXLOCK and SUFFIX. Additionally, the filename
+#pod (defaulting to true), DIR, EXLOCK, PERMS and SUFFIX.
+#pod Additionally, the filename
#pod template is specified using the TEMPLATE option. The OPEN option
#pod is not supported (the file is always opened).
#pod
@@ -1359,6 +1365,11 @@ sub DESTROY {
#pod
#pod ($fh, $filename) = tempfile($template, EXLOCK => 1);
#pod
+#pod By default, the temp file is created with 0600 file permissions.
+#pod Use C<PERMS> to change this:
+#pod
+#pod ($fh, $filename) = tempfile($template, PERMS => 0666);
+#pod
#pod Options can be combined as required.
#pod
#pod Will croak() if there is an error.
@@ -1371,6 +1382,8 @@ sub DESTROY {
#pod
#pod EXLOCK flag available since 0.19.
#pod
+#pod PERMS flag available since 0.2310.
+#pod
#pod =cut
sub tempfile {
@@ -1386,8 +1399,9 @@ sub tempfile {
"SUFFIX" => '', # Template suffix
"UNLINK" => 0, # Do not unlink file on exit
"OPEN" => 1, # Open file
- "TMPDIR" => 0, # Place tempfile in tempdir if template specified
- "EXLOCK" => 0, # Open file with O_EXLOCK
+ "TMPDIR" => 0, # Place tempfile in tempdir if template specified
+ "EXLOCK" => 0, # Open file with O_EXLOCK
+ "PERMS" => undef, # File permissions
);
# Check to see whether we have an odd or even number of arguments
@@ -1464,12 +1478,13 @@ sub tempfile {
my ($fh, $path, $errstr);
croak "Error in tempfile() using template $template: $errstr"
unless (($fh, $path) = _gettemp($template,
- "open" => $options{'OPEN'},
- "mkdir"=> 0 ,
- "unlink_on_close" => $unlink_on_close,
- "suffixlen" => length($options{'SUFFIX'}),
- "ErrStr" => \$errstr,
- "use_exlock" => $options{EXLOCK},
+ "open" => $options{OPEN},
+ "mkdir" => 0,
+ "unlink_on_close" => $unlink_on_close,
+ "suffixlen" => length($options{SUFFIX}),
+ "ErrStr" => \$errstr,
+ "use_exlock" => $options{EXLOCK},
+ "file_permissions" => $options{PERMS},
) );
# Set up an exit handler that can do whatever is right for the
@@ -2581,7 +2596,7 @@ sub unlink1 {
package ## hide from PAUSE
File::Temp::Dir;
-our $VERSION = '0.2309';
+our $VERSION = '0.2311';
use File::Path qw/ rmtree /;
use strict;
@@ -2648,7 +2663,7 @@ File::Temp - return name and handle of a temporary file safely
=head1 VERSION
-version 0.2309
+version 0.2311
=head1 SYNOPSIS
@@ -2819,7 +2834,8 @@ that the temporary file is removed by the object destructor
if UNLINK is set to true (the default).
Supported arguments are the same as for C<tempfile>: UNLINK
-(defaulting to true), DIR, EXLOCK and SUFFIX. Additionally, the filename
+(defaulting to true), DIR, EXLOCK, PERMS and SUFFIX.
+Additionally, the filename
template is specified using the TEMPLATE option. The OPEN option
is not supported (the file is always opened).
@@ -3004,6 +3020,11 @@ versions, explicitly set C<< EXLOCK=>0 >>.
($fh, $filename) = tempfile($template, EXLOCK => 1);
+By default, the temp file is created with 0600 file permissions.
+Use C<PERMS> to change this:
+
+ ($fh, $filename) = tempfile($template, PERMS => 0666);
+
Options can be combined as required.
Will croak() if there is an error.
@@ -3016,6 +3037,8 @@ TMPDIR flag available since 0.19.
EXLOCK flag available since 0.19.
+PERMS flag available since 0.2310.
+
=item B<tempdir>
This is the recommended interface for creation of temporary
@@ -3606,13 +3629,13 @@ Tim Jenness <tjenness@cpan.org>
=head1 CONTRIBUTORS
-=for stopwords David Golden Karen Etheridge Slaven Rezic Peter Rabbitson Olivier Mengue Kevin Ryde John Acklam James E. Keenan Brian Mowrey Dagfinn Ilmari Mannsåker Steinbrunner Ed Avis Guillem Jover Ben Tilly
+=for stopwords Tim Jenness Karen Etheridge David Golden Slaven Rezic mohawk2 Roy Ivy III Peter Rabbitson Olivier Mengué John Acklam Gim Yee Nicolas R Brian Mowrey Dagfinn Ilmari Mannsåker Steinbrunner Ed Avis Guillem Jover James E. Keenan Kevin Ryde Ben Tilly
=over 4
=item *
-David Golden <dagolden@cpan.org>
+Tim Jenness <t.jenness@jach.hawaii.edu>
=item *
@@ -3620,23 +3643,27 @@ Karen Etheridge <ether@cpan.org>
=item *
-Slaven Rezic <slaven@rezic.de>
+David Golden <dagolden@cpan.org>
=item *
-Peter Rabbitson <ribasushi@cpan.org>
+Slaven Rezic <srezic@cpan.org>
=item *
-Olivier Mengue <dolmen@cpan.org>
+mohawk2 <mohawk2@users.noreply.github.com>
=item *
-David Golden <xdg@xdg.me>
+Roy Ivy III <rivy.dev@gmail.com>
=item *
-Kevin Ryde <user42@zip.com.au>
+Peter Rabbitson <ribasushi@cpan.org>
+
+=item *
+
+Olivier Mengué <dolmen@cpan.org>
=item *
@@ -3644,11 +3671,11 @@ Peter John Acklam <pjacklam@online.no>
=item *
-Slaven Rezic <slaven.rezic@idealo.de>
+Tim Gim Yee <tim.gim.yee@gmail.com>
=item *
-James E. Keenan <jkeen@verizon.net>
+Nicolas R <atoomic@cpan.org>
=item *
@@ -3672,13 +3699,21 @@ Guillem Jover <guillem@hadrons.org>
=item *
+James E. Keenan <jkeen@verizon.net>
+
+=item *
+
+Kevin Ryde <user42@zip.com.au>
+
+=item *
+
Ben Tilly <btilly@gmail.com>
=back
=head1 COPYRIGHT AND LICENSE
-This software is copyright (c) 2019 by Tim Jenness and the UK Particle Physics and Astronomy Research Council.
+This software is copyright (c) 2020 by Tim Jenness and the UK Particle Physics and Astronomy Research Council.
This is free software; you can redistribute it and/or modify it under
the same terms as the Perl 5 programming language system itself.