Skip to content

Commit d91175b

Browse files
peffgitster
authored andcommitted
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 <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
1 parent d05c77c commit d91175b

2 files changed

Lines changed: 11 additions & 1 deletion

File tree

server-info.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ static int update_info_file(char *path, int (*generate)(FILE *))
1717
FILE *fp = NULL;
1818

1919
safe_create_leading_directories(path);
20-
fd = mkstemp(tmp);
20+
fd = git_mkstemp_mode(tmp, 0666);
2121
if (fd < 0)
2222
goto out;
2323
fp = fdopen(fd, "w");

t/t1301-shared-repo.sh

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,16 @@ do
111111

112112
done
113113

114+
test_expect_success POSIXPERM 'info/refs respects umask in unshared repo' '
115+
rm -f .git/info/refs &&
116+
test_unconfig core.sharedrepository &&
117+
umask 002 &&
118+
git update-server-info &&
119+
echo "-rw-rw-r--" >expect &&
120+
modebits .git/info/refs >actual &&
121+
test_cmp expect actual
122+
'
123+
114124
test_expect_success POSIXPERM 'git reflog expire honors core.sharedRepository' '
115125
umask 077 &&
116126
git config core.sharedRepository group &&

0 commit comments

Comments
 (0)