Skip to content

Commit

Permalink
update-server-info: create info/* with mode 0666
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Jeff King authored and Junio C Hamano committed Jan 6, 2015
1 parent d05c77c commit d91175b
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
2 changes: 1 addition & 1 deletion server-info.c
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ static int update_info_file(char *path, int (*generate)(FILE *))
FILE *fp = NULL;

safe_create_leading_directories(path);
fd = mkstemp(tmp);
fd = git_mkstemp_mode(tmp, 0666);
if (fd < 0)
goto out;
fp = fdopen(fd, "w");
Expand Down
10 changes: 10 additions & 0 deletions t/t1301-shared-repo.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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 &&
Expand Down

0 comments on commit d91175b

Please sign in to comment.