git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH 1/3] read-cache: use shared perms when writing shared index

From
Junio C Hamano <gitster@pobox.com>
Date
Jun 22, 2017, 19:51 UTC
Message-ID
<xmqq8tkjkdgl.fsf@gitster.mtv.corp.google.com>
In-Reply-To
<20170622190158.13265-1-chriscool@tuxfamily.org>
Christian Couder <christian.couder@gmail.com> writes:
Show 15 quoted lines
> 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.

Assuming that a "shared" repository setting should allow uses by different users, the above analysis makes sense to me.

But the conclusion does not.
Show 6 quoted lines
> Let's fix that by using create_tempfile() instead of mks_tempfile()
> to create the shared index file.
>
> ...
> -	fd = mks_tempfile(&temporary_sharedindex, git_path("sharedindex_XXXXXX"));
> +	fd = create_tempfile(&temporary_sharedindex, git_path("sharedindex_XXXXXX"));

So we used to create a temporary file that made sure its name is unique but now we create sharedindex_XXXXXX with 6 X's literally at the end?

Doesn't mks_tempfile() family include a variant where you can give custom mode? Better yet, perhaps you can call adjust_shared_perm() on the path _after_ seeing that mks_tempfile() succeeds (you can ask get_tempfile_path() which path to adjust, I presume)?

>  	if (fd < 0) {
>  		hashclr(si->base_sha1);
>  		return do_write_locked_index(istate, lock, flags);
Previous: Christian CouderNext: Christian Couder
Message 12 of 22 in “read-cache: use shared perms when writing shared index”
  1. 1/3 read-cache: use shared perms when writing shared indexChristian Couder, Jun 22, 2017
  2. 2/3 t1301: move movebits() to test-lib-functions.shChristian Couder, Jun 22, 2017
  3. Junio C HamanoJun 22, 2017
  4. Ramsay JonesJun 22, 2017
  5. Junio C HamanoJun 23, 2017
  6. Christian CouderJun 23, 2017
  7. 3/3 t1700: make sure split-index respects core.sharedrepositoryChristian Couder, Jun 22, 2017
  8. Junio C HamanoJun 22, 2017
  9. Christian CouderJun 22, 2017
  10. Junio C HamanoJun 22, 2017
  11. Christian CouderJun 22, 2017
  12. Junio C HamanoJun 22, 2017
  13. Christian CouderJun 23, 2017
  14. Ævar Arnfjörð BjarmasonNov 13, 2018
  15. read-cache: write all indexes with the same permissionsÆvar Arnfjörð Bjarmason, Nov 13, 2018
  16. Duy NguyenNov 13, 2018
  17. Ævar Arnfjörð BjarmasonNov 13, 2018
  18. Christian CouderNov 16, 2018
  19. SZEDER GáborNov 16, 2018
  20. Duy NguyenNov 16, 2018
  21. Christian CouderNov 17, 2018
  22. SZEDER GáborNov 17, 2018

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.