Merge branch 'jc/shared'
authorJunio C Hamano <junkio@cox.net>
Mon, 19 Jun 2006 03:19:09 +0000 (20:19 -0700)
committerJunio C Hamano <junkio@cox.net>
Mon, 19 Jun 2006 03:19:09 +0000 (20:19 -0700)
* jc/shared:
shared repository: optionally allow reading to "others".

1  2 
cache.h
path.c
diff --combined cache.h
index f630cf4bfa92e45600a83d2c3bac05a855deb847,1b8e053f2850c9f70089ad0eebc8d12518f1fc39..7fcb6d406aa258315f6f2bbba128baee60f59838
+++ b/cache.h
@@@ -208,9 -208,15 +208,15 @@@ extern const unsigned char null_sha1[20
  
  int git_mkstemp(char *path, size_t n, const char *template);
  
+ enum sharedrepo {
+       PERM_UMASK = 0,
+       PERM_GROUP,
+       PERM_EVERYBODY
+ };
+ int git_config_perm(const char *var, const char *value);
  int adjust_shared_perm(const char *path);
  int safe_create_leading_directories(char *path);
 -char *safe_strncpy(char *, const char *, size_t);
 +size_t safe_strncpy(char *, const char *, size_t);
  char *enter_repo(char *path, int strict);
  
  /* Read and unpack a sha1 file into memory, write memory to a sha1 file */
diff --combined path.c
index 194e0b553f7a5c4fd99b348228112b308c5419b6,5d82503b6bd0a384b7918f2df497972f9492efa5..36972fd6df63b3c4eebdcf89238df8ade60d53c3
--- 1/path.c
--- 2/path.c
+++ b/path.c
@@@ -83,19 -83,14 +83,19 @@@ int git_mkstemp(char *path, size_t len
  }
  
  
 -char *safe_strncpy(char *dest, const char *src, size_t n)
 +size_t safe_strncpy(char *dest, const char *src, size_t size)
  {
 -      strncpy(dest, src, n);
 -      dest[n - 1] = '\0';
 +      size_t ret = strlen(src);
  
 -      return dest;
 +      if (size) {
 +              size_t len = (ret >= size) ? size - 1 : ret;
 +              memcpy(dest, src, len);
 +              dest[len] = '\0';
 +      }
 +      return ret;
  }
  
 +
  int validate_symref(const char *path)
  {
        struct stat st;
@@@ -267,11 -262,21 +267,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)