History

Merge branch 'dm/disable-clone'

Lars Hjemli committed 15 years ago

Commit 4837fdd2 parents 568d8d3 aae06715 files · +40 −23Browse files

Unified · Split

5 files
  1. cgit.c +11 −1
  2. cgit.h +1 −0
  3. cgitrc.5.txt +5 −0
  4. cmd.c +21 −21
  5. cmd.h +2 −1
cgit.c+11−1
@@ -147,6 +147,8 @@ void config_cb(const char *name, const char *value) · 146 unmodified lines
147147 ctx.cfg.enable_filter_overrides = atoi(value);
148148 else if (!strcmp(name, "enable-gitweb-owner"))
149149 ctx.cfg.enable_gitweb_owner = atoi(value);
150+ else if (!strcmp(name, "enable-http-clone"))
151+ ctx.cfg.enable_http_clone = atoi(value);
150152 else if (!strcmp(name, "enable-index-links"))
151153 ctx.cfg.enable_index_links = atoi(value);
152154 else if (!strcmp(name, "enable-commit-graph"))
@@ -312,6 +314,7 @@ static void prepare_context(struct cgit_context *ctx) · 159 unmodified lines
312314 ctx->cfg.logo = "/cgit.png";
313315 ctx->cfg.local_time = 0;
314316 ctx->cfg.enable_gitweb_owner = 1;
317+ ctx->cfg.enable_http_clone = 1;
315318 ctx->cfg.enable_tree_linenumbers = 1;
316319 ctx->cfg.max_repo_count = 50;
317320 ctx->cfg.max_commit_count = 50;
@@ -439,7 +442,7 @@ static int prepare_repo_cmd(struct cgit_context *ctx) · 121 unmodified lines
439442 tmp = xstrdup(ctx->qry.head);
440443 ctx->qry.head = ctx->repo->defbranch;
441444 ctx->page.status = 404;
442− ctx->page.statusmsg = "not found";
445+ ctx->page.statusmsg = "Not found";
443446 cgit_print_http_headers(ctx);
444447 cgit_print_docstart(ctx);
445448 cgit_print_pageheader(ctx);
@@ -458,6 +461,8 @@ static void process_request(void *cbdata) · 12 unmodified lines
458461 cmd = cgit_get_cmd(ctx);
459462 if (!cmd) {
460463 ctx->page.title = "cgit error";
464+ ctx->page.status = 404;
465+ ctx->page.statusmsg = "Not found";
461466 cgit_print_http_headers(ctx);
462467 cgit_print_docstart(ctx);
463468 cgit_print_pageheader(ctx);
@@ -466,6 +471,11 @@ static void process_request(void *cbdata) · 2 unmodified lines
466471 return;
467472 }
468473
474+ if (!ctx->cfg.enable_http_clone && cmd->is_clone) {
475+ html_status(404, "Not found", 0);
476+ return;
477+ }
478+
469479 /* If cmd->want_vpath is set, assume ctx->qry.path contains a "virtual"
470480 * in-project path limit to be made available at ctx->qry.vpath.
471481 * Otherwise, no path limit is in effect (ctx->qry.vpath = NULL).
cgit.h+1−0
@@ -191,6 +191,7 @@ struct cgit_config { · 190 unmodified lines
191191 int embedded;
192192 int enable_filter_overrides;
193193 int enable_gitweb_owner;
194+ int enable_http_clone;
194195 int enable_index_links;
195196 int enable_commit_graph;
196197 int enable_log_filecount;
cgitrc.5.txt+5−0
@@ -105,6 +105,11 @@ enable-gitweb-owner:: · 104 unmodified lines
105105 for the git config value "gitweb.owner" to determine the owner.
106106 Default value: "1". See also: scan-path.
107107
108+enable-http-clone::
109+ If set to "1", cgit will act as an dumb HTTP endpoint for git clones.
110+ If you use an alternate way of serving git repositories, you may wish
111+ to disable this. Default value: "1".
112+
108113 enable-index-links::
109114 Flag which, when set to "1", will make cgit generate extra links for
110115 each repo in the repository index (specifically, to the "summary",
cmd.c+21−21
@@ -130,31 +130,31 @@ static void tree_fn(struct cgit_context *ctx) · 129 unmodified lines
130130 cgit_print_tree(ctx->qry.sha1, ctx->qry.path);
131131 }
132132
133−#define def_cmd(name, want_repo, want_layout, want_vpath) \
134− {#name, name##_fn, want_repo, want_layout, want_vpath}
133+#define def_cmd(name, want_repo, want_layout, want_vpath, is_clone) \
134+ {#name, name##_fn, want_repo, want_layout, want_vpath, is_clone}
135135
136136 struct cgit_cmd *cgit_get_cmd(struct cgit_context *ctx)
137137 {
138138 static struct cgit_cmd cmds[] = {
139− def_cmd(HEAD, 1, 0, 0),
140− def_cmd(atom, 1, 0, 0),
141− def_cmd(about, 0, 1, 0),
142− def_cmd(blob, 1, 0, 0),
143− def_cmd(commit, 1, 1, 1),
144− def_cmd(diff, 1, 1, 1),
145− def_cmd(info, 1, 0, 0),
146− def_cmd(log, 1, 1, 1),
147− def_cmd(ls_cache, 0, 0, 0),
148− def_cmd(objects, 1, 0, 0),
149− def_cmd(patch, 1, 0, 1),
150− def_cmd(plain, 1, 0, 0),
151− def_cmd(refs, 1, 1, 0),
152− def_cmd(repolist, 0, 0, 0),
153− def_cmd(snapshot, 1, 0, 0),
154− def_cmd(stats, 1, 1, 1),
155− def_cmd(summary, 1, 1, 0),
156− def_cmd(tag, 1, 1, 0),
157− def_cmd(tree, 1, 1, 1),
139+ def_cmd(HEAD, 1, 0, 0, 1),
140+ def_cmd(atom, 1, 0, 0, 0),
141+ def_cmd(about, 0, 1, 0, 0),
142+ def_cmd(blob, 1, 0, 0, 0),
143+ def_cmd(commit, 1, 1, 1, 0),
144+ def_cmd(diff, 1, 1, 1, 0),
145+ def_cmd(info, 1, 0, 0, 1),
146+ def_cmd(log, 1, 1, 1, 0),
147+ def_cmd(ls_cache, 0, 0, 0, 0),
148+ def_cmd(objects, 1, 0, 0, 1),
149+ def_cmd(patch, 1, 0, 1, 0),
150+ def_cmd(plain, 1, 0, 0, 0),
151+ def_cmd(refs, 1, 1, 0, 0),
152+ def_cmd(repolist, 0, 0, 0, 0),
153+ def_cmd(snapshot, 1, 0, 0, 0),
154+ def_cmd(stats, 1, 1, 1, 0),
155+ def_cmd(summary, 1, 1, 0, 0),
156+ def_cmd(tag, 1, 1, 0, 0),
157+ def_cmd(tree, 1, 1, 1, 0),
158158 };
159159 int i;
160160
cmd.h+2−1
@@ -8,7 +8,8 @@ struct cgit_cmd { · 7 unmodified lines
88 cgit_cmd_fn fn;
99 unsigned int want_repo:1,
1010 want_layout:1,
11− want_vpath:1;
11+ want_vpath:1,
12+ is_clone:1;
1213 };
1314
1415 extern struct cgit_cmd *cgit_get_cmd(struct cgit_context *ctx);