author | Felix Hanley <felix@seconddrawer.com.au> | 2010-11-08 18:41:13 (UTC) |
---|---|---|
committer | Lars Hjemli <hjemli@gmail.com> | 2010-11-08 18:41:13 (UTC) |
commit | e0c6f23789e4893781bcd5af2281d468991ccf3a (patch) (side-by-side diff) | |
tree | 1cffe4d35b6404dd59cd0f0a314e11944e37d0f2 | |
parent | 49d09d4fd1b0cab8189cf1809a1b1241f54c2e48 (diff) | |
download | cgit-e0c6f23789e4893781bcd5af2281d468991ccf3a.zip cgit-e0c6f23789e4893781bcd5af2281d468991ccf3a.tar.gz cgit-e0c6f23789e4893781bcd5af2281d468991ccf3a.tar.bz2 |
Add `strict-export` option
This option is used to specify a filename which needs to be present in
the repositories found during `scan-path` processing. By setting this
option to 'git-daemon-export-ok', only repositories explicitly marked
for git daemon export will be included in the cgit configuration.
Signed-off-by: Felix Hanley <felix@seconddrawer.com.au>
Signed-off-by: Lars Hjemli <hjemli@gmail.com>
-rw-r--r-- | cgit.c | 2 | ||||
-rw-r--r-- | cgit.h | 1 | ||||
-rw-r--r-- | cgitrc.5.txt | 7 | ||||
-rw-r--r-- | scan-tree.c | 4 |
4 files changed, 14 insertions, 0 deletions
@@ -112,24 +112,26 @@ void config_cb(const char *name, const char *value) else if (!strcmp(name, "header")) ctx.cfg.header = xstrdup(value); else if (!strcmp(name, "logo")) ctx.cfg.logo = xstrdup(value); else if (!strcmp(name, "index-header")) ctx.cfg.index_header = xstrdup(value); else if (!strcmp(name, "index-info")) ctx.cfg.index_info = xstrdup(value); else if (!strcmp(name, "logo-link")) ctx.cfg.logo_link = xstrdup(value); else if (!strcmp(name, "module-link")) ctx.cfg.module_link = xstrdup(value); + else if (!strcmp(name, "strict-export")) + ctx.cfg.strict_export = xstrdup(value); else if (!strcmp(name, "virtual-root")) { ctx.cfg.virtual_root = trim_end(value, '/'); if (!ctx.cfg.virtual_root && (!strcmp(value, "/"))) ctx.cfg.virtual_root = ""; } else if (!strcmp(name, "nocache")) ctx.cfg.nocache = atoi(value); else if (!strcmp(name, "noplainemail")) ctx.cfg.noplainemail = atoi(value); else if (!strcmp(name, "noheader")) ctx.cfg.noheader = atoi(value); else if (!strcmp(name, "snapshots")) ctx.cfg.snapshots = cgit_parse_snapshots_mask(value); @@ -167,24 +167,25 @@ struct cgit_config { char *logo; char *logo_link; char *module_link; char *project_list; char *readme; char *robots; char *root_title; char *root_desc; char *root_readme; char *script_name; char *section; char *virtual_root; + char *strict_export; int cache_size; int cache_dynamic_ttl; int cache_max_create_time; int cache_repo_ttl; int cache_root_ttl; int cache_scanrc_ttl; int cache_static_ttl; int embedded; int enable_filter_overrides; int enable_gitweb_owner; int enable_index_links; int enable_log_filecount; diff --git a/cgitrc.5.txt b/cgitrc.5.txt index ce78d41..75b6584 100644 --- a/cgitrc.5.txt +++ b/cgitrc.5.txt @@ -308,24 +308,31 @@ source-filter:: summary-branches:: Specifies the number of branches to display in the repository "summary" view. Default value: "10". summary-log:: Specifies the number of log entries to display in the repository "summary" view. Default value: "10". summary-tags:: Specifies the number of tags to display in the repository "summary" view. Default value: "10". +strict-export:: + Filename which, if specified, needs to be present within the repository + for cgit to allow access to that repository. This can be used to emulate + gitweb's EXPORT_OK and STRICT_EXPORT functionality and limit cgit's + repositories to match those exported by git-daemon. This option MUST come + before 'scan-path'. + virtual-root:: Url which, if specified, will be used as root for all cgit links. It will also cause cgit to generate 'virtual urls', i.e. urls like '/cgit/tree/README' as opposed to '?r=cgit&p=tree&path=README'. Default value: none. NOTE: cgit has recently learned how to use PATH_INFO to achieve the same kind of virtual urls, so this option will probably be deprecated. REPOSITORY SETTINGS ------------------- repo.about-filter:: Override the default about-filter. Default value: none. See also: diff --git a/scan-tree.c b/scan-tree.c index b5b50f3..a0e09ce 100644 --- a/scan-tree.c +++ b/scan-tree.c @@ -72,24 +72,28 @@ static void add_repo(const char *base, const char *path, repo_config_fn fn) { struct stat st; struct passwd *pwd; char *rel, *p, *slash; int n; size_t size; if (stat(path, &st)) { fprintf(stderr, "Error accessing %s: %s (%d)\n", path, strerror(errno), errno); return; } + + if (ctx.cfg.strict_export && stat(fmt("%s/%s", path, ctx.cfg.strict_export), &st)) + return; + if (!stat(fmt("%s/noweb", path), &st)) return; owner = NULL; if (ctx.cfg.enable_gitweb_owner) git_config_from_file(git_owner_config, fmt("%s/config", path), NULL); if (base == path) rel = xstrdup(fmt("%s", path)); else rel = xstrdup(fmt("%s", path + strlen(base) + 1)); if (!strcmp(rel + strlen(rel) - 5, "/.git")) |