Commit Diff


commit - 5a95d4b0b4b549439308302575967da86108067b21d473c3714874ce1225f870
commit + ebaf990d1ad5d7f1769239144192edd718bcd85efc1260a4762c806e9a788311
blob - 4a3591f190287a8938dba7ab05c57be856f2acdaa06d716154314168d9bf6b97
blob + 79172a1e9461a26d60a83bc7c45d5986518a8ec65cc8db422978a449150c4a91
--- gotsys/parse.y	
+++ gotsys/parse.y	
@@ -627,6 +627,16 @@ webrepo		: REPOSITORY STRING {
 				YYERROR;
 			}
 
+			if (strcmp(new_webrepo->repo_name, "gotsys") == 0 ||
+			    strcmp(new_webrepo->repo_name, "gotsys.git") == 0) {
+				err = got_error_msg(GOT_ERR_PARSE_CONFIG,
+				    "\"gotsys\" repository cannot be used "
+				    "on the web");
+				yyerror("%s", err->msg);
+				free($2);
+				YYERROR;
+			}
+
 			webrepo = gotsys_find_webrepo_by_name(
 			    new_webrepo->repo_name,
 			    &new_webserver->repos);
@@ -749,6 +759,16 @@ websiteopts1	: PATH STRING {
 				YYERROR;
 			}
 
+			if (strcmp($2, "gotsys") == 0 ||
+			    strcmp($2, "gotsys.git") == 0) {
+				err = got_error_msg(GOT_ERR_PARSE_CONFIG,
+				    "\"gotsys\" repository cannot be used "
+				    "for web sites");
+				yyerror("%s", err->msg);
+				free($2);
+				YYERROR;
+			}
+
 			n = strlcpy(new_website->repo_name, $2,
 			    sizeof(new_website->repo_name));
 			if (n >= sizeof(new_website->repo_name)) {
blob - 08b0b6cdcd8b826033fd21783a6a766d3cd5b07e9ac75b45e6757402b7963af2
blob + d24c5455ee34c724ac68c046fde9cdd26f3f708f8752631233f3a6a78b70ec81
--- gotsysd/libexec/gotsys-write-conf/gotsys-write-conf.c	
+++ gotsysd/libexec/gotsys-write-conf/gotsys-write-conf.c	
@@ -926,6 +926,24 @@ write_gotd_conf(int *auth_idx)
 }
 
 static const struct got_error *
+hide_gotsys_repo(int fd, const char *path)
+{
+	int ret;
+
+	ret = dprintf(fd,
+	    "\trepository \"gotsys\" {\n"
+	    "\t\thide repository on\n"
+	    "\t\tenable authentication\n"
+	    "\t}\n");
+	if (ret == -1) 
+		return got_error_from_errno2("dprintf", path);
+	if (ret != 23 + 21 + 24 + 3)
+		return got_error_fmt(GOT_ERR_IO, "short write to %s", path);
+
+	return NULL;
+}
+
+static const struct got_error *
 write_webrepo(int *show_repo_description, int fd, const char *path,
     struct gotsys_webrepo *webrepo,
     enum gotsysd_web_auth_config webd_auth_config)
@@ -1349,6 +1367,10 @@ write_gotwebd_conf(void)
 
 			/* TODO mediatypes */
 
+			err = hide_gotsys_repo(fd, path);
+			if (err)
+				return err;
+
 			STAILQ_FOREACH(webrepo, &srv->repos, entry) {
 				err = write_webrepo(&show_repo_description,
 				    fd, path, webrepo, srv_cfg->auth_config);
@@ -2077,6 +2099,15 @@ dispatch_event(int fd, short event, void *arg)
 				free(webrepo);
 				break;
 			}
+			if (strcmp(repo->name, "gotsys") == 0 ||
+			    strcmp(repo->name, "gotsys.git") == 0) {
+				err = got_error_fmt(GOT_ERR_PRIVSEP_MSG,
+				    "gotsys repository cannot be used on "
+				    "the web");
+				free(webrepo);
+				break;
+			}
+
 			STAILQ_INSERT_TAIL(&srv->repos, webrepo, entry);
 			break;
 		}
@@ -2210,6 +2241,13 @@ dispatch_event(int fd, short event, void *arg)
 				    writeconf_state);
 				break;
 			}
+			if (strcmp(repo->name, "gotsys") == 0 ||
+			    strcmp(repo->name, "gotsys.git") == 0) {
+				err = got_error_fmt(GOT_ERR_PRIVSEP_MSG,
+				    "gotsys repository cannot be used for "
+				    "web sites");
+				break;
+			}
 			break;
 		}
 		case GOTSYSD_IMSG_SYSCONF_WEBSITE_ACCESS_RULE: {
blob - 5e1915c63829678923b5e0b98098164c567f55c1489a756000c81382db9d5fa5
blob + 353047283addd5eaf3d15e6d8316dd2ffe63c285797131f30c6e834f5e4b7524
--- regress/gotsysd/test_gotwebd.sh	
+++ regress/gotsysd/test_gotwebd.sh	
@@ -44,6 +44,9 @@ repository gotsys.git {
 	permit rw ${GOTSYSD_TEST_USER}
 	permit rw ${GOTSYSD_DEV_USER}
 }
+repository testrepo.git {
+	permit rw ${GOTSYSD_TEST_USER}
+}
 repository gotdev.git {
 	permit rw ${GOTSYSD_DEV_USER}
 }
@@ -51,7 +54,7 @@ repository hidden.git {
 	permit rw ${GOTSYSD_TEST_USER}
 }
 web server "${VMIP}" {
-	repository gotsys.git {
+	repository testrepo {
 		permit ${GOTSYSD_TEST_USER}
 	}
 	repository gotdev.git {
@@ -119,6 +122,41 @@ EOF
 		return 1
 	fi
 
+	got init $testroot/testrepo.git
+	ret=$?
+	if [ $ret -ne 0 ]; then
+		"got init failed unexpectedly"
+		test_done "$testroot" 1
+		return 1
+	fi
+
+	mkdir $testroot/import
+	echo "my plans are: ..." > $testroot/import/myplans.txt
+
+	got import -m init -r $testroot/testrepo.git $testroot/import > /dev/null
+	ret=$?
+	if [ $ret -ne 0 ]; then
+		"got import failed unexpectedly"
+		test_done "$testroot" 1
+		return 1
+	fi
+
+	cat >> $testroot/testrepo.git/got.conf <<EOF
+remote "origin" {
+	server ${GOTSYSD_TEST_USER}@${VMIP}
+	protocol ssh
+	repository testrepo
+}
+EOF
+
+	got send -q -f -i ${GOTSYSD_SSH_KEY} -r $testroot/testrepo.git
+	ret=$?
+	if [ $ret -ne 0 ]; then
+		"got send failed unexpectedly"
+		test_done "$testroot" 1
+		return 1
+	fi
+
 	# Obtain a login token over ssh.
 	ssh -q -i ${GOTSYSD_SSH_KEY} ${GOTSYSD_TEST_USER}@${VMIP} \
 		'gotsh -c weblogin' > $testroot/stdout
@@ -137,7 +175,7 @@ EOF
 [got]
 Repos
 Project
-gotsys.git
+testrepo.git
 summary | briefs | commits | tags | tree | rss
 -------------------------------------------------------------------------------
 
@@ -152,19 +190,19 @@ EOF
 
 	# Request a tree page using the stored cookie.
 	w3m -cookie-jar "$testroot/cookies" \
-		"http://${VMIP}/?action=tree&path=gotsys.git" -dump \
+		"http://${VMIP}/?action=tree&path=testrepo.git" -dump \
 		> $testroot/stdout
 
-	local commit_id=`git_show_head $testroot/${GOTSYS_REPO}`
-	local commit_time=`git_show_author_time $testroot/${GOTSYS_REPO} $commit_id`
+	local commit_id=`git_show_head $testroot/testrepo.git`
+	local commit_time=`git_show_author_time $testroot/testrepo.git $commit_id`
 	local d=$(env LC_ALL=C date -u -r "$commit_time" \
 		+"%a %b %e %H:%M:%S %Y UTC" | sed -e 's/  / /')
-	local tree_id=$(got cat -r $testroot/${GOTSYS_REPO} $commit_id | \
+	local tree_id=$(got cat -r $testroot/testrepo.git $commit_id | \
 		grep 'tree ' | cut -d ' ' -f2)
 
 	cat > $testroot/stdout.expected <<EOF
 [got]
-Repos / gotsys.git / tree /
+Repos / testrepo.git / tree /
 
 Tree
 
@@ -173,11 +211,11 @@ Tree:
 Date:
     $d
 Message:
-    configure web server
+    init
 
 -------------------------------------------------------------------------------
 
-gotsys.conf commits | blame
+myplans.txt commits | blame
 
 EOF
 	cmp -s $testroot/stdout.expected $testroot/stdout
@@ -189,7 +227,7 @@ EOF
 	fi
 
 	# Attempt to access the same page again without the cookie.
-	w3m "http://${VMIP}/?action=tree&path=gotsys.git" -dump \
+	w3m "http://${VMIP}/?action=tree&path=testrepo.git" -dump \
 		> $testroot/stdout
 
 	local commit_id=`git_show_head $testroot/${GOTSYS_REPO}`
@@ -198,7 +236,7 @@ EOF
 
 	cat > $testroot/stdout.expected <<EOF
 [got]
-Repos / gotsys.git / tree /
+Repos / testrepo.git / tree /
 Log in by running: ssh ${GOTSYSD_TEST_USER}@${VMIP} "weblogin ${VMIP}"
 
 EOF
@@ -278,9 +316,6 @@ repository hidden.git {
 	permit rw ${GOTSYSD_TEST_USER}
 }
 web server "${VMIP}" {
-	repository gotsys.git {
-		permit ${GOTSYSD_TEST_USER}
-	}
 	repository public.git {
 		disable authentication
 	}
@@ -368,9 +403,6 @@ EOF
 [got]
 Repos
 Project
-gotsys.git
-summary | briefs | commits | tags | tree | rss
--------------------------------------------------------------------------------
 gottest.git
 summary | briefs | commits | tags | tree | rss
 -------------------------------------------------------------------------------
@@ -464,9 +496,6 @@ repository hidden.git {
 	permit rw ${GOTSYSD_TEST_USER}
 }
 web server "${VMIP}" {
-	repository gotsys.git {
-		permit ${GOTSYSD_TEST_USER}
-	}
 	repository public {
 		disable authentication
 	}
@@ -574,9 +603,6 @@ EOF
 [got]
 Repos
 Project
-gotsys.git
-summary | briefs | commits | tags | tree | rss
--------------------------------------------------------------------------------
 gottest.git
 summary | briefs | commits | tags | tree | rss
 -------------------------------------------------------------------------------
blob - cff92b0d90fe86bb05f0abd0b34fe181704b232225526935c0536bffe3559b4b
blob + 3c40f53035f4bf4fd1464a10c17b564ed72fcc7e1324aa1c0b90eb9eb0aabc54
--- regress/gotsysd/test_gotwebd_repos_www.sh	
+++ regress/gotsysd/test_gotwebd_repos_www.sh	
@@ -50,10 +50,6 @@ repository www {
 	permit rw ${GOTSYSD_DEV_USER}
 }
 web server "${VMIP}" {
-	repository gotsys {
-		hide repository on
-	}
-
 	repositories url path "/"
 
 	website "/website" {
blob - 8314c8c3a4af783200c6b7167685dd5a5f0e870ebde156d745e0579c2f054c7d
blob + a78f6c00f7da7b68e4b79ab5ea5328e23643a4002b4db583a4d2d7fdccf0494a
--- regress/gotsysd/test_gotwebd_www.sh	
+++ regress/gotsysd/test_gotwebd_www.sh	
@@ -51,10 +51,6 @@ repository www {
 }
 
 web server "${VMIP}" {
-	repository gotsys {
-		hide repository on
-	}
-
 	repositories url path "/repos"
 
 	website "/" {