commit ebaf990d1ad5d7f1769239144192edd718bcd85efc1260a4762c806e9a788311 from: Stefan Sperling date: Mon Jan 26 14:07:37 2026 UTC hide the gotsys.git repository from web browsers Forbid use of gotsys.git in gotsys.conf in web server or web site context. Always set gotsys.git to hidden in /etc/gotwebd.conf. Just in case, enable authentication for gotsys.git in /etc/gotwebd.conf as well. This should never apply in practice since the repository is hidden. 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 < $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 < $testroot/stdout local commit_id=`git_show_head $testroot/${GOTSYS_REPO}` @@ -198,7 +236,7 @@ EOF cat > $testroot/stdout.expected <