diff options
author | Thierry Vignaud <tv@mageia.org> | 2011-11-27 13:06:57 +0000 |
---|---|---|
committer | Thierry Vignaud <tv@mageia.org> | 2011-11-27 13:06:57 +0000 |
commit | e07e90466b6444f411df58af64183f97d6f35988 (patch) | |
tree | dd99d8fe691241c035dca8d3a11c364089862248 | |
parent | ebde9467298155ef92bd6e918640ddd7f97e0243 (diff) | |
download | drakx-e07e90466b6444f411df58af64183f97d6f35988.tar drakx-e07e90466b6444f411df58af64183f97d6f35988.tar.gz drakx-e07e90466b6444f411df58af64183f97d6f35988.tar.bz2 drakx-e07e90466b6444f411df58af64183f97d6f35988.tar.xz drakx-e07e90466b6444f411df58af64183f97d6f35988.zip |
(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";
-rw-r--r-- | perl-install/common.pm | 13 |
1 files 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; } |