#!perl -w
-# Copyright (C) 2014-2021 all contributors <meta@public-inbox.org>
+# Copyright (C) all contributors <meta@public-inbox.org>
# License: AGPL-3.0+ <https://www.gnu.org/licenses/agpl-3.0.txt>
use strict;
use v5.10.1;
};
require PublicInbox::OnDestroy;
my $auto_unlink = PublicInbox::OnDestroy->new($$, sub { unlink $lockfile });
-my ($perm, %seen);
+my $perm = 0644 & ~umask;
+my %seen;
if (-e $pi_config) {
open(my $oh, '<', $pi_config) or die "unable to read $pi_config: $!\n";
my @st = stat($oh);
}
# needed for git prior to v2.1.0
-umask(0077) if defined $perm;
+umask(0077);
require PublicInbox::Spawn;
PublicInbox::Spawn->import(qw(run_die));
}
# needed for git prior to v2.1.0
-if (defined $perm) {
- chmod($perm & 07777, $pi_config_tmp) or
- die "(f)chmod failed on future $pi_config: $!\n";
-}
+chmod($perm & 07777, $pi_config_tmp) or
+ die "(f)chmod failed on future $pi_config: $!\n";
rename $pi_config_tmp, $pi_config or
die "failed to rename `$pi_config_tmp' to `$pi_config': $!\n";
my $cfgfile = "$ENV{PI_DIR}/config";
my $cmd = [ '-init', 'blist', "$tmpdir/blist",
qw(http://example.com/blist blist@example.com) ];
+ my $umask = umask(070) // xbail "umask: $!";
ok(run_script($cmd), 'public-inbox-init OK');
+ umask($umask) // xbail "umask: $!";
+ my $mode = (stat($cfgfile))[2];
+ is(sprintf('0%03o', $mode & 0777), '0604', 'config respects umask');
is(read_indexlevel('blist'), '', 'indexlevel unset by default');