about summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorChristian Hesse2018-06-07 21:31:28 +0200
committerJason A. Donenfeld2018-07-03 20:37:44 +0200
commit7ba41963dde175581ae7b395045fd51678237930 (patch)
tree72df4e03388644a243d3a4d18b055f45b707d860
parentextra-head-content: introduce another option for meta tags (diff)
downloadcgit-7ba41963dde175581ae7b395045fd51678237930.tar.gz
cgit-7ba41963dde175581ae7b395045fd51678237930.zip
snapshot: support tar signature for compressed tar
This adds support for kernel.org style signatures where the uncompressed
tar archive is signed and compressed later. The signature is valid for
all tar* snapshots.

We have a filter which snapshots may be generated and downloaded. This has
to allow tar signatures now even if tar itself is not allowed. To simplify
things we allow all signatures.

Signed-off-by: Christian Hesse <mail@eworm.de>
-rw-r--r--ui-shared.c9
-rw-r--r--ui-snapshot.c3
2 files changed, 10 insertions, 2 deletions
diff --git a/ui-shared.c b/ui-shared.c index 9a2e382..066a470 100644 --- a/ui-shared.c +++ b/ui-shared.c
@@ -1114,7 +1114,7 @@ void cgit_compose_snapshot_prefix(struct strbuf *filename, const char *base,
1114void cgit_print_snapshot_links(const struct cgit_repo *repo, const char *ref, 1114void cgit_print_snapshot_links(const struct cgit_repo *repo, const char *ref,
1115 const char *separator) 1115 const char *separator)
1116{ 1116{
1117 const struct cgit_snapshot_format* f; 1117 const struct cgit_snapshot_format *f;
1118 struct strbuf filename = STRBUF_INIT; 1118 struct strbuf filename = STRBUF_INIT;
1119 const char *basename; 1119 const char *basename;
1120 size_t prefixlen; 1120 size_t prefixlen;
@@ -1139,6 +1139,13 @@ void cgit_print_snapshot_links(const struct cgit_repo *repo, const char *ref,
1139 cgit_snapshot_link("sig", NULL, NULL, NULL, NULL, 1139 cgit_snapshot_link("sig", NULL, NULL, NULL, NULL,
1140 filename.buf); 1140 filename.buf);
1141 html(")"); 1141 html(")");
1142 } else if (starts_with(f->suffix, ".tar") && cgit_snapshot_get_sig(ref, &cgit_snapshot_formats[0])) {
1143 strbuf_setlen(&filename, strlen(filename.buf) - strlen(f->suffix));
1144 strbuf_addstr(&filename, ".tar.asc");
1145 html(" (");
1146 cgit_snapshot_link("sig", NULL, NULL, NULL, NULL,
1147 filename.buf);
1148 html(")");
1142 } 1149 }
1143 html(separator); 1150 html(separator);
1144 } 1151 }
diff --git a/ui-snapshot.c b/ui-snapshot.c index 92c3277..fa3ceaf 100644 --- a/ui-snapshot.c +++ b/ui-snapshot.c
@@ -86,6 +86,7 @@ static int write_tar_xz_archive(const char *hex, const char *prefix)
86} 86}
87 87
88const struct cgit_snapshot_format cgit_snapshot_formats[] = { 88const struct cgit_snapshot_format cgit_snapshot_formats[] = {
89 /* .tar must remain the 0 index */
89 { ".tar", "application/x-tar", write_tar_archive }, 90 { ".tar", "application/x-tar", write_tar_archive },
90 { ".tar.gz", "application/x-gzip", write_tar_gzip_archive }, 91 { ".tar.gz", "application/x-gzip", write_tar_gzip_archive },
91 { ".tar.bz2", "application/x-bzip2", write_tar_bzip2_archive }, 92 { ".tar.bz2", "application/x-bzip2", write_tar_bzip2_archive },
@@ -268,7 +269,7 @@ void cgit_print_snapshot(const char *head, const char *hex,
268 } 269 }
269 270
270 f = get_format(filename); 271 f = get_format(filename);
271 if (!f || !(ctx.repo->snapshots & cgit_snapshot_format_bit(f))) { 272 if (!f || (!sig_filename && !(ctx.repo->snapshots & cgit_snapshot_format_bit(f)))) {
272 cgit_print_error_page(400, "Bad request", 273 cgit_print_error_page(400, "Bad request",
273 "Unsupported snapshot format: %s", filename); 274 "Unsupported snapshot format: %s", filename);
274 return; 275 return;