git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH] gitweb: option 'strict export'

From
MLMatthias Lederhofer <matled@gmx.net>
Date
Sep 16, 2006, 21:43 UTC
Message-ID
<20060916214323.GA21637@moooo.ath.cx>
In-Reply-To
<20060916192750.GA27008@moooo.ath.cx>

With this option enabled gitweb will only give access to repositories which are also shown on the overview page. --- Matthias Lederhofer <matled@gmx.net> wrote:

> Perhaps there should be another option which allows only those
> repositories to be shown which are in $projects_list.
Here it is.  This option is probably the one more likely to be used.
It disallows access to repositories (using ?p=path/to/repository) that
are not on the projects-list-page.
---
 Makefile           |    2 ++
 gitweb/gitweb.perl |   12 +++++++++++-
 2 files changed, 13 insertions(+), 1 deletions(-)
diff --git a/Makefile b/Makefile
index 63df24c..0e17d4c 100644
--- a/Makefile
+++ b/Makefile
@@ -133,6 +133,7 @@ GITWEB_CSS = gitweb.css
 GITWEB_LOGO = git-logo.png
 GITWEB_FAVICON = git-favicon.png
 GITWEB_EXPORT_OK =
+GITWEB_STRICT_EXPORT =
 
 export prefix bindir gitexecdir template_dir GIT_PYTHON_DIR
 
@@ -639,6 +640,7 @@ gitweb/gitweb.cgi: gitweb/gitweb.perl
 	    -e 's|++GITWEB_LOGO++|$(GITWEB_LOGO)|g' \
 	    -e 's|++GITWEB_FAVICON++|$(GITWEB_FAVICON)|g' \
 	    -e 's|++GITWEB_EXPORT_OK++|$(GITWEB_EXPORT_OK)|g' \
+	    -e 's|++GITWEB_STRICT_EXPORT++|$(GITWEB_STRICT_EXPORT)|g' \
 	    $< >$@+
 	chmod +x $@+
 	mv $@+ $@
diff --git a/gitweb/gitweb.perl b/gitweb/gitweb.perl
index 3944d13..976f7ec 100755
--- a/gitweb/gitweb.perl
+++ b/gitweb/gitweb.perl
@@ -57,6 +57,9 @@ our $projects_list = "++GITWEB_LIST++";
 # show repository only if this file exists
 our $export_ok = "++GITWEB_EXPORT_OK++";
 
+# only allow viewing of repositories also shown on the overview page
+our $strict_export = "++GITWEB_STRICT_EXPORT++";
+
 # list of git base URLs used for URL to where fetch project from,
 # i.e. full URL is "$git_base_url/$project"
 our @git_base_url_list = ("++GITWEB_BASE_URL++");
@@ -189,7 +192,8 @@ if (defined $project) {
 	}
 	if (!(-d "$projectroot/$project") ||
 	    !(-e "$projectroot/$project/HEAD") ||
-	    ($export_ok && !(-e "$projectroot/$project/$export_ok"))) {
+	    ($export_ok && !(-e "$projectroot/$project/$export_ok")) ||
+	    ($strict_export && !project_in_list($project))) {
 		undef $project;
 		die_error(undef, "No such project");
 	}
@@ -384,6 +388,12 @@ sub untabify {
 	return $line;
 }
 
+sub project_in_list {
+	my $project = shift;
+	my @list = git_get_projects_list();
+	return(@list && scalar(grep { $_->{'path'} eq $project } @list) != 0);
+}
+
 ## ----------------------------------------------------------------------
 ## HTML aware string manipulation
 
-- 
1.4.2.g0ea2
Previous: Jakub NarebskiNext: Matthias Lederhofer
Message 6 of 15 in “gitweb: export-ok option”
  1. gitweb: export-ok optionMatthias Lederhofer, Sep 16, 2006
  2. Jakub NarebskiSep 16, 2006
  3. Matthias LederhoferSep 16, 2006
  4. Junio C HamanoSep 16, 2006
  5. Jakub NarebskiSep 16, 2006
  6. gitweb: option 'strict export'Matthias Lederhofer, Sep 16, 2006
  7. gitweb: do not use 'No such directory' error messageMatthias Lederhofer, Sep 16, 2006
  8. gitweb: export optionsMatthias Lederhofer, Sep 16, 2006
  9. Junio C HamanoSep 17, 2006
  10. Matthias LederhoferSep 17, 2006
  11. Junio C HamanoSep 17, 2006
  12. gitweb: fix warnings in PATH_INFO code and add export_ok/strict_exportMatthias Lederhofer, Sep 17, 2006
  13. Junio C HamanoSep 17, 2006
  14. Jakub NarebskiSep 17, 2006
  15. Junio C HamanoSep 17, 2006

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.