From patchwork Sun Nov 18 19:04:29 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= X-Patchwork-Id: 10688015 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id A174A15A7 for ; Sun, 18 Nov 2018 19:04:42 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 8433628FB8 for ; Sun, 18 Nov 2018 19:04:42 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 74ADD29385; Sun, 18 Nov 2018 19:04:42 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C1CDF28FB8 for ; Sun, 18 Nov 2018 19:04:41 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1725812AbeKSFZo (ORCPT ); Mon, 19 Nov 2018 00:25:44 -0500 Received: from mail-wm1-f67.google.com ([209.85.128.67]:40296 "EHLO mail-wm1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725800AbeKSFZn (ORCPT ); Mon, 19 Nov 2018 00:25:43 -0500 Received: by mail-wm1-f67.google.com with SMTP id q26so3182454wmf.5 for ; Sun, 18 Nov 2018 11:04:39 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=zh9nhdgB/pWsQCooUfn625BBA+tTw/23WGjZ96VuWF0=; b=hrM726OVOOUd7MimNhzlj/KHbep81Py/Zn/zwP8EnP3MCtbBQ2YTI6cESKqK/bDjur BIq9YOWlunOOm5aK1c4hdsDhXPY/6e5kmzpAr1paldUzfD2z+2a/26yLDXkTk/5GAX4g dZPOCD4UBAEf8aZ8AG+iCzGfNKhXupSIXMyjVND2MI7zjRNHtQxILpiQfbIFymxiTr/Y DvIVqnwcNB+jbc1iePVXWEWgBsce7yrXQP+TrbHGVN1niuab9iXhKXw8QkedCyAvrAKB /cH6aWH6asvXo4ksKcFktbcgwS1HOOmrSd6nS1Il8S267SxpiY94CGxDOHVKAFVkBrgb 5oWQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=zh9nhdgB/pWsQCooUfn625BBA+tTw/23WGjZ96VuWF0=; b=l1ENW/sOR+0pG64k+V8mdFd4aBBlCtHM1J60drk48xZb8RdzxfFk3xBNfePqHkRgq/ d59Wby6NSrdBskvzU8A9VKV52+OzF5KAggcZILYBAYtogH+XBWRVfYWDEVokxpiVjr5u Y+dHzXTkxXCSoLldM8wUCzpMCG1LvxhaZhs3JS2xSGQKTPv3Kdj7wXpd26mQws9Vk8XD YTORkcT7xZaRyBGzmj5/VFFTBrChMnoJkaMYLq+bikOv5HtIeDtK5Avpl1azW1foEj6E WzfhUWAjcnF4Jo8bVvNUMBQ8oGJtbeTQ4zhmwvHUxf9h7F2EkSQB6reUi4UHlK5QFBZP 30cA== X-Gm-Message-State: AGRZ1gK3dnbQyTy2NHXCWEiDasbHCMXzsGQm0YPVDFC67VsTwt+JPiqL ueSFrmbhL1KwXB5hhQXz9EdZQrsg X-Google-Smtp-Source: AJdET5csDFmikHgulOCMj3t93mhcyh6OGdUNIGHJMVy56q/UlGVFlXJN4U8TH6Bcd7yMc1v9c5USHg== X-Received: by 2002:a1c:e58c:: with SMTP id c134mr4692839wmh.124.1542567877675; Sun, 18 Nov 2018 11:04:37 -0800 (PST) Received: from u.nix.is ([2a01:4f8:190:5095::2]) by smtp.gmail.com with ESMTPSA id t17sm5640041wme.43.2018.11.18.11.04.36 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 18 Nov 2018 11:04:36 -0800 (PST) From: =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= To: git@vger.kernel.org Cc: Junio C Hamano , Jeff King , Christian Couder , =?utf-8?b?Tmd1eeG7hW4gVGg=?= =?utf-8?b?w6FpIE5n4buNYyBEdXk=?= , Michael Haggerty , =?utf-8?q?SZEDER_G=C3=A1bor?= , =?utf-8?b?w4Z2YXIg?= =?utf-8?b?QXJuZmrDtnLDsCBCamFybWFzb24=?= , Christian Couder Subject: [PATCH v3] read-cache: make the split index obey umask settings Date: Sun, 18 Nov 2018 19:04:29 +0000 Message-Id: <20181118190429.15581-1-avarab@gmail.com> X-Mailer: git-send-email 2.19.1.1182.g4ecb1133ce In-Reply-To: <87efbi1tk4.fsf@evledraar.gmail.com> References: <87efbi1tk4.fsf@evledraar.gmail.com> MIME-Version: 1.0 Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Make the split index write out its .git/sharedindex_* files with the same permissions as .git/index. This only changes the behavior when core.sharedRepository isn't set, i.e. the user's umask settings will be respected. This hasn't been the case ever since the split index was originally implemented in c18b80a0e8 ("update-index: new options to enable/disable split index mode", 2014-06-13). A mkstemp()-like function has always been used to create it. First mkstemp() itself, and then later our own mkstemp()-like in f6ecc62dbf ("write_shared_index(): use tempfile module", 2015-08-10) A related bug was fixed in df801f3f9f ("read-cache: use shared perms when writing shared index", 2017-06-25). Since then the split index has respected core.sharedRepository. However, using that setting should not be required simply to make git obey the user's umask setting. It's intended for the use-case of overriding whatever that umask is set to. This fixes cases where the user has e.g. set his umask to 022 on a shared server in anticipation of other user's needing to run "status", "log" etc. in his repository. Signed-off-by: Ævar Arnfjörð Bjarmason Signed-off-by: Christian Couder Signed-off-by: Junio C Hamano --- Here it is with a rewritten commit message & adjusted comment as discussed in the v2 discussion. read-cache.c | 3 ++- t/t1700-split-index.sh | 20 ++++++++++++++++++++ 2 files changed, 22 insertions(+), 1 deletion(-) diff --git a/read-cache.c b/read-cache.c index 4ca81286c0..e7e77e780b 100644 --- a/read-cache.c +++ b/read-cache.c @@ -3150,7 +3150,8 @@ int write_locked_index(struct index_state *istate, struct lock_file *lock, struct tempfile *temp; int saved_errno; - temp = mks_tempfile(git_path("sharedindex_XXXXXX")); + /* Same initial permissions as the main .git/index file */ + temp = mks_tempfile_sm(git_path("sharedindex_XXXXXX"), 0, 0666); if (!temp) { oidclr(&si->base_oid); ret = do_write_locked_index(istate, lock, flags); diff --git a/t/t1700-split-index.sh b/t/t1700-split-index.sh index 2ac47aa0e4..fa1d3d468b 100755 --- a/t/t1700-split-index.sh +++ b/t/t1700-split-index.sh @@ -381,6 +381,26 @@ test_expect_success 'check splitIndex.sharedIndexExpire set to "never" and "now" test $(ls .git/sharedindex.* | wc -l) -le 2 ' +test_expect_success POSIXPERM 'same mode for index & split index' ' + git init same-mode && + ( + cd same-mode && + test_commit A && + test_modebits .git/index >index_mode && + test_must_fail git config core.sharedRepository && + git -c core.splitIndex=true status && + shared=$(ls .git/sharedindex.*) && + case "$shared" in + *" "*) + # we have more than one??? + false ;; + *) + test_modebits "$shared" >split_index_mode && + test_cmp index_mode split_index_mode ;; + esac + ) +' + while read -r mode modebits do test_expect_success POSIXPERM "split index respects core.sharedrepository $mode" '