diff options
author | René Scharfe <l.s.r@web.de> | 2017-03-26 15:43:50 +0200 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2017-03-26 17:41:05 -0700 |
commit | a54e938e5b53c76ebcd5c068a4f74739c1c68bac (patch) | |
tree | 6b8e11ba8e28b219f741063c2b2c2dfa4c89e3be /t/t0001-init.sh | |
parent | 8f9aeb0d36c6cbfb849946bb272fa0d3c4611547 (diff) | |
download | git-a54e938e5b53c76ebcd5c068a4f74739c1c68bac.tar.gz |
strbuf: support long paths w/o read rights in strbuf_getcwd() on FreeBSDrs/freebsd-getcwd-workaround
FreeBSD implements getcwd(3) as a syscall, but falls back to a version
based on readdir(3) if it fails for some reason. The latter requires
permissions to read and execute path components, while the former does
not. That means that if our buffer is too small and we're missing
rights we could get EACCES, but we may succeed with a bigger buffer.
Keep retrying if getcwd(3) indicates lack of permissions until our
buffer can fit PATH_MAX bytes, as that's the maximum supported by the
syscall on FreeBSD anyway. This way we do what we can to be able to
benefit from the syscall, but we also won't loop forever if there is a
real permission issue.
This fixes a regression introduced with 7333ed17 (setup: convert
setup_git_directory_gently_1 et al. to strbuf, 2014-07-28) for paths
longer than 127 bytes with components that miss read or execute
permissions (e.g. 0711 on /home for privacy reasons); we used a fixed
PATH_MAX-sized buffer before.
Reported-by: Zenobiusz Kunegunda <zenobiusz.kunegunda@interia.pl>
Signed-off-by: Rene Scharfe <l.s.r@web.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 't/t0001-init.sh')
-rwxr-xr-x | t/t0001-init.sh | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/t/t0001-init.sh b/t/t0001-init.sh index e424de5363..c4814d248f 100755 --- a/t/t0001-init.sh +++ b/t/t0001-init.sh @@ -315,6 +315,20 @@ test_expect_success 'init with separate gitdir' ' test_path_is_dir realgitdir/refs ' +test_expect_success 'init in long base path' ' + # exceed initial buffer size of strbuf_getcwd() + component=123456789abcdef && + test_when_finished "chmod 0700 $component; rm -rf $component" && + p31=$component/$component && + p127=$p31/$p31/$p31/$p31 && + mkdir -p $p127 && + chmod 0111 $component && + ( + cd $p127 && + git init newdir + ) +' + test_expect_success 're-init on .git file' ' ( cd newdir && git init ) ' |