]> git.cameronkatri.com Git - cgit.git/commitdiff
snapshot: support tar signature for compressed tar
authorChristian Hesse <mail@eworm.de>
Thu, 7 Jun 2018 19:31:28 +0000 (21:31 +0200)
committerJason A. Donenfeld <Jason@zx2c4.com>
Tue, 3 Jul 2018 18:37:44 +0000 (20:37 +0200)
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>
ui-shared.c
ui-snapshot.c

index 9a2e382b62abfe6241123711a88223da8cfb59ab..066a470e5dd419b503bd4ff80646028079f844ad 100644 (file)
@@ -1114,7 +1114,7 @@ void cgit_compose_snapshot_prefix(struct strbuf *filename, const char *base,
 void cgit_print_snapshot_links(const struct cgit_repo *repo, const char *ref,
                               const char *separator)
 {
-       const struct cgit_snapshot_formatf;
+       const struct cgit_snapshot_format *f;
        struct strbuf filename = STRBUF_INIT;
        const char *basename;
        size_t prefixlen;
@@ -1139,6 +1139,13 @@ void cgit_print_snapshot_links(const struct cgit_repo *repo, const char *ref,
                        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);
+                       html(")");
                }
                html(separator);
        }
index 92c3277ad42d2410da2c89dca98eba2dff764e75..fa3ceafe65473a015f4a0ff0e6d97b9dcfc54677 100644 (file)
@@ -86,6 +86,7 @@ static int write_tar_xz_archive(const char *hex, const char *prefix)
 }
 
 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 @@ void cgit_print_snapshot(const char *head, const char *hex,
        }
 
        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;