all repos — cgit @ 7ba41963dde175581ae7b395045fd51678237930

a hyperfast web frontend for git written in c

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>
Christian Hesse mail@eworm.de
Thu, 07 Jun 2018 21:31:28 +0200
commit

7ba41963dde175581ae7b395045fd51678237930

parent

b522a302c9c4fb9fd9e1ea829ee990afc74980ca

2 files changed, 10 insertions(+), 2 deletions(-)

jump to
M ui-shared.cui-shared.c

@@ -1114,7 +1114,7 @@

void cgit_print_snapshot_links(const struct cgit_repo *repo, const char *ref, const char *separator) { - const struct cgit_snapshot_format* f; + const struct cgit_snapshot_format *f; struct strbuf filename = STRBUF_INIT; const char *basename; size_t prefixlen;

@@ -1135,6 +1135,13 @@ cgit_snapshot_link(filename.buf, NULL, NULL, NULL, NULL,

filename.buf); if (cgit_snapshot_get_sig(ref, f)) { strbuf_addstr(&filename, ".asc"); + html(" ("); + cgit_snapshot_link("sig", NULL, NULL, NULL, NULL, + filename.buf); + html(")"); + } else if (starts_with(f->suffix, ".tar") && cgit_snapshot_get_sig(ref, &cgit_snapshot_formats[0])) { + strbuf_setlen(&filename, strlen(filename.buf) - strlen(f->suffix)); + strbuf_addstr(&filename, ".tar.asc"); html(" ("); cgit_snapshot_link("sig", NULL, NULL, NULL, NULL, filename.buf);
M ui-snapshot.cui-snapshot.c

@@ -86,6 +86,7 @@ return write_compressed_tar_archive(hex, prefix, argv);

} const struct cgit_snapshot_format cgit_snapshot_formats[] = { + /* .tar must remain the 0 index */ { ".tar", "application/x-tar", write_tar_archive }, { ".tar.gz", "application/x-gzip", write_tar_gzip_archive }, { ".tar.bz2", "application/x-bzip2", write_tar_bzip2_archive },

@@ -268,7 +269,7 @@ filename = adj_filename;

} f = get_format(filename); - if (!f || !(ctx.repo->snapshots & cgit_snapshot_format_bit(f))) { + if (!f || (!sig_filename && !(ctx.repo->snapshots & cgit_snapshot_format_bit(f)))) { cgit_print_error_page(400, "Bad request", "Unsupported snapshot format: %s", filename); return;