From e07e90466b6444f411df58af64183f97d6f35988 Mon Sep 17 00:00:00 2001 From: Thierry Vignaud Date: Sun, 27 Nov 2011 13:06:57 +0000 Subject: (secured_file) ensure that ~/tmp is correctly owned if created callers should probably just use mkstemp in /tmp instead of relying on $TMPDIR || $ENV{HOME}/tmp or we should just move the choice of directory from callers to here, sg like: my $tmpdir = find { -d $_ } $ENV{TMPDIR}, "$ENV{HOME}/tmp", "$::prefix/tmp"; --- perl-install/common.pm | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/perl-install/common.pm b/perl-install/common.pm index 30ef121e2..f0fd6bd08 100644 --- a/perl-install/common.pm +++ b/perl-install/common.pm @@ -264,10 +264,19 @@ sub open_file { open($F, $file) ? $F : do { log::l("Cannot open $file: $!"); undef }; } - +# FIXME: callers should just use mkstemp in /tmp instead of relying on $TMPDIR || $ENV{HOME}/tmp +# or we should just move the choice of directoyr from callers to here: +# my $tmpdir = find { -d $_ } $ENV{TMPDIR}, "$ENV{HOME}/tmp", "$::prefix/tmp"; sub secured_file { my ($f) = @_; - mkdir_p(dirname($f)); + my $d = dirname($f); + if (! -d $d) { + mkdir_p($d); + if ($d =~ /^$ENV{HOME}/) { + my ($user) = grep { $_->[7] eq $ENV{HOME} } list_passwd(); + chown($user->[2], $user->[3], $d); + } + } c::is_secure_file($f) or die "cannot ensure a safe $f"; $f; } -- cgit v1.2.1