commit f05467224f503defae2df3307dee4164a17153c24983ac91d86889cad02564bb from: Stefan Sperling date: Wed Feb 4 22:08:58 2026 UTC make gotsys-write-conf set the clone_url option in gotwebd.conf If the web login hint user (usually "anonymous") has access to a repository via SSH we now add a corresponding clone_url option to /etc/gotwebd.conf. commit - 59ec6f30d83e4bdac0699743000c51dc4a55230de4ac589d4d6ff2dc3d432315 commit + f05467224f503defae2df3307dee4164a17153c24983ac91d86889cad02564bb blob - 9171a9ae307f324ed57415a349f60aa7870b05f23d276988ba0a96d083fea977 blob + 9eee6d0f402e06fef3af1417c73a3e825f02ec0a4ec92b5e3908fd0f88c5a1d9 --- gotsysd/libexec/gotsys-write-conf/gotsys-write-conf.c +++ gotsysd/libexec/gotsys-write-conf/gotsys-write-conf.c @@ -956,7 +956,7 @@ static const struct got_error * write_webrepo(int *show_repo_description, int *login_hint_user_access, int fd, const char *path, struct gotsys_webrepo *webrepo, enum gotsysd_web_auth_config webd_auth_config, - int hide_repositories) + int hide_repositories, const char *server_name) { const struct got_error *err; struct gotsys_repo *repo; @@ -964,6 +964,7 @@ write_webrepo(int *show_repo_description, int *login_h char repo_name[_POSIX_PATH_MAX]; size_t namelen; int have_login_hint_user = 0; + int login_hint_user_has_repo_access = 0; namelen = strlcpy(repo_name, webrepo->repo_name, sizeof(repo_name)); if (namelen >= sizeof(repo_name)) { @@ -1021,6 +1022,55 @@ write_webrepo(int *show_repo_description, int *login_h *show_repo_description = 1; } + if (repo) { + struct gotsys_access_rule *rule; + + STAILQ_FOREACH(rule, &repo->access_rules, entry) { + if (rule->access == GOTSYS_ACCESS_PERMITTED && + strcmp(rule->identifier, + webcfg.login_hint_user) == 0) { + login_hint_user_has_repo_access = 1; + break; + } + } + } + + if (!login_hint_user_has_repo_access) { + struct gotsys_access_rule *rule; + + STAILQ_FOREACH(rule, &global_repo_access_rules, entry) { + if (rule->access == GOTSYS_ACCESS_PERMITTED && + strcmp(rule->identifier, + webcfg.login_hint_user) == 0) { + login_hint_user_has_repo_access = 1; + break; + } + } + } + + if (login_hint_user_has_repo_access) { + char *clone_url; + + if (asprintf(&clone_url, "ssh://%s@%s%s%s/%s.git", + webcfg.login_hint_user, server_name, + webcfg.login_hint_port[0] ? ":" : "", + webcfg.login_hint_port[0] ? webcfg.login_hint_port : "", + repo_name) == -1) + return got_error_from_errno("asprintf"); + + ret = dprintf(fd, "\t\tclone_url \"%s\"\n", clone_url); + if (ret == -1) { + free(clone_url); + return got_error_from_errno2("dprintf", path); + } + if (ret != 14 + strlen(clone_url) + 1) { + free(clone_url); + return got_error_fmt(GOT_ERR_IO, + "short write to %s", path); + } + free(clone_url); + } + ret = dprintf(fd, "\t}\n"); if (ret == -1) return got_error_from_errno2("dprintf", path); @@ -1379,7 +1429,7 @@ write_gotwebd_conf(void) err = write_webrepo(&show_repo_description, &login_hint_user_access, fd, path, webrepo, srv_cfg->auth_config, - hide_repositories); + hide_repositories, srv_cfg->server_name); if (err) return err; } blob - 103ef52df64b6f7a3c9db31d17bcdaec4dbfe439e5458b9790f50369f9df9d3a blob + 1bdaac536d1e89109c9deae62efed0bc5d32cf7725b59a766bd7dddb530389a1 --- regress/gotsysd/test_gotwebd.sh +++ regress/gotsysd/test_gotwebd.sh @@ -642,7 +642,185 @@ EOF test_done "$testroot" "$ret" } +test_summary_page() { + local testroot=`test_init summary_page 1` + + got checkout -q $testroot/${GOTSYS_REPO} $testroot/wt >/dev/null + ret=$? + if [ $ret -ne 0 ]; then + echo "got checkout failed unexpectedly" >&2 + test_done "$testroot" 1 + return 1 + fi + + crypted_vm_pw=`echo ${GOTSYSD_VM_PASSWORD} | encrypt | tr -d '\n'` + crypted_pw=`echo ${GOTSYSD_DEV_PASSWORD} | encrypt | tr -d '\n'` + sshkey=`cat ${GOTSYSD_SSH_PUBKEY}` + cat > ${testroot}/wt/gotsys.conf <