diff options
author | Timo Teräs <timo.teras@iki.fi> | 2020-01-11 03:29:54 +0200 |
---|---|---|
committer | Timo Teräs <timo.teras@iki.fi> | 2020-01-11 03:43:38 +0200 |
commit | 9dda2d3c21d1116077257caafa065b659ffe419b (patch) | |
tree | 7530c489518f113c17d1b866a42bc9108a6d0c58 /src | |
parent | 6fae74e1daeb59f789456dcc816b089e601809fd (diff) | |
download | apk-tools-9dda2d3c21d1116077257caafa065b659ffe419b.tar.gz apk-tools-9dda2d3c21d1116077257caafa065b659ffe419b.tar.bz2 apk-tools-9dda2d3c21d1116077257caafa065b659ffe419b.tar.xz apk-tools-9dda2d3c21d1116077257caafa065b659ffe419b.zip |
archive: remove support for old packages without xattr checksums
Diffstat (limited to 'src')
-rw-r--r-- | src/apk_archive.h | 2 | ||||
-rw-r--r-- | src/archive.c | 45 | ||||
-rw-r--r-- | src/database.c | 13 | ||||
-rw-r--r-- | src/manifest.c | 2 | ||||
-rw-r--r-- | src/package.c | 2 | ||||
-rw-r--r-- | src/verify.c | 2 |
6 files changed, 14 insertions, 52 deletions
diff --git a/src/apk_archive.h b/src/apk_archive.h index 7436dd3..bb16c48 100644 --- a/src/apk_archive.h +++ b/src/apk_archive.h @@ -22,7 +22,7 @@ typedef int (*apk_archive_entry_parser)(void *ctx, int apk_tar_parse(struct apk_istream *, apk_archive_entry_parser parser, void *ctx, - int soft_checksums, struct apk_id_cache *); + struct apk_id_cache *); int apk_tar_write_entry(struct apk_ostream *, const struct apk_file_info *ae, const char *data); int apk_tar_write_padding(struct apk_ostream *, const struct apk_file_info *ae); diff --git a/src/archive.c b/src/archive.c index e04e583..db9242f 100644 --- a/src/archive.c +++ b/src/archive.c @@ -51,13 +51,6 @@ struct tar_header { char padding[12]; /* 500-511 */ }; -struct apk_tar_digest_info { - char id[4]; - uint16_t nid; - uint16_t size; - unsigned char digest[]; -}; - #define GET_OCTAL(s) get_octal(s, sizeof(s)) #define PUT_OCTAL(s,v) put_octal(s, sizeof(s), v) @@ -84,8 +77,6 @@ struct apk_tar_entry_istream { struct apk_istream is; struct apk_istream *tar_is; size_t bytes_left; - EVP_MD_CTX *mdctx; - struct apk_checksum *csum; time_t mtime; }; @@ -118,14 +109,6 @@ static ssize_t tar_entry_read(struct apk_istream *is, void *ptr, size_t size) } teis->bytes_left -= r; - if (teis->csum == NULL) - return r; - - EVP_DigestUpdate(teis->mdctx, ptr, r); - if (teis->bytes_left == 0) { - teis->csum->type = EVP_MD_CTX_size(teis->mdctx); - EVP_DigestFinal_ex(teis->mdctx, teis->csum->data, NULL); - } return r; } @@ -194,7 +177,7 @@ static void handle_extended_header(struct apk_file_info *fi, apk_blob_t hdr) } int apk_tar_parse(struct apk_istream *is, apk_archive_entry_parser parser, - void *ctx, int soft_checksums, struct apk_id_cache *idc) + void *ctx, struct apk_id_cache *idc) { struct apk_file_info entry; struct apk_tar_entry_istream teis = { @@ -202,17 +185,12 @@ int apk_tar_parse(struct apk_istream *is, apk_archive_entry_parser parser, .tar_is = is, }; struct tar_header buf; - struct apk_tar_digest_info *odi; unsigned long offset = 0; int end = 0, r; size_t toskip, paxlen = 0; apk_blob_t pax = APK_BLOB_NULL, longname = APK_BLOB_NULL; char filename[sizeof buf.name + sizeof buf.prefix + 2]; - odi = (struct apk_tar_digest_info *) &buf.linkname[3]; - teis.mdctx = EVP_MD_CTX_new(); - if (!teis.mdctx) return -ENOMEM; - memset(&entry, 0, sizeof(entry)); entry.name = buf.name; while ((r = apk_istream_read(is, &buf, 512)) == 512) { @@ -244,7 +222,6 @@ int apk_tar_parse(struct apk_istream *is, apk_archive_entry_parser parser, } buf.mode[0] = 0; /* to nul terminate 100-byte buf.name */ buf.magic[0] = 0; /* to nul terminate 100-byte buf.linkname */ - teis.csum = NULL; teis.mtime = entry.mtime; apk_xattr_array_resize(&entry.xattrs, 0); @@ -269,14 +246,6 @@ int apk_tar_parse(struct apk_istream *is, apk_archive_entry_parser parser, break; case '0': case '7': /* regular file */ - if (entry.csum.type == APK_CHECKSUM_NONE) { - if (memcmp(odi->id, "APK2", 4) == 0 && - odi->size <= sizeof(entry.csum.data)) { - entry.csum.type = odi->size; - memcpy(entry.csum.data, odi->digest, odi->size); - } else if (soft_checksums) - teis.csum = &entry.csum; - } entry.mode |= S_IFREG; break; case '1': /* hard link */ @@ -286,12 +255,6 @@ int apk_tar_parse(struct apk_istream *is, apk_archive_entry_parser parser, case '2': /* symbolic link */ entry.mode |= S_IFLNK; if (!entry.link_target) entry.link_target = buf.linkname; - if (entry.csum.type == APK_CHECKSUM_NONE && soft_checksums) { - EVP_Digest(buf.linkname, strlen(buf.linkname), - entry.csum.data, NULL, - apk_checksum_default(), NULL); - entry.csum.type = APK_CHECKSUM_DEFAULT; - } break; case '3': /* char device */ entry.mode |= S_IFCHR; @@ -327,11 +290,6 @@ int apk_tar_parse(struct apk_istream *is, apk_archive_entry_parser parser, teis.bytes_left = entry.size; if (entry.mode & S_IFMT) { - /* callback parser function */ - if (teis.csum != NULL) - EVP_DigestInit_ex(teis.mdctx, - apk_checksum_default(), NULL); - r = parser(ctx, &entry, &teis.is); if (r != 0) goto err; @@ -362,7 +320,6 @@ err: /* Check that there was no partial (or non-zero) record */ if (r >= 0) r = -EBADMSG; ok: - EVP_MD_CTX_free(teis.mdctx); free(pax.ptr); free(longname.ptr); apk_fileinfo_free(&entry); diff --git a/src/database.c b/src/database.c index 834695a..6fe637f 100644 --- a/src/database.c +++ b/src/database.c @@ -654,7 +654,7 @@ int apk_cache_download(struct apk_database *db, struct apk_repository *repo, bs = apk_bstream_tee(bs, db->cache_fd, tmpcacheitem, !autoupdate, cb, cb_ctx); is = apk_bstream_gunzip_mpart(bs, apk_sign_ctx_mpart_cb, &sctx); if (!IS_ERR_OR_NULL(is)) - r = apk_tar_parse(is, apk_sign_ctx_verify_tar, &sctx, FALSE, &db->id_cache); + r = apk_tar_parse(is, apk_sign_ctx_verify_tar, &sctx, &db->id_cache); else r = PTR_ERR(is) ?: -EIO; apk_sign_ctx_free(&sctx); @@ -1179,7 +1179,7 @@ static int apk_db_read_state(struct apk_database *db, int flags) is = apk_istream_from_file(db->root_fd, apk_scripts_file); if (!IS_ERR_OR_NULL(is)) { apk_tar_parse(is, apk_read_script_archive_entry, db, - FALSE, &db->id_cache); + &db->id_cache); apk_istream_close(is); } } @@ -2205,7 +2205,7 @@ static int load_index(struct apk_database *db, struct apk_bstream *bs, ctx.found = 0; apk_sign_ctx_init(&ctx.sctx, APK_SIGN_VERIFY, NULL, db->keys_fd); is = apk_bstream_gunzip_mpart(bs, apk_sign_ctx_mpart_cb, &ctx.sctx); - r = apk_tar_parse(is, load_apkindex, &ctx, FALSE, &db->id_cache); + r = apk_tar_parse(is, load_apkindex, &ctx, &db->id_cache); apk_istream_close(is); apk_sign_ctx_free(&ctx.sctx); @@ -2590,6 +2590,11 @@ static int apk_db_install_archive_entry(void *_ctx, memcpy(&file->csum, &link_target_file->csum, sizeof file->csum); else memcpy(&file->csum, &ae->csum, sizeof file->csum); + if (file->csum.type == APK_CHECKSUM_NONE) { + apk_warning(PKG_VER_FMT": no checksum for file %s", + PKG_VER_PRINTF(pkg), ae->name); + ipkg->broken_files = 1; + } break; case -ENOTSUP: ipkg->broken_xattr = 1; @@ -2832,7 +2837,7 @@ static int apk_db_unpack_pkg(struct apk_database *db, }; apk_sign_ctx_init(&ctx.sctx, APK_SIGN_VERIFY_IDENTITY, &pkg->csum, db->keys_fd); tar = apk_bstream_gunzip_mpart(bs, apk_sign_ctx_mpart_cb, &ctx.sctx); - r = apk_tar_parse(tar, apk_db_install_archive_entry, &ctx, TRUE, &db->id_cache); + r = apk_tar_parse(tar, apk_db_install_archive_entry, &ctx, &db->id_cache); apk_sign_ctx_free(&ctx.sctx); apk_istream_close(tar); diff --git a/src/manifest.c b/src/manifest.c index 7d20aa2..adabe61 100644 --- a/src/manifest.c +++ b/src/manifest.c @@ -99,7 +99,7 @@ static void process_file(struct apk_database *db, const char *match) return; } - (void) apk_tar_parse(is, read_file_entry, &ctx, FALSE, &db->id_cache); + (void) apk_tar_parse(is, read_file_entry, &ctx, &db->id_cache); apk_istream_close(is); } diff --git a/src/package.c b/src/package.c index 262bda2..7981b49 100644 --- a/src/package.c +++ b/src/package.c @@ -931,7 +931,7 @@ int apk_pkg_read(struct apk_database *db, const char *file, ctx.pkg->size = fi.size; tar = apk_bstream_gunzip_mpart(bs, apk_sign_ctx_mpart_cb, sctx); - r = apk_tar_parse(tar, read_info_entry, &ctx, FALSE, &db->id_cache); + r = apk_tar_parse(tar, read_info_entry, &ctx, &db->id_cache); apk_istream_close(tar); if (r < 0 && r != -ECANCELED) goto err; diff --git a/src/verify.c b/src/verify.c index f681f2f..ed0920b 100644 --- a/src/verify.c +++ b/src/verify.c @@ -37,7 +37,7 @@ static int verify_main(void *ctx, struct apk_database *db, struct apk_string_arr rc++; continue; } - r = apk_tar_parse(is, apk_sign_ctx_verify_tar, &sctx, FALSE, &db->id_cache); + r = apk_tar_parse(is, apk_sign_ctx_verify_tar, &sctx, &db->id_cache); apk_istream_close(is); ok = sctx.control_verified && sctx.data_verified; if (apk_verbosity >= 1) |