mirror of
https://github.com/git/git.git
synced 2024-10-28 04:49:43 +01:00
safe.directory: setting safe.directory="." allows the "current" directory
When "git daemon" enters a repository, it chdir's to the requested repository and then uses "." (the curent directory) to consult the "is this repository considered safe?" when it is not owned by the same owner as the process. Make sure this access will be allowed by setting safe.directory to ".", as that was once advertised on the list as a valid workaround to the overly tight safe.directory settings introduced by 2.45.1 (cf. <834862fd-b579-438a-b9b3-5246bf27ce8a@gmail.com>). Also add simlar test to show what happens in the same setting if the safe.directory is set to "*" instead of "."; in short, "." is a bit tighter (as it is custom designed for git-daemon situation) than "anything goes" settings given by "*". Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
parent
dc0edbb01c
commit
ee0be850b0
1 changed files with 64 additions and 0 deletions
|
@ -233,4 +233,68 @@ test_expect_success SYMLINKS 'configured leading paths are normalized' '
|
|||
git -C repo/s/.git/ for-each-ref
|
||||
'
|
||||
|
||||
test_expect_success 'safe.directory set to a dot' '
|
||||
test_when_finished "rm -rf repository" &&
|
||||
(
|
||||
sane_unset GIT_TEST_ASSUME_DIFFERENT_OWNER &&
|
||||
git config --global --unset-all safe.directory
|
||||
) &&
|
||||
mkdir -p repository/subdir &&
|
||||
git init repository &&
|
||||
(
|
||||
cd repository &&
|
||||
sane_unset GIT_TEST_ASSUME_DIFFERENT_OWNER &&
|
||||
test_commit sample
|
||||
) &&
|
||||
|
||||
(
|
||||
sane_unset GIT_TEST_ASSUME_DIFFERENT_OWNER &&
|
||||
git config --global safe.directory "."
|
||||
) &&
|
||||
git -C repository for-each-ref &&
|
||||
git -C repository/ for-each-ref &&
|
||||
git -C repository/.git for-each-ref &&
|
||||
git -C repository/.git/ for-each-ref &&
|
||||
|
||||
# What is allowed is repository/subdir but the repository
|
||||
# path is repository.
|
||||
test_must_fail git -C repository/subdir for-each-ref &&
|
||||
|
||||
# Likewise, repository .git/refs is allowed with "." but
|
||||
# repository/.git that is accessed is not allowed.
|
||||
test_must_fail git -C repository/.git/refs for-each-ref
|
||||
'
|
||||
|
||||
test_expect_success 'safe.directory set to asterisk' '
|
||||
test_when_finished "rm -rf repository" &&
|
||||
(
|
||||
sane_unset GIT_TEST_ASSUME_DIFFERENT_OWNER &&
|
||||
git config --global --unset-all safe.directory
|
||||
) &&
|
||||
mkdir -p repository/subdir &&
|
||||
git init repository &&
|
||||
(
|
||||
cd repository &&
|
||||
sane_unset GIT_TEST_ASSUME_DIFFERENT_OWNER &&
|
||||
test_commit sample
|
||||
) &&
|
||||
|
||||
(
|
||||
sane_unset GIT_TEST_ASSUME_DIFFERENT_OWNER &&
|
||||
git config --global safe.directory "*"
|
||||
) &&
|
||||
# these are trivial
|
||||
git -C repository for-each-ref &&
|
||||
git -C repository/ for-each-ref &&
|
||||
git -C repository/.git for-each-ref &&
|
||||
git -C repository/.git/ for-each-ref &&
|
||||
|
||||
# With "*", everything is allowed, and the repository is
|
||||
# discovered, which is different behaviour from "." above.
|
||||
git -C repository/subdir for-each-ref &&
|
||||
|
||||
# Likewise.
|
||||
git -C repository/.git/refs for-each-ref
|
||||
'
|
||||
|
||||
test_done
|
||||
|
|
Loading…
Reference in a new issue