git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
* [PATCH 1/3] read-cache: use shared perms when writing shared index
@ 2017-06-22 19:01 Christian Couder
  2017-06-22 19:01 ` [PATCH 2/3] t1301: move movebits() to test-lib-functions.sh Christian Couder
                   ` (2 more replies)
  0 siblings, 3 replies; 22+ messages in thread
From: Christian Couder @ 2017-06-22 19:01 UTC (permalink / raw)
  To: git
  Cc: Junio C Hamano, Ævar Arnfjörð Bjarmason,
	Michael Haggerty, Nguyen Thai Ngoc Duy, Christian Couder

Since f6ecc62dbf (write_shared_index(): use tempfile module, 2015-08-10)
write_shared_index() has been using mks_tempfile() to create the
temporary file that will become the shared index.

But even before that, it looks like the functions used to create this
file didn't call adjust_shared_perm(), which means that the shared
index file has always been created with 600 permissions regardless
of the shared permission settings.

This means that on repositories created with `git init --shared=all`
and using the split index feature one gets an error like:

fatal: .git/sharedindex.a52f910b489bc462f187ab572ba0086f7b5157de: index file open failed: Permission denied

when another user performs any operation that reads the shared index.

Let's fix that by using create_tempfile() instead of mks_tempfile()
to create the shared index file.

Signed-off-by: Christian Couder <chriscool@tuxfamily.org>
---
 read-cache.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/read-cache.c b/read-cache.c
index bc156a133e..eb71e93aa4 100644
--- a/read-cache.c
+++ b/read-cache.c
@@ -2414,7 +2414,7 @@ static int write_shared_index(struct index_state *istate,
 	struct split_index *si = istate->split_index;
 	int fd, ret;
 
-	fd = mks_tempfile(&temporary_sharedindex, git_path("sharedindex_XXXXXX"));
+	fd = create_tempfile(&temporary_sharedindex, git_path("sharedindex_XXXXXX"));
 	if (fd < 0) {
 		hashclr(si->base_sha1);
 		return do_write_locked_index(istate, lock, flags);
-- 
2.13.1.516.g05ec6e13aa


^ permalink raw reply related	[flat|nested] 22+ messages in thread

end of thread, other threads:[~2018-11-17 12:47 UTC | newest]

Thread overview: 22+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-06-22 19:01 [PATCH 1/3] read-cache: use shared perms when writing shared index Christian Couder
2017-06-22 19:01 ` [PATCH 2/3] t1301: move movebits() to test-lib-functions.sh Christian Couder
2017-06-22 19:52   ` Junio C Hamano
2017-06-22 23:09     ` Ramsay Jones
2017-06-23  5:31       ` Junio C Hamano
2017-06-23 15:12       ` Christian Couder
2017-06-22 19:01 ` [PATCH 3/3] t1700: make sure split-index respects core.sharedrepository Christian Couder
2017-06-22 19:53   ` Junio C Hamano
2017-06-22 20:19     ` Christian Couder
2017-06-22 20:25       ` Junio C Hamano
2017-06-22 21:07         ` Christian Couder
2017-06-22 19:51 ` [PATCH 1/3] read-cache: use shared perms when writing shared index Junio C Hamano
2017-06-23 15:14   ` Christian Couder
2018-11-13 15:22   ` Ævar Arnfjörð Bjarmason
2018-11-13 15:32     ` [RFC/PATCH] read-cache: write all indexes with the same permissions Ævar Arnfjörð Bjarmason
2018-11-13 16:55       ` Duy Nguyen
2018-11-13 17:34         ` Ævar Arnfjörð Bjarmason
2018-11-16 17:41           ` Christian Couder
2018-11-16 19:07             ` SZEDER Gábor
2018-11-16 19:19               ` Duy Nguyen
2018-11-17  6:52                 ` Christian Couder
2018-11-17 12:38                   ` SZEDER Gábor

Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

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).