From patchwork Mon Nov 21 03:00:19 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eric Sunshine X-Patchwork-Id: 13050315 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 32D04C433FE for ; Mon, 21 Nov 2022 03:00:31 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229915AbiKUDA3 (ORCPT ); Sun, 20 Nov 2022 22:00:29 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53830 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229861AbiKUDA1 (ORCPT ); Sun, 20 Nov 2022 22:00:27 -0500 Received: from mail-wr1-x42c.google.com (mail-wr1-x42c.google.com [IPv6:2a00:1450:4864:20::42c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 733C82F642 for ; Sun, 20 Nov 2022 19:00:25 -0800 (PST) Received: by mail-wr1-x42c.google.com with SMTP id z4so3328908wrr.3 for ; Sun, 20 Nov 2022 19:00:25 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=cc:to:mime-version:content-transfer-encoding:fcc:subject:date:from :references:in-reply-to:message-id:from:to:cc:subject:date :message-id:reply-to; bh=Uyza2Qzfb0o7qIYUjovbLXZQXbGbmQ6n4f7Hjeg6syY=; b=Yqmzdy8cNf7TAEc7U0mPuCQkHk/oo/gHt8lp7bBNa8ItC8DrYZBl7mGUCLFsWWLpX9 vQ54UTRv2E0X3bYMm7T8IxwatJ2M04s23h8r6DixwX511LEGgGI666mnWiP7F7DjU9C2 3yxmtXdMMIwP1rAAhbjjzNy18zrUA9l8Oq6VIYULRND6Emx7rOF/jOu6Sryf90FVIiIM cWtEv3JdmGX0bMTQPDxT1bK1RPuNAkUaIf5nkInBPTRKN26PlsQO8B3h4aoieU0EL4z3 qVQb54K3JcHKJlhE3P6nYlBiypbESMahYxqMH89QlrehNaWpEgcuQU9qqjvKKjUTWXk9 fcTg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=cc:to:mime-version:content-transfer-encoding:fcc:subject:date:from :references:in-reply-to:message-id:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=Uyza2Qzfb0o7qIYUjovbLXZQXbGbmQ6n4f7Hjeg6syY=; b=dlvgt+5wwZql7KNNDhh/YNYQ/DXLabIDAz2cn+TJOoBJhjC5Q6sgCi+RwuVuiVjoIy hLRFV/Uh81uuM9nqe+zpgcT1l0+TCk2rH1GzvU6nd1qIlASKXChM1ZAU+uV2s/YcMpZ2 W7UyiwraGwAsGSZtTPZtFUwFLZYf2Knv0vO5aqiymTc2WI8gJo0FEfAkGW4FKmf7mexZ SOlCFk3k2vxJp+pJ/vp3eDPsMXhcuZs0M6QizwFq9KcKVTF2M3AwGvnRXKD14T/e0riR 0GIfyt2DcwGaeEj6PDr2PBZ5ls/3PIN7PK75XDKodk9W3OU+hOMGzw0h0LFecAI04IBc 4vjw== X-Gm-Message-State: ANoB5pkECgGPp8mW8N32AW9rupeDC2GfgXzHgwmQLmNGZ92n7ARi9TFa DCxIkGko5enQBuaKPBG+n4MCBdstYuA= X-Google-Smtp-Source: AA0mqf6hRzCgOnJFKUlTFjoP3+nZotqXwn2DUcBtySkelw1a4WkvkOWoif6qDGMWLv5tQjbqP6ujTg== X-Received: by 2002:a5d:6707:0:b0:241:c56f:583b with SMTP id o7-20020a5d6707000000b00241c56f583bmr6436357wru.382.1668999623754; Sun, 20 Nov 2022 19:00:23 -0800 (PST) Received: from [127.0.0.1] ([13.74.141.28]) by smtp.gmail.com with ESMTPSA id bt21-20020a056000081500b00241cbb7f15csm5278605wrb.106.2022.11.20.19.00.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 20 Nov 2022 19:00:23 -0800 (PST) Message-Id: <0efeec8abdb913786c67775cbd79c8e4285ded10.1668999621.git.gitgitgadget@gmail.com> In-Reply-To: References: Date: Mon, 21 Nov 2022 03:00:19 +0000 Subject: [PATCH 1/3] t1509: fix failing "root work tree" test due to owner-check Fcc: Sent MIME-Version: 1.0 To: git@vger.kernel.org Cc: Johannes Schindelin , Eric Sunshine , Eric Sunshine Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org From: Eric Sunshine From: Eric Sunshine When 8959555cee (setup_git_directory(): add an owner check for the top-level directory, 2022-03-02) tightened security surrounding directory ownership, it neglected to adjust t1509-root-work-tree.sh to take the new restriction into account. As a result, since the root directory `/` is typically not owned by the user running the test (indeed, t1509 refuses to run as `root`), the ownership check added by 8959555cee kicks in and causes the test to fail: fatal: detected dubious ownership in repository at '/' To add an exception for this directory, call: git config --global --add safe.directory / This problem went unnoticed for so long because t1509 is rarely run since it requires setting up a `chroot` environment or a sacrificial virtual machine in which `/` can be made writable and polluted by any user. Signed-off-by: Eric Sunshine --- t/t1509-root-work-tree.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/t/t1509-root-work-tree.sh b/t/t1509-root-work-tree.sh index 553a3f601ba..eb57fe7e19f 100755 --- a/t/t1509-root-work-tree.sh +++ b/t/t1509-root-work-tree.sh @@ -221,7 +221,8 @@ test_expect_success 'setup' ' rm -rf /.git && echo "Initialized empty Git repository in /.git/" > expected && git init > result && - test_cmp expected result + test_cmp expected result && + git config --global --add safe.directory / ' test_vars 'auto gitdir, root' ".git" "/" "" From patchwork Mon Nov 21 03:00:20 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eric Sunshine X-Patchwork-Id: 13050316 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 00DDCC433FE for ; Mon, 21 Nov 2022 03:00:33 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229929AbiKUDAb (ORCPT ); Sun, 20 Nov 2022 22:00:31 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53832 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229864AbiKUDA1 (ORCPT ); Sun, 20 Nov 2022 22:00:27 -0500 Received: from mail-wr1-x436.google.com (mail-wr1-x436.google.com [IPv6:2a00:1450:4864:20::436]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6B0EC2FC06 for ; Sun, 20 Nov 2022 19:00:26 -0800 (PST) Received: by mail-wr1-x436.google.com with SMTP id b12so4111108wrn.2 for ; Sun, 20 Nov 2022 19:00:26 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=cc:to:mime-version:content-transfer-encoding:fcc:subject:date:from :references:in-reply-to:message-id:from:to:cc:subject:date :message-id:reply-to; bh=NWo9OoIErwIDRMHSD9NwxmYmRFcrsleCZMdfGNNF5Js=; b=dSvInlYlycUoAhN25sTIT7ag8WiCNrnqruLZDcUFp5tMsAfoK4HFP5uzvGuJVdqPYg K2wrYf1zePV5xCaaGAbgy4P8UQcek/lIlIz5IFv7DBahtynD4F/oyM2IQzBJVP7lRIia KGJh8C9b5fOR9VZhy7qDuQBcMST3OVfDQEt4vdyQ5YnEMKzv4ozrpsNRPVOiewKeBSRq FBI7KvUqgTbGzfY7lK2TNotL2Hc4IQBr4PAufskAoFe6J1F0mbnDu+961cjLR9mwyGaJ Bkto0xz46xdp3MpVuUWUUK9fZjKTx2x125aBFf0l8NUt+4jQBU4aDJVfErwA0b7xdKa7 URCQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=cc:to:mime-version:content-transfer-encoding:fcc:subject:date:from :references:in-reply-to:message-id:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=NWo9OoIErwIDRMHSD9NwxmYmRFcrsleCZMdfGNNF5Js=; b=0WdLjqm9V1gjBpr0CHoOjYoh2811p83rr9vVpeiO27UgD+IRs9dWivZf1e+A3sNQvJ JaKgWnN8E/Ximv+mGbyw9QK5D9BGwFN/jEDRYXpwnl3aXPCwEx6lVIf8AO7MSDciIBNK begkRUjeNYcko66X0aE5R8dwtGTL0llh8AAAytPz6BktKuhb5zlWiuCvpq5jtNIlL/7l M8OjxA7ZxsqZK7gniLTuWWxxCZ9puEsupJGZ5smh2mgF/zksTLbqdV75ojaH7XUwSmAQ TrRb6h7KckfcSOj/h/N0y2q3EK+iQl72+L9DteFr9oC8jRGN6VqZdqKt6WUfakMWlet5 JO+w== X-Gm-Message-State: ANoB5pnAuwZN/+3P7vHQzaIjjpGDlTDREHkV7NDoWev/98QiqAjwBSC5 y/ptupcnnPwjktiBFisNYV3LdHgDJCk= X-Google-Smtp-Source: AA0mqf634DQ0oOlpVNoOqX3601S8Yna1soktDTzJh7D8/JRe2i/rVL5kXMbf/em6d3JTRug+afVRyw== X-Received: by 2002:a5d:6049:0:b0:22e:32f8:ca31 with SMTP id j9-20020a5d6049000000b0022e32f8ca31mr9765901wrt.247.1668999624728; Sun, 20 Nov 2022 19:00:24 -0800 (PST) Received: from [127.0.0.1] ([13.74.141.28]) by smtp.gmail.com with ESMTPSA id f3-20020a5d4dc3000000b0022e57e66824sm11404565wru.99.2022.11.20.19.00.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 20 Nov 2022 19:00:24 -0800 (PST) Message-Id: <617f98dcb40d417fbb48d9c1de8fa9ab650f5370.1668999621.git.gitgitgadget@gmail.com> In-Reply-To: References: Date: Mon, 21 Nov 2022 03:00:20 +0000 Subject: [PATCH 2/3] t1509: make "setup" test more robust Fcc: Sent MIME-Version: 1.0 To: git@vger.kernel.org Cc: Johannes Schindelin , Eric Sunshine , Eric Sunshine Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org From: Eric Sunshine From: Eric Sunshine One of the t1509 setup tests is very particular about the output it expects from `git init`, and fails if the output differs even slightly which can happen easily if the script is run multiple times since it doesn't do a good job of cleaning up after itself (i.e. it leaves detritus in the root directory `/`). One bit of cruft in particular (`/HEAD`) makes the test fail since its presence causes `git init` to alter its output; rather than reporting "Initialized empty Git repository", it instead reports "Reinitialized existing Git repository" when `/HEAD` is present. Address this problem by making the test do a more careful job of crafting its intended initial state. Signed-off-by: Eric Sunshine --- t/t1509-root-work-tree.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/t/t1509-root-work-tree.sh b/t/t1509-root-work-tree.sh index eb57fe7e19f..d0417626280 100755 --- a/t/t1509-root-work-tree.sh +++ b/t/t1509-root-work-tree.sh @@ -243,7 +243,7 @@ say "auto bare gitdir" # DESTROYYYYY!!!!! test_expect_success 'setup' ' rm -rf /refs /objects /info /hooks && - rm -f /expected /ls.expected /me /result && + rm -f /HEAD /expected /ls.expected /me /result && cd / && echo "Initialized empty Git repository in /" > expected && git init --bare > result && From patchwork Mon Nov 21 03:00:21 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eric Sunshine X-Patchwork-Id: 13050317 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 1224BC433FE for ; Mon, 21 Nov 2022 03:00:36 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229787AbiKUDAf (ORCPT ); Sun, 20 Nov 2022 22:00:35 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53838 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229870AbiKUDA2 (ORCPT ); Sun, 20 Nov 2022 22:00:28 -0500 Received: from mail-wr1-x42b.google.com (mail-wr1-x42b.google.com [IPv6:2a00:1450:4864:20::42b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7A29F2FC13 for ; Sun, 20 Nov 2022 19:00:27 -0800 (PST) Received: by mail-wr1-x42b.google.com with SMTP id b12so4111155wrn.2 for ; Sun, 20 Nov 2022 19:00:27 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=cc:to:mime-version:content-transfer-encoding:fcc:subject:date:from :references:in-reply-to:message-id:from:to:cc:subject:date :message-id:reply-to; bh=jCaIGT8G+GqKz4PWOcqc32ri69czi5anqnyaDUI4HEY=; b=DU2s3jwNDZH5weMZ5fkv8Z4Pdv6ZRopTQjjblqWqbiv85FshcVZVAcMGjnG4hxT8N/ +tTZr9r/xn47qc6B2eWuu8C9lP071rAynl5JybQ0zdNQ62ZcPYavAeNs71fv3FOmmg5Z QwsXBUmyBhfcEXEAt2iiCgLJjRh1Zsv7IsCkYBCe/z9U+tMya1INrTHwfop9/WVe3UbO cG/BS5+FEdEBq1+6Rf2FTG6pdRb8NE1yZwgJaEVKr6R9/eNHHfSyJgr0Al6Y8VeYueI+ AiI38IMywmJDdS0M8zjOKfuVLnc7YEHmhBYlF9JX4pTi9hlBSjOTd45uDJJgn3S/Dftq iUbQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=cc:to:mime-version:content-transfer-encoding:fcc:subject:date:from :references:in-reply-to:message-id:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=jCaIGT8G+GqKz4PWOcqc32ri69czi5anqnyaDUI4HEY=; b=kutWiuICDtUyRzwPMb9+WKquhLKBRRLuS2lv3NVn3NxEUrzQS7kXnWTeg1IBDu6cnE 8sXku4EEBoreFVYdRpx1l3+lQQ3Ogp9tFqjy0G2ZeqKMU99VEg6/RMnyfGCP9E6qeTpa HRdJgeZKD89C/sRhlBs8QBDTYVS2/cNTw4tTzwtUAUtwQ4yrUglP0RjqAWwQ+vgd8kxb /okumK8IXNfLEpkt2ZQ+i9sRiAA7xISu2f674Zbzh5lTTxHhqqsTVC6njwqw/dA7j/zh eP5Jx5gDPjpDSztpB4N+uRaCvoFmEk/7ill7t1+e/ySgwfGdEP9l/Gv+X8s/VCn0ovu3 o/iw== X-Gm-Message-State: ANoB5pn3dJumoc5aNbV8z/dtuGWtX3aRz4b5cPOYF0QzY4Dxl6u7wPT9 qfzbwRubBM9o9ztbWFLtR09lCSdYpGM= X-Google-Smtp-Source: AA0mqf6xumimGrhXTBSo8ujOaRUVDIkQBciQ538SNbTuPPPp+6nblvXS2EqEE/H3g4CW2pShbkQ5Zg== X-Received: by 2002:adf:f847:0:b0:241:d9c7:3400 with SMTP id d7-20020adff847000000b00241d9c73400mr570441wrq.620.1668999625845; Sun, 20 Nov 2022 19:00:25 -0800 (PST) Received: from [127.0.0.1] ([13.74.141.28]) by smtp.gmail.com with ESMTPSA id c1-20020a5d4cc1000000b002365b759b65sm9921100wrt.86.2022.11.20.19.00.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 20 Nov 2022 19:00:25 -0800 (PST) Message-Id: <97ada2a1202190776ce3989d3841dd47e2702316.1668999621.git.gitgitgadget@gmail.com> In-Reply-To: References: Date: Mon, 21 Nov 2022 03:00:21 +0000 Subject: [PATCH 3/3] t1509: facilitate repeated script invocations Fcc: Sent MIME-Version: 1.0 To: git@vger.kernel.org Cc: Johannes Schindelin , Eric Sunshine , Eric Sunshine Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org From: Eric Sunshine From: Eric Sunshine t1509-root-work-tree.sh, which tests behavior of a Git repository located at the root `/` directory, refuses to run if it detects the presence of an existing repository at `/`. This safeguard ensures that it won't clobber a legitimate repository at that location. However, because t1509 does a poor job of cleaning up after itself, it runs afoul of its own safety check on subsequent runs, which makes it painful to run the script repeatedly since each run requires manual cleanup of detritus from the previous run. Address this shortcoming by making t1509 clean up after itself as its last action. This is safe since the script can only make it to this cleanup action if it did not find a legitimate repository at `/` in the first place, so the resources cleaned up here can only have been created by the script itself. Signed-off-by: Eric Sunshine --- t/t1509-root-work-tree.sh | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/t/t1509-root-work-tree.sh b/t/t1509-root-work-tree.sh index d0417626280..c799f5b6aca 100755 --- a/t/t1509-root-work-tree.sh +++ b/t/t1509-root-work-tree.sh @@ -256,4 +256,9 @@ test_expect_success 'go to /foo' 'cd /foo' test_vars 'auto gitdir, root' "/" "" "" +test_expect_success 'cleanup root' ' + rm -rf /.git /refs /objects /info /hooks /branches /foo && + rm -f /HEAD /config /description /expected /ls.expected /me /result +' + test_done