pch += n;
}
- safe_strncpy(pch, template, len);
+ strlcpy(pch, template, len);
return mkstemp(path);
}
-char *safe_strncpy(char *dest, const char *src, size_t n)
-{
- strncpy(dest, src, n);
- dest[n - 1] = '\0';
-
- return dest;
-}
-
int validate_symref(const char *path)
{
struct stat st;
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)