commit 3991b2a5fc4bf9e028e24e4ea4f7f66f1ed4ff6c from: Landry Breuil via: Thomas Adam date: Mon Oct 31 17:56:02 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 - 832b8374d8cbbf52cd6ec6fe305aae8bbddd930f commit + 3991b2a5fc4bf9e028e24e4ea4f7f66f1ed4ff6c blob - d1f211ae16cc4d051601f487fd12c9919998f7bd blob + 47405eecdb089c1597bbe2dc967b3c2de677e97a --- 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 - 0f2104fd08adfe765d0eb0291769ef85ac01c9f2 blob + 3a2aa91c3991dd23b5f51d3ceb3d8d4e5487763d --- gotwebd/parse.y +++ gotwebd/parse.y @@ -120,7 +120,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 @@ -357,6 +357,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; } @@ -440,6 +443,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 }, @@ -876,6 +880,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;