From patchwork Wed Jan 24 12:31:30 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Patrick Steinhardt X-Patchwork-Id: 13529165 Received: from wout1-smtp.messagingengine.com (wout1-smtp.messagingengine.com [64.147.123.24]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 15B6E6D1CE for ; Wed, 24 Jan 2024 12:31:36 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=64.147.123.24 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706099499; cv=none; b=rbRFhYXJVm3rN5P7lEdNa2+WoauVfZ2U7BnLbMwBfYS9vMX9C0r2oX8hZf4P7CUyt9sHQTU2lyu7OdGlBrqt8bjJ5Gv4j+w+ZhFosuerOptQS7yWYpQLoJNMzA4wfmFqxOTVbw5lFkXZdbtv0wc4/cwYXvSR82ThEFQWBP0WRUU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706099499; c=relaxed/simple; bh=K2K/u85rxRTMzkOiEZNuxYgcGCwed9XEux/KngMm1J4=; h=Date:From:To:Subject:Message-ID:MIME-Version:Content-Type: Content-Disposition; b=MSzAZqRBCDLp6R1scWVwEk5wczeWnGL0EuTFjxoLSRuy+FRgLJAogcD95FSXaqsgDFOFzSiZcbnA6hM2BSeaxWOrSd8NSPHifbWXlslq5Q0hn4yGeI0CIqa5Xi+8s5B8Fn0kz2NoQBESEdtdqCS+IPWjcRKz84B1thLOlEFszJc= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=pks.im; spf=pass smtp.mailfrom=pks.im; dkim=pass (2048-bit key) header.d=pks.im header.i=@pks.im header.b=kCn/eQ3E; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b=HG6oyYaM; arc=none smtp.client-ip=64.147.123.24 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=pks.im Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=pks.im Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=pks.im header.i=@pks.im header.b="kCn/eQ3E"; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b="HG6oyYaM" Received: from compute3.internal (compute3.nyi.internal [10.202.2.43]) by mailout.west.internal (Postfix) with ESMTP id C1A7D3200ACC for ; Wed, 24 Jan 2024 07:31:35 -0500 (EST) Received: from mailfrontend1 ([10.202.2.162]) by compute3.internal (MEProxy); Wed, 24 Jan 2024 07:31:35 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=pks.im; h=cc :content-type:content-type:date:date:from:from:in-reply-to :message-id:mime-version:reply-to:subject:subject:to:to; s=fm3; t=1706099495; x=1706185895; bh=Sxcs2lfiavPP2jCEIpGFLK1MUSivU5EV mE3VL44TAf8=; b=kCn/eQ3EZ+m4ffNBcWilOP0/96/uca5AuwkbpyzMm37A+aeb KtxswHozV0rrBa1TiB75rP3j/6BMJ6Y09ksm2sH/hn1d2fEt8MQ4rynm84k8rMPN 8Vme8a8u8ecq3B5EJNOPmr7q9QTWw3YGe6zUP0v2GggruKTnWdcGbjhgt/a6uhV+ nKQyFVpatkdEVusljCdwuyoUKe3T5IMyWuJf6P+PCsEvcZdMGSrzwe+5Q2gHVHbf wImo0Ev13IoncmVqnCRmToRaJsWgRZjxLspG1XfgajGpn1ZMQx0OxikvabgY9aMU NxHslH9JKtI8LSJYQkUr7DVPNdH5r5MIYPxp/w== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-type:content-type:date:date :feedback-id:feedback-id:from:from:in-reply-to:message-id :mime-version:reply-to:subject:subject:to:to:x-me-proxy :x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s=fm3; t= 1706099495; x=1706185895; bh=Sxcs2lfiavPP2jCEIpGFLK1MUSivU5EVmE3 VL44TAf8=; b=HG6oyYaMWRPUroR1P9O38spu/Wx02FxsyWt4GrEdOlB8jbnbknm T1hVd4uWQ87GY9K6iXCov1Hj7bOaCsTC+KyS0L9Hn0tE8eb/scvDJL1+7DxkytsB KA2EjKL4BxOGabkm/cTywJFDAROenjlKlQOovVG2Vm2Tr+n2eBGyBUvZE1xuW6ag hIL2WTlcC6nlyppiOTbZjeV4GFNzf/AIyDblHLI4fJtMCWUDWOBsQqOKnP5suwli 5gwNDqaryV8khUK32YQIG8pSX2sMxYbxFwCN1bTqeRz+40Y0eBINdPDePrMvwYlO lZ/xWa/dbjU5ljvTKRtcsTLZdW8wz6SP4Pg== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvkedrvdeluddgfeekucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucenucfjughrpeffhffvuffkgggtugesghdtreertd dtvdenucfhrhhomheprfgrthhrihgtkhcuufhtvghinhhhrghrughtuceophhssehpkhhs rdhimheqnecuggftrfgrthhtvghrnhepjeeifedvueelfffgjeduffdvgefhiefgjefgvd dvfeduvefffeevfffhgfekieffnecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghm pehmrghilhhfrhhomhepphhssehpkhhsrdhimh X-ME-Proxy: Feedback-ID: i197146af:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA for ; Wed, 24 Jan 2024 07:31:34 -0500 (EST) Received: by vm-mail (OpenSMTPD) with ESMTPSA id 2feeb7c2 (TLSv1.3:TLS_AES_256_GCM_SHA384:256:NO) for ; Wed, 24 Jan 2024 12:28:25 +0000 (UTC) Date: Wed, 24 Jan 2024 13:31:30 +0100 From: Patrick Steinhardt To: git@vger.kernel.org Subject: [PATCH 0/2] reftable: adjust permissions of compacted tables Message-ID: Precedence: bulk X-Mailing-List: git@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Disposition: inline Hi, this small patch series fixes a bug in the reftable stack implementation where the "default_permissions" write option is not honored for newly written compacted tables. The effect is that the "core.sharedRepository" config is ignored when performing compaction. The series runs into two minor conflicts with jc/reftable-core-fsync that can be fixed like follows. As this series has been merged to next already I'd also be happy to rebase these patches on top of it. Please let me know your preference. Patrick +++ b/reftable/stack.c @@@ -633,13 -643,13 +643,13 @@@ int reftable_addition_add(struct reftab err = REFTABLE_IO_ERROR; goto done; } - if (add->stack->config.default_permissions) { - if (chmod(temp_tab_file_name.buf, add->stack->config.default_permissions)) { - err = REFTABLE_IO_ERROR; - goto done; - } + if (add->stack->config.default_permissions && + fchmod(tab_fd, add->stack->config.default_permissions) < 0) { + err = REFTABLE_IO_ERROR; + goto done; } + - wr = reftable_new_writer(reftable_fd_write, &tab_fd, + wr = reftable_new_writer(reftable_fd_write, reftable_fd_flush, &tab_fd, &add->stack->config); err = write_table(wr, arg); if (err < 0) @@@ -731,13 -741,7 +741,13 @@@ static int stack_compact_locked(struct strbuf_addstr(temp_tab, ".temp.XXXXXX"); tab_fd = mkstemp(temp_tab->buf); + if (st->config.default_permissions && + fchmod(tab_fd, st->config.default_permissions) < 0) { + err = REFTABLE_IO_ERROR; + goto done; + } + - wr = reftable_new_writer(reftable_fd_write, &tab_fd, &st->config); + wr = reftable_new_writer(reftable_fd_write, reftable_fd_flush, &tab_fd, &st->config); err = stack_write_compact(st, wr, first, last, config); if (err < 0) Patrick Steinhardt (2): reftable/stack: use fchmod(3P) to set permissions reftable/stack: adjust permissions of compacted tables reftable/stack.c | 35 ++++++++++++++++++++--------------- reftable/stack_test.c | 25 +++++++++++++++++++++++-- 2 files changed, 43 insertions(+), 17 deletions(-) diff --cc reftable/stack.c index 27cc586460,ab295341cc..0000000000 --- a/reftable/stack.c