From 94df2506edd76a886a1044376f8c99349b2f226e Mon Sep 17 00:00:00 2001 From: Junio C Hamano Date: Fri, 9 Jun 2006 23:09:49 -0700 Subject: shared repository: optionally allow reading to "others". This enhances core.sharedrepository to have additionally specify that read and exec permissions to be given to others as well. It is useful when serving a repository via gitweb and git-daemon that runs as a user outside the project group. The configuration item can take the following values: [core] sharedrepository ; the same as "group" sharedrepository = true ; ditto sharedrepository = 1 ; ditto sharedrepository = group ; allow rwx to group sharedrepository = all ; allow rwx to group, allow rx to other sharedrepository = umask ; not shared - use umask It also extends "git init-db" to take "--shared=all" and friends from the command line. Signed-off-by: Junio C Hamano --- path.c | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) (limited to 'path.c') diff --git a/path.c b/path.c index 5168b5f17d..5d82503b6b 100644 --- a/path.c +++ b/path.c @@ -262,11 +262,21 @@ int adjust_shared_perm(const char *path) return -1; mode = st.st_mode; if (mode & S_IRUSR) - mode |= S_IRGRP; + mode |= (shared_repository == PERM_GROUP + ? S_IRGRP + : (shared_repository == PERM_EVERYBODY + ? (S_IRGRP|S_IROTH) + : 0)); + if (mode & S_IWUSR) mode |= S_IWGRP; + if (mode & S_IXUSR) - mode |= S_IXGRP; + mode |= (shared_repository == PERM_GROUP + ? S_IXGRP + : (shared_repository == PERM_EVERYBODY + ? (S_IXGRP|S_IXOTH) + : 0)); if (S_ISDIR(mode)) mode |= S_ISGID; if (chmod(path, mode) < 0) -- cgit v1.2.1