commit d5996b9efcd57875669fb0b06006ecf8cf566272 from: Landry Breuil date: Mon Oct 31 17:52:53 2022 UTC add respect_exportok flag, defaulting to off allows to hide repositories if they have the magic git-daemon-export-ok file ok op@ tracey@ stsp@ commit - 585362fdeffda23f6ace02652caf7c5b0ecd4759 commit + d5996b9efcd57875669fb0b06006ecf8cf566272 blob - 62c8c986ac17851a371bfa80e6bdff7c7dd2084f blob + 89220d16dadb171f6bf179e5fa2d7118b94a4aad --- gotwebd/gotweb.c +++ gotwebd/gotweb.c @@ -2439,6 +2439,13 @@ gotweb_load_got_path(struct request *c, struct repo_di } done: + if (srv->respect_exportok && + faccessat(dirfd(dt), "git-daemon-export-ok", F_OK, 0) == -1) { + error = got_error_path(repo_dir->name, GOT_ERR_NOT_GIT_REPO); + goto err; + } + + repo = find_cached_repo(srv, repo_dir->path); if (repo == NULL) { error = cache_repo(&repo, srv, repo_dir, sock); blob - 82d73b6a9ce6b79982f543208398c56d6464e96d blob + 3b21405e0c045479879c333d2f5fd060bf11b6e6 --- gotwebd/gotwebd.conf.5 +++ gotwebd/gotwebd.conf.5 @@ -130,6 +130,10 @@ Set the maximum amount of repositories displayed on th .It Ic repos_path Ar path Set the path to the directory which contains Git repositories that the server should publish. +.It Ic respect_exportok Ar on | off +Set whether to display the repository only if it contains the magic +.Pa git-daemon-export-ok +file. .It Ic show_repo_age Ar on | off Toggle display of last repository modification date. .It Ic show_repo_cloneurl Ar on | off @@ -196,6 +200,8 @@ server "localhost-unix" { #show_repo_age false #show_repo_description no #show_repo_cloneurl off + # off by default + #respect_exportok on #max_repos 100 #max_repos_display 25 blob - 06f8d01516c1b327e8524a128e571a8cc082ca7e blob + a8a55276acbd0b209205938c75b88d6918b1c6b8 --- gotwebd/gotwebd.h +++ gotwebd/gotwebd.h @@ -71,6 +71,7 @@ #define D_SHOWAGE 1 #define D_SHOWDESC 1 #define D_SHOWURL 1 +#define D_RESPECTEXPORTOK 0 #define D_MAXREPO 0 #define D_MAXREPODISP 25 #define D_MAXSLCOMMDISP 10 @@ -278,6 +279,7 @@ struct server { int show_repo_age; int show_repo_description; int show_repo_cloneurl; + int respect_exportok; int unix_socket; char unix_socket_name[PATH_MAX]; blob - a343be03a8846c19af54d78c6da13c96303c3dde blob + 3fa61ab2a8f841eb1259a6824dbb7f5f17b32558 --- gotwebd/parse.y +++ gotwebd/parse.y @@ -121,7 +121,7 @@ typedef struct { %token LISTEN WWW_PATH MAX_REPOS SITE_NAME SITE_OWNER SITE_LINK LOGO %token LOGO_URL SHOW_REPO_OWNER SHOW_REPO_AGE SHOW_REPO_DESCRIPTION %token MAX_REPOS_DISPLAY REPOS_PATH MAX_COMMITS_DISPLAY ON ERROR -%token SHOW_SITE_OWNER SHOW_REPO_CLONEURL PORT PREFORK +%token SHOW_SITE_OWNER SHOW_REPO_CLONEURL PORT PREFORK RESPECT_EXPORTOK %token UNIX_SOCKET UNIX_SOCKET_NAME SERVER CHROOT CUSTOM_CSS %token STRING @@ -358,6 +358,9 @@ serveropts1 : REPOS_PATH STRING { | SHOW_REPO_CLONEURL boolean { new_srv->show_repo_cloneurl = $2; } + | RESPECT_EXPORTOK boolean { + new_srv->respect_exportok = $2; + } | MAX_REPOS_DISPLAY NUMBER { new_srv->max_repos_display = $2; } @@ -441,6 +444,7 @@ lookup(char *s) { "port", PORT }, { "prefork", PREFORK }, { "repos_path", REPOS_PATH }, + { "respect_exportok", RESPECT_EXPORTOK }, { "server", SERVER }, { "show_repo_age", SHOW_REPO_AGE }, { "show_repo_cloneurl", SHOW_REPO_CLONEURL }, @@ -877,6 +881,7 @@ conf_new_server(const char *name) srv->show_repo_age = D_SHOWAGE; srv->show_repo_description = D_SHOWDESC; srv->show_repo_cloneurl = D_SHOWURL; + srv->respect_exportok = D_RESPECTEXPORTOK; srv->max_repos_display = D_MAXREPODISP; srv->max_commits_display = D_MAXCOMMITDISP;