summaryrefslogtreecommitdiffstats
path: root/perl-install/common.pm
diff options
context:
space:
mode:
authorThierry Vignaud <tv@mageia.org>2011-11-27 11:24:48 +0000
committerThierry Vignaud <tv@mageia.org>2011-11-27 11:24:48 +0000
commit18d5cd2d2f37019efd9341a300bfbb82c6a0841d (patch)
treee8f718ee732cae5cec61d1bc3f69bff06d4a2556 /perl-install/common.pm
parentb82b02fece7f4884848fecb34cc48c734ed12d55 (diff)
downloaddrakx-18d5cd2d2f37019efd9341a300bfbb82c6a0841d.tar
drakx-18d5cd2d2f37019efd9341a300bfbb82c6a0841d.tar.gz
drakx-18d5cd2d2f37019efd9341a300bfbb82c6a0841d.tar.bz2
drakx-18d5cd2d2f37019efd9341a300bfbb82c6a0841d.tar.xz
drakx-18d5cd2d2f37019efd9341a300bfbb82c6a0841d.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 directoyr from callers to here, sg like: my $tmpdir = find { -d $_ } $ENV{TMPDIR}, "$ENV{HOME}/tmp", "$::prefix/tmp";
Diffstat (limited to 'perl-install/common.pm')
-rw-r--r--perl-install/common.pm13
1 files changed, 11 insertions, 2 deletions
diff --git a/perl-install/common.pm b/perl-install/common.pm
index c30abc9d1..adaa07a0d 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;
}