Commit Diff


commit - fe3e03730bfd3157ab843bcc845171585707e530f9f921b47910f3763a9f1258
commit + fab68aac687236e6e6735e36a71de37ee264317411c339884b08e5653a61b8aa
blob - e224b5960d870bfd4289b40ed93850ad305af61bf2092613bf12a2bedd2d4af5
blob + b48b1ba30008cb567395037cfe860dec3662dc2d7b70aa0ff4a2206500d8f95d
--- gotsysd/libexec/gotsys-repo-create/gotsys-repo-create.c	
+++ gotsysd/libexec/gotsys-repo-create/gotsys-repo-create.c	
@@ -81,9 +81,12 @@ sighdlr(int sig, short event, void *arg)
 	}
 }
 
-/* Ensure that repositories are only accessible to the gotd user. */
+/*
+ * Ensure that repositories are only writeable by the gotd user and
+ * readable by the gotd group.
+ */
 static const struct got_error *
-chmod_700_repo(const char *repo_name)
+chmod_750_repo(const char *repo_name)
 {
 	struct stat sb;
 
@@ -92,10 +95,11 @@ chmod_700_repo(const char *repo_name)
 		    repos_path, repo_name);
 	}
 
-	if (!S_ISDIR(sb.st_mode) || sb.st_uid != gotd_uid)
+	if (!S_ISDIR(sb.st_mode) || sb.st_uid != gotd_uid ||
+	    sb.st_gid != gotd_gid)
 		return NULL;
 
-	if (fchmodat(repos_dir_fd, repo_name, S_IRWXU,
+	if (fchmodat(repos_dir_fd, repo_name, S_IRWXU | S_IRGRP | S_IXGRP,
 	    AT_SYMLINK_NOFOLLOW) == -1) {
 		return got_error_from_errno_fmt("chmod %o %s/%s",
 		    S_IRWXU, repos_path, repo_name);
@@ -267,9 +271,10 @@ create_repo(struct imsg *imsg)
 		goto done;
 	}
 
-	if (mkdirat(repos_dir_fd, fullname, S_IRWXU) == -1) {
+	if (mkdirat(repos_dir_fd, fullname,
+	    S_IRWXU | S_IRGRP | S_IXGRP) == -1) {
 		if (errno == EEXIST) {
-			err = chmod_700_repo(fullname);
+			err = chmod_750_repo(fullname);
 			if (err)
 				goto done;
 			if (headref) {
blob - b78f413ceb124bca0a65ff9ac4708784baecc570064474ff9d1b1f980751862a
blob + cf1dc2245c1bcf28059108a6a47c471b4b5e6661338cc8652ade9c05bb00687e
--- regress/gotsysd/test_gotsysd.sh	
+++ regress/gotsysd/test_gotsysd.sh	
@@ -954,9 +954,9 @@ EOF
 		return 1
 	fi
 
-	# The repositories should have 700 permissions and be owned by _gotd.
+	# The repositories should have 750 permissions and be owned by _gotd.
 	ssh -q -i ${GOTSYSD_SSH_KEY} root@${VMIP} ls -l /git | \
-		grep -v ^total | awk '{print $1" "$3}' > $testroot/stdout
+		grep -v ^total | awk '{print $1" "$3" "$4}' > $testroot/stdout
 	ret=$?
 	if [ $ret -ne 0 ]; then
 		echo "ls /git failed unexpectedly" >&2
@@ -965,8 +965,8 @@ EOF
 	fi
 
 	cat > $testroot/stdout.expected <<EOF
-drwx------ _gotd
-drwx------ _gotd
+drwxr-x--- _gotd _gotd
+drwxr-x--- _gotd _gotd
 EOF
 	cmp -s $testroot/stdout.expected $testroot/stdout
 	ret=$?