commit dca4220f4aa2f7af92383fe1e31d2f8ff7e11b305c61377ef6d62fa5035727d4 from: Stefan Sperling date: Thu Feb 12 21:29:36 2026 UTC ensure visitors see the repository index page after logging into gotwebd If a repository URL path is set, include it in the login token URL. This should result in less surprising behaviour when a website is served from the root path "/" and does not require authentication, while autbentication is required to browse repositories at a different path. The gotwebd index page clearly indicates the user is now logged in, while the web site has static content which cannot indicate login status. This new behaviour might be imperfect in cases where a website requires authentication and the visitor is logging in to see it. But that is likely a fringe use case, and it should be easy to navigate back to the desired website after logging into gotwebd. commit - 014fbe8cd308fa0ef1839e98ae396df9dae27848ea84bb1fcd916d89e65b752c commit + dca4220f4aa2f7af92383fe1e31d2f8ff7e11b305c61377ef6d62fa5035727d4 blob - ee4064a232b61c2d01eff71193163f27af98ac563c2ed1a1d7b856fbdcd8c404 blob + 23560b79c2a1b5547a2a2d85b159c170110f3fa5c8c0bc83a36a9fff3e1e94b0 --- gotwebd/login.c +++ gotwebd/login.c @@ -503,7 +503,7 @@ client_read(struct bufferevent *bev, void *d) struct evbuffer *out = EVBUFFER_OUTPUT(bev); char *line, *cmd, *code; size_t linelen; - const char *hostname, *path = NULL; + const char *hostname, *path = NULL, *repos_path = NULL; if (client->cmd_done) { log_warnx("%s: client sent data even though login command " @@ -574,8 +574,13 @@ client_read(struct bufferevent *bev, void *d) !got_path_is_root_dir(srv->gotweb_url_root)) path = srv->gotweb_url_root; - if (evbuffer_add_printf(out, "ok https://%s%s/?login=%s\n", - hostname, path ? path : "", code) == -1) { + if (srv->repos_url_path[0] != '\0' && + !got_path_is_root_dir(srv->repos_url_path)) + repos_path = srv->repos_url_path; + + if (evbuffer_add_printf(out, "ok https://%s%s%s%s/?login=%s\n", + hostname, path ? path : "", path ? "/" : "", + repos_path ? repos_path : "", code) == -1) { log_warnx("%s: evbuffer_add_printf failed", __func__); client_err(bev, EVBUFFER_READ, client); free(code);