public inbox for git@vger.kernel.org 
 help / color / mirror / Atom feed
From: Junio C Hamano <gitster@pobox•com>
To: Christian Couder <christian.couder@gmail•com>
Cc: git@vger•kernel.org, "Ævar Arnfjörð Bjarmason" <avarab@gmail•com>,
	"Michael Haggerty" <mhagger@alum•mit.edu>,
	"Nguyen Thai Ngoc Duy" <pclouds@gmail•com>,
	"Christian Couder" <chriscool@tuxfamily•org>
Subject: Re: [PATCH 1/3] read-cache: use shared perms when writing shared index
Date: Thu, 22 Jun 2017 12:51:54 -0700	[thread overview]
Message-ID: <xmqq8tkjkdgl.fsf@gitster.mtv.corp.google.com> (raw)
In-Reply-To: <20170622190158.13265-1-chriscool@tuxfamily.org> (Christian Couder's message of "Thu, 22 Jun 2017 21:01:56 +0200")

Christian Couder <christian.couder@gmail•com> writes:

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

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

  parent reply	other threads:[~2017-06-22 19:51 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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 ` Junio C Hamano [this message]
2017-06-23 15:14   ` [PATCH 1/3] read-cache: use shared perms when writing shared index 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

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

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=xmqq8tkjkdgl.fsf@gitster.mtv.corp.google.com \
    --to=gitster@pobox$(echo .)com \
    --cc=avarab@gmail$(echo .)com \
    --cc=chriscool@tuxfamily$(echo .)org \
    --cc=christian.couder@gmail$(echo .)com \
    --cc=git@vger$(echo .)kernel.org \
    --cc=mhagger@alum$(echo .)mit.edu \
    --cc=pclouds@gmail$(echo .)com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html
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