From: Eric Wong <e@80x24.org>
To: meta@public-inbox.org
Subject: [PATCH 1/5] init: preserve permissions for git prior to 2.1.0
Date: Wed, 22 May 2019 02:13:58 +0000 [thread overview]
Message-ID: <20190522021402.24114-2-e@80x24.org> (raw)
In-Reply-To: <20190522021402.24114-1-e@80x24.org>
"git config" did not preserve permissions of the config file it
modifies prior to git 2.1.0, so workaround that.
---
script/public-inbox-init | 12 +++++++++++-
1 file changed, 11 insertions(+), 1 deletion(-)
diff --git a/script/public-inbox-init b/script/public-inbox-init
index 5516e79..2cc704c 100755
--- a/script/public-inbox-init
+++ b/script/public-inbox-init
@@ -38,10 +38,11 @@ my $pi_config = PublicInbox::Config->default_file;
my $dir = dirname($pi_config);
mkpath($dir); # will croak on fatal errors
my ($fh, $pi_config_tmp) = tempfile('pi-init-XXXXXXXX', DIR => $dir);
+my $perm;
if (-e $pi_config) {
open(my $oh, '<', $pi_config) or die "unable to read $pi_config: $!\n";
my @st = stat($oh);
- my $perm = $st[2];
+ $perm = $st[2];
defined $perm or die "(f)stat failed on $pi_config: $!\n";
chmod($perm & 07777, $fh) or
die "(f)chmod failed on future $pi_config: $!\n";
@@ -125,6 +126,9 @@ if ($version >= 2) {
die "Unsupported -V/--version: $version\n";
}
+# needed for git prior to v2.1.0
+umask(0077) if defined $perm;
+
foreach my $addr (@address) {
next if $seen{lc($addr)};
x(@x, "--add", "$pfx.address", $addr);
@@ -136,5 +140,11 @@ if (defined($indexlevel)) {
x(@x, "$pfx.indexlevel", $indexlevel);
}
+# 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";
+}
+
rename $pi_config_tmp, $pi_config or
die "failed to rename `$pi_config_tmp' to `$pi_config': $!\n";
--
EW
next prev parent reply other threads:[~2019-05-22 2:14 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-05-22 2:13 [PATCH 0/5] fixes for CentOS 7 Eric Wong
2019-05-22 2:13 ` Eric Wong [this message]
2019-05-22 2:13 ` [PATCH 2/5] t/watch_filter_rubylang: disable v2 test for git < 2.6 Eric Wong
2019-05-22 2:14 ` [PATCH 3/5] git: workaround old git-rev-parse(1) (--git-path) Eric Wong
2019-05-22 2:14 ` [PATCH 4/5] t/search*: require DBI and DBD::SQLite, too Eric Wong
2019-05-22 2:14 ` [PATCH 5/5] ci: support CentOS-7 Eric Wong
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://public-inbox.org/README
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20190522021402.24114-2-e@80x24.org \
--to=e@80x24.org \
--cc=meta@public-inbox.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).