summaryrefslogtreecommitdiffstats
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
commit8b002c23010ae6c58a99a8dcd5830f0ba44ac79d (patch)
treee8f718ee732cae5cec61d1bc3f69bff06d4a2556
parentb74bdd4a160dc043d7836a4e5baa6853987d0244 (diff)
downloaddrakx-backup-do-not-use-8b002c23010ae6c58a99a8dcd5830f0ba44ac79d.tar
drakx-backup-do-not-use-8b002c23010ae6c58a99a8dcd5830f0ba44ac79d.tar.gz
drakx-backup-do-not-use-8b002c23010ae6c58a99a8dcd5830f0ba44ac79d.tar.bz2
drakx-backup-do-not-use-8b002c23010ae6c58a99a8dcd5830f0ba44ac79d.tar.xz
drakx-backup-do-not-use-8b002c23010ae6c58a99a8dcd5830f0ba44ac79d.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";
-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;
}