From 138086a72582620e0b3ec0aa60a78da208e89a2a Mon Sep 17 00:00:00 2001 From: Junio C Hamano Date: Fri, 9 Jun 2006 22:07:23 -0700 Subject: shared repository - add a few missing calls to adjust_shared_perm(). There were a few calls to adjust_shared_perm() that were missing: - init-db creates refs, refs/heads, and refs/tags before reading from templates that could specify sharedrepository in the config file; - updating config file created it under user's umask without adjusting; - updating refs created it under user's umask without adjusting; - switching branches created .git/HEAD under user's umask without adjusting. This moves adjust_shared_perm() from sha1_file.c to path.c, since a few SIMPLE_PROGRAM need to call repository configuration functions which in turn need to call adjust_shared_perm(). sha1_file.c needs to link with SHA1 computation library which is usually not linked to SIMPLE_PROGRAM. Signed-off-by: Junio C Hamano --- path.c | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) (limited to 'path.c') diff --git a/path.c b/path.c index 334b2bd195..5168b5f17d 100644 --- a/path.c +++ b/path.c @@ -250,3 +250,26 @@ char *enter_repo(char *path, int strict) return NULL; } + +int adjust_shared_perm(const char *path) +{ + struct stat st; + int mode; + + if (!shared_repository) + return 0; + if (lstat(path, &st) < 0) + return -1; + mode = st.st_mode; + if (mode & S_IRUSR) + mode |= S_IRGRP; + if (mode & S_IWUSR) + mode |= S_IWGRP; + if (mode & S_IXUSR) + mode |= S_IXGRP; + if (S_ISDIR(mode)) + mode |= S_ISGID; + if (chmod(path, mode) < 0) + return -2; + return 0; +} -- cgit v1.2.3