about summary refs log tree commit homepage
path: root/lib
diff options
context:
space:
mode:
authorEric Wong (Contractor, The Linux Foundation) <e@80x24.org>2018-03-30 17:46:31 +0000
committerEric Wong (Contractor, The Linux Foundation) <e@80x24.org>2018-03-30 20:49:31 +0000
commitc4aa293b2320feb805c5afeaa373f608e5bc8618 (patch)
tree08413ea414cbf561d4246b0254d00e899f7ff6b3 /lib
parentf1a3ece0df6825792f1ec0ca326998c8915fd80d (diff)
downloadpublic-inbox-c4aa293b2320feb805c5afeaa373f608e5bc8618.tar.gz
Ensure -convert and -compact do not make repositories
unreadable on live servers.
Diffstat (limited to 'lib')
-rw-r--r--lib/PublicInbox/InboxWritable.pm5
-rw-r--r--lib/PublicInbox/V2Writable.pm26
2 files changed, 16 insertions, 15 deletions
diff --git a/lib/PublicInbox/InboxWritable.pm b/lib/PublicInbox/InboxWritable.pm
index 92b9016e..5c11a36c 100644
--- a/lib/PublicInbox/InboxWritable.pm
+++ b/lib/PublicInbox/InboxWritable.pm
@@ -168,10 +168,7 @@ sub import_mbox {
 sub _read_git_config_perm {
         my ($self) = @_;
         my @cmd = qw(config);
-        if (($self->{version} ||= 1) == 2) {
-                push @cmd, "--file=$self->{mainrepo}/all.git/config";
-        }
-        chomp(my $perm = $self->git->qx(@cmd, 'core.sharedRepository'));
+        chomp(my $perm = $self->git->qx('config', 'core.sharedRepository'));
         $perm;
 }
 
diff --git a/lib/PublicInbox/V2Writable.pm b/lib/PublicInbox/V2Writable.pm
index 34f13e26..c4368ccc 100644
--- a/lib/PublicInbox/V2Writable.pm
+++ b/lib/PublicInbox/V2Writable.pm
@@ -50,6 +50,7 @@ sub new {
         }
         $nparts = nproc() if ($nparts == 0);
 
+        $v2ibx = PublicInbox::InboxWritable->new($v2ibx);
         my $self = {
                 -inbox => $v2ibx,
                 im => undef, #  PublicInbox::Import
@@ -193,20 +194,23 @@ sub idx_init {
         # frequently activated.
         delete $ibx->{$_} foreach (qw(git mm search));
 
-        $self->lock_acquire;
+        $ibx->umask_prepare;
+        $ibx->with_umask(sub {
+                $self->lock_acquire;
 
-        # first time initialization, first we create the skeleton pipe:
-        my $skel = $self->{skel} = PublicInbox::SearchIdxSkeleton->new($self);
+                # first time initialization, first we create the skeleton pipe:
+                my $skel = PublicInbox::SearchIdxSkeleton->new($self);
+                $self->{skel} = $skel;
 
-        # need to create all parts before initializing msgmap FD
-        my $max = $self->{partitions} - 1;
-        my $idx = $self->{idx_parts} = [];
-        for my $i (0..$max) {
-                push @$idx, PublicInbox::SearchIdxPart->new($self, $i, $skel);
-        }
+                # need to create all parts before initializing msgmap FD
+                my $max = $self->{partitions} - 1;
+                @{$self->{idx_parts}} = map {
+                        PublicInbox::SearchIdxPart->new($self, $_, $skel);
+                } (0..$max);
 
-        # Now that all subprocesses are up, we can open the FD for SQLite:
-        $skel->_msgmap_init->{dbh}->begin_work;
+                # Now that all subprocesses are up, we can open the FD for SQLite:
+                $skel->_msgmap_init->{dbh}->begin_work;
+        });
 }
 
 sub purge_oids {