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

[PATCH 1/3] t1509: fix failing "root work tree" test due to owner-check

From
Eric Sunshine via GitGitGadget <gitgitgadget@gmail.com>
Date
Nov 21, 2022, 03:00 UTC
Message-ID
<0efeec8abdb913786c67775cbd79c8e4285ded10.1668999621.git.gitgitgadget@gmail.com>
In-Reply-To
<pull.1425.git.1668999621.gitgitgadget@gmail.com>
From: Eric Sunshine <sunshine@sunshineco.com>

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 <sunshine@sunshineco.com>
---
 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" "/" ""
-- 
gitgitgadget
Previous: Eric Sunshine via GitGitGadgetNext: Johannes Schindelin
Message 2 of 14 in “fix t1509-root-work-tree failure”
  1. 0/3 fix t1509-root-work-tree failureEric Sunshine via GitGitGadget, Nov 21, 2022
  2. 1/3 t1509: fix failing "root work tree" test due to owner-checkEric Sunshine via GitGitGadget, Nov 21, 2022
  3. Johannes SchindelinDec 8, 2022
  4. 2/3 t1509: make "setup" test more robustEric Sunshine via GitGitGadget, Nov 21, 2022
  5. Johannes SchindelinDec 8, 2022
  6. 3/3 t1509: facilitate repeated script invocationsEric Sunshine via GitGitGadget, Nov 21, 2022
  7. Ævar Arnfjörð BjarmasonDec 6, 2022
  8. Eric SunshineDec 6, 2022
  9. Johannes SchindelinDec 8, 2022
  10. "test_atexit" v.s. "test_when_finished" (was: [PATCH 3/3] t1509: facilitate repeated script invocations)Ævar Arnfjörð Bjarmason, Dec 8, 2022
  11. Junio C HamanoDec 9, 2022
  12. Eric SunshineDec 5, 2022
  13. Johannes SchindelinDec 8, 2022
  14. Eric SunshineDec 9, 2022

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.