From d05c77cca2a6768ca03e95bcdd7358eb6af85c1a Mon Sep 17 00:00:00 2001 From: Jeff King Date: Mon, 5 Jan 2015 22:49:43 -0500 Subject: t1301: set umask in reflog sharedrepository=group test The t1301 script sets the umask globally before many of the tests. Most of the tests that care about the umask then set it explicitly at the start of the test. However, one test does not, and relies on the 077 umask setting from earlier tests. This is fragile and can break if another test is added in between. Let's be more explicit. Signed-off-by: Jeff King Signed-off-by: Junio C Hamano --- t/t1301-shared-repo.sh | 1 + 1 file changed, 1 insertion(+) (limited to 't') diff --git a/t/t1301-shared-repo.sh b/t/t1301-shared-repo.sh index de42d21c92..86ed901e0e 100755 --- a/t/t1301-shared-repo.sh +++ b/t/t1301-shared-repo.sh @@ -112,6 +112,7 @@ do done test_expect_success POSIXPERM 'git reflog expire honors core.sharedRepository' ' + umask 077 && git config core.sharedRepository group && git reflog expire --all && actual="$(ls -l .git/logs/refs/heads/master)" && -- cgit v1.2.3 From d91175b2128aeae00ed10cd7e8216a60ca66e06b Mon Sep 17 00:00:00 2001 From: Jeff King Date: Mon, 5 Jan 2015 22:50:49 -0500 Subject: update-server-info: create info/* with mode 0666 Prior to d38379e (make update-server-info more robust, 2014-09-13), we used a straight "fopen" to create the info/refs and objects/info/packs files, which creates the file using mode 0666 (less the default umask). In d38379e, we switched to creating the file with mkstemp to get a unique filename. But mkstemp also uses the more restrictive 0600 mode to create the file. This was an unintended side effect that we did not want, and causes problems when the repository is served by a different user than the one running update-server-info (it is not readable by a dumb http server running as `www`, for example). We can fix this by using git_mkstemp_mode and specifying 0666 to make sure that the umask is honored. Note that we could also say "just use core.sharedrepository", as we do call adjust_shared_perm on the result before renaming it into place. But that should not be necessary as long as everybody involved is using permissive umask to allow HTTP server to read necessary files. Signed-off-by: Jeff King Signed-off-by: Junio C Hamano --- t/t1301-shared-repo.sh | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 't') diff --git a/t/t1301-shared-repo.sh b/t/t1301-shared-repo.sh index 86ed901e0e..7eecfb836a 100755 --- a/t/t1301-shared-repo.sh +++ b/t/t1301-shared-repo.sh @@ -111,6 +111,16 @@ do done +test_expect_success POSIXPERM 'info/refs respects umask in unshared repo' ' + rm -f .git/info/refs && + test_unconfig core.sharedrepository && + umask 002 && + git update-server-info && + echo "-rw-rw-r--" >expect && + modebits .git/info/refs >actual && + test_cmp expect actual +' + test_expect_success POSIXPERM 'git reflog expire honors core.sharedRepository' ' umask 077 && git config core.sharedRepository group && -- cgit v1.2.3