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) (unidiff) | |
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) | |||
112 | else if (!strcmp(name, "header")) | 112 | else if (!strcmp(name, "header")) |
113 | ctx.cfg.header = xstrdup(value); | 113 | ctx.cfg.header = xstrdup(value); |
114 | else if (!strcmp(name, "logo")) | 114 | else if (!strcmp(name, "logo")) |
115 | ctx.cfg.logo = xstrdup(value); | 115 | ctx.cfg.logo = xstrdup(value); |
116 | else if (!strcmp(name, "index-header")) | 116 | else if (!strcmp(name, "index-header")) |
117 | ctx.cfg.index_header = xstrdup(value); | 117 | ctx.cfg.index_header = xstrdup(value); |
118 | else if (!strcmp(name, "index-info")) | 118 | else if (!strcmp(name, "index-info")) |
119 | ctx.cfg.index_info = xstrdup(value); | 119 | ctx.cfg.index_info = xstrdup(value); |
120 | else if (!strcmp(name, "logo-link")) | 120 | else if (!strcmp(name, "logo-link")) |
121 | ctx.cfg.logo_link = xstrdup(value); | 121 | ctx.cfg.logo_link = xstrdup(value); |
122 | else if (!strcmp(name, "module-link")) | 122 | else if (!strcmp(name, "module-link")) |
123 | ctx.cfg.module_link = xstrdup(value); | 123 | ctx.cfg.module_link = xstrdup(value); |
124 | else if (!strcmp(name, "strict-export")) | ||
125 | ctx.cfg.strict_export = xstrdup(value); | ||
124 | else if (!strcmp(name, "virtual-root")) { | 126 | else if (!strcmp(name, "virtual-root")) { |
125 | ctx.cfg.virtual_root = trim_end(value, '/'); | 127 | ctx.cfg.virtual_root = trim_end(value, '/'); |
126 | if (!ctx.cfg.virtual_root && (!strcmp(value, "/"))) | 128 | if (!ctx.cfg.virtual_root && (!strcmp(value, "/"))) |
127 | ctx.cfg.virtual_root = ""; | 129 | ctx.cfg.virtual_root = ""; |
128 | } else if (!strcmp(name, "nocache")) | 130 | } else if (!strcmp(name, "nocache")) |
129 | ctx.cfg.nocache = atoi(value); | 131 | ctx.cfg.nocache = atoi(value); |
130 | else if (!strcmp(name, "noplainemail")) | 132 | else if (!strcmp(name, "noplainemail")) |
131 | ctx.cfg.noplainemail = atoi(value); | 133 | ctx.cfg.noplainemail = atoi(value); |
132 | else if (!strcmp(name, "noheader")) | 134 | else if (!strcmp(name, "noheader")) |
133 | ctx.cfg.noheader = atoi(value); | 135 | ctx.cfg.noheader = atoi(value); |
134 | else if (!strcmp(name, "snapshots")) | 136 | else if (!strcmp(name, "snapshots")) |
135 | ctx.cfg.snapshots = cgit_parse_snapshots_mask(value); | 137 | ctx.cfg.snapshots = cgit_parse_snapshots_mask(value); |
@@ -167,24 +167,25 @@ struct cgit_config { | |||
167 | char *logo; | 167 | char *logo; |
168 | char *logo_link; | 168 | char *logo_link; |
169 | char *module_link; | 169 | char *module_link; |
170 | char *project_list; | 170 | char *project_list; |
171 | char *readme; | 171 | char *readme; |
172 | char *robots; | 172 | char *robots; |
173 | char *root_title; | 173 | char *root_title; |
174 | char *root_desc; | 174 | char *root_desc; |
175 | char *root_readme; | 175 | char *root_readme; |
176 | char *script_name; | 176 | char *script_name; |
177 | char *section; | 177 | char *section; |
178 | char *virtual_root; | 178 | char *virtual_root; |
179 | char *strict_export; | ||
179 | int cache_size; | 180 | int cache_size; |
180 | int cache_dynamic_ttl; | 181 | int cache_dynamic_ttl; |
181 | int cache_max_create_time; | 182 | int cache_max_create_time; |
182 | int cache_repo_ttl; | 183 | int cache_repo_ttl; |
183 | int cache_root_ttl; | 184 | int cache_root_ttl; |
184 | int cache_scanrc_ttl; | 185 | int cache_scanrc_ttl; |
185 | int cache_static_ttl; | 186 | int cache_static_ttl; |
186 | int embedded; | 187 | int embedded; |
187 | int enable_filter_overrides; | 188 | int enable_filter_overrides; |
188 | int enable_gitweb_owner; | 189 | int enable_gitweb_owner; |
189 | int enable_index_links; | 190 | int enable_index_links; |
190 | int enable_log_filecount; | 191 | 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:: | |||
308 | summary-branches:: | 308 | summary-branches:: |
309 | Specifies the number of branches to display in the repository "summary" | 309 | Specifies the number of branches to display in the repository "summary" |
310 | view. Default value: "10". | 310 | view. Default value: "10". |
311 | 311 | ||
312 | summary-log:: | 312 | summary-log:: |
313 | Specifies the number of log entries to display in the repository | 313 | Specifies the number of log entries to display in the repository |
314 | "summary" view. Default value: "10". | 314 | "summary" view. Default value: "10". |
315 | 315 | ||
316 | summary-tags:: | 316 | summary-tags:: |
317 | Specifies the number of tags to display in the repository "summary" | 317 | Specifies the number of tags to display in the repository "summary" |
318 | view. Default value: "10". | 318 | view. Default value: "10". |
319 | 319 | ||
320 | strict-export:: | ||
321 | Filename which, if specified, needs to be present within the repository | ||
322 | for cgit to allow access to that repository. This can be used to emulate | ||
323 | gitweb's EXPORT_OK and STRICT_EXPORT functionality and limit cgit's | ||
324 | repositories to match those exported by git-daemon. This option MUST come | ||
325 | before 'scan-path'. | ||
326 | |||
320 | virtual-root:: | 327 | virtual-root:: |
321 | Url which, if specified, will be used as root for all cgit links. It | 328 | Url which, if specified, will be used as root for all cgit links. It |
322 | will also cause cgit to generate 'virtual urls', i.e. urls like | 329 | will also cause cgit to generate 'virtual urls', i.e. urls like |
323 | '/cgit/tree/README' as opposed to '?r=cgit&p=tree&path=README'. Default | 330 | '/cgit/tree/README' as opposed to '?r=cgit&p=tree&path=README'. Default |
324 | value: none. | 331 | value: none. |
325 | NOTE: cgit has recently learned how to use PATH_INFO to achieve the | 332 | NOTE: cgit has recently learned how to use PATH_INFO to achieve the |
326 | same kind of virtual urls, so this option will probably be deprecated. | 333 | same kind of virtual urls, so this option will probably be deprecated. |
327 | 334 | ||
328 | REPOSITORY SETTINGS | 335 | REPOSITORY SETTINGS |
329 | ------------------- | 336 | ------------------- |
330 | repo.about-filter:: | 337 | repo.about-filter:: |
331 | Override the default about-filter. Default value: none. See also: | 338 | 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) | |||
72 | { | 72 | { |
73 | struct stat st; | 73 | struct stat st; |
74 | struct passwd *pwd; | 74 | struct passwd *pwd; |
75 | char *rel, *p, *slash; | 75 | char *rel, *p, *slash; |
76 | int n; | 76 | int n; |
77 | size_t size; | 77 | size_t size; |
78 | 78 | ||
79 | if (stat(path, &st)) { | 79 | if (stat(path, &st)) { |
80 | fprintf(stderr, "Error accessing %s: %s (%d)\n", | 80 | fprintf(stderr, "Error accessing %s: %s (%d)\n", |
81 | path, strerror(errno), errno); | 81 | path, strerror(errno), errno); |
82 | return; | 82 | return; |
83 | } | 83 | } |
84 | |||
85 | if (ctx.cfg.strict_export && stat(fmt("%s/%s", path, ctx.cfg.strict_export), &st)) | ||
86 | return; | ||
87 | |||
84 | if (!stat(fmt("%s/noweb", path), &st)) | 88 | if (!stat(fmt("%s/noweb", path), &st)) |
85 | return; | 89 | return; |
86 | 90 | ||
87 | owner = NULL; | 91 | owner = NULL; |
88 | if (ctx.cfg.enable_gitweb_owner) | 92 | if (ctx.cfg.enable_gitweb_owner) |
89 | git_config_from_file(git_owner_config, fmt("%s/config", path), NULL); | 93 | git_config_from_file(git_owner_config, fmt("%s/config", path), NULL); |
90 | if (base == path) | 94 | if (base == path) |
91 | rel = xstrdup(fmt("%s", path)); | 95 | rel = xstrdup(fmt("%s", path)); |
92 | else | 96 | else |
93 | rel = xstrdup(fmt("%s", path + strlen(base) + 1)); | 97 | rel = xstrdup(fmt("%s", path + strlen(base) + 1)); |
94 | 98 | ||
95 | if (!strcmp(rel + strlen(rel) - 5, "/.git")) | 99 | if (!strcmp(rel + strlen(rel) - 5, "/.git")) |