archive: remove support for old packages without xattr checksums
parent
6fae74e1da
commit
9dda2d3c21
|
@ -22,7 +22,7 @@ typedef int (*apk_archive_entry_parser)(void *ctx,
|
||||||
|
|
||||||
int apk_tar_parse(struct apk_istream *,
|
int apk_tar_parse(struct apk_istream *,
|
||||||
apk_archive_entry_parser parser, void *ctx,
|
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,
|
int apk_tar_write_entry(struct apk_ostream *, const struct apk_file_info *ae,
|
||||||
const char *data);
|
const char *data);
|
||||||
int apk_tar_write_padding(struct apk_ostream *, const struct apk_file_info *ae);
|
int apk_tar_write_padding(struct apk_ostream *, const struct apk_file_info *ae);
|
||||||
|
|
|
@ -51,13 +51,6 @@ struct tar_header {
|
||||||
char padding[12]; /* 500-511 */
|
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 GET_OCTAL(s) get_octal(s, sizeof(s))
|
||||||
#define PUT_OCTAL(s,v) put_octal(s, sizeof(s), v)
|
#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 is;
|
||||||
struct apk_istream *tar_is;
|
struct apk_istream *tar_is;
|
||||||
size_t bytes_left;
|
size_t bytes_left;
|
||||||
EVP_MD_CTX *mdctx;
|
|
||||||
struct apk_checksum *csum;
|
|
||||||
time_t mtime;
|
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;
|
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;
|
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,
|
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_file_info entry;
|
||||||
struct apk_tar_entry_istream teis = {
|
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,
|
.tar_is = is,
|
||||||
};
|
};
|
||||||
struct tar_header buf;
|
struct tar_header buf;
|
||||||
struct apk_tar_digest_info *odi;
|
|
||||||
unsigned long offset = 0;
|
unsigned long offset = 0;
|
||||||
int end = 0, r;
|
int end = 0, r;
|
||||||
size_t toskip, paxlen = 0;
|
size_t toskip, paxlen = 0;
|
||||||
apk_blob_t pax = APK_BLOB_NULL, longname = APK_BLOB_NULL;
|
apk_blob_t pax = APK_BLOB_NULL, longname = APK_BLOB_NULL;
|
||||||
char filename[sizeof buf.name + sizeof buf.prefix + 2];
|
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));
|
memset(&entry, 0, sizeof(entry));
|
||||||
entry.name = buf.name;
|
entry.name = buf.name;
|
||||||
while ((r = apk_istream_read(is, &buf, 512)) == 512) {
|
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.mode[0] = 0; /* to nul terminate 100-byte buf.name */
|
||||||
buf.magic[0] = 0; /* to nul terminate 100-byte buf.linkname */
|
buf.magic[0] = 0; /* to nul terminate 100-byte buf.linkname */
|
||||||
teis.csum = NULL;
|
|
||||||
teis.mtime = entry.mtime;
|
teis.mtime = entry.mtime;
|
||||||
apk_xattr_array_resize(&entry.xattrs, 0);
|
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;
|
break;
|
||||||
case '0':
|
case '0':
|
||||||
case '7': /* regular file */
|
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;
|
entry.mode |= S_IFREG;
|
||||||
break;
|
break;
|
||||||
case '1': /* hard link */
|
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 */
|
case '2': /* symbolic link */
|
||||||
entry.mode |= S_IFLNK;
|
entry.mode |= S_IFLNK;
|
||||||
if (!entry.link_target) entry.link_target = buf.linkname;
|
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;
|
break;
|
||||||
case '3': /* char device */
|
case '3': /* char device */
|
||||||
entry.mode |= S_IFCHR;
|
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;
|
teis.bytes_left = entry.size;
|
||||||
if (entry.mode & S_IFMT) {
|
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);
|
r = parser(ctx, &entry, &teis.is);
|
||||||
if (r != 0) goto err;
|
if (r != 0) goto err;
|
||||||
|
|
||||||
|
@ -362,7 +320,6 @@ err:
|
||||||
/* Check that there was no partial (or non-zero) record */
|
/* Check that there was no partial (or non-zero) record */
|
||||||
if (r >= 0) r = -EBADMSG;
|
if (r >= 0) r = -EBADMSG;
|
||||||
ok:
|
ok:
|
||||||
EVP_MD_CTX_free(teis.mdctx);
|
|
||||||
free(pax.ptr);
|
free(pax.ptr);
|
||||||
free(longname.ptr);
|
free(longname.ptr);
|
||||||
apk_fileinfo_free(&entry);
|
apk_fileinfo_free(&entry);
|
||||||
|
|
|
@ -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);
|
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);
|
is = apk_bstream_gunzip_mpart(bs, apk_sign_ctx_mpart_cb, &sctx);
|
||||||
if (!IS_ERR_OR_NULL(is))
|
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
|
else
|
||||||
r = PTR_ERR(is) ?: -EIO;
|
r = PTR_ERR(is) ?: -EIO;
|
||||||
apk_sign_ctx_free(&sctx);
|
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);
|
is = apk_istream_from_file(db->root_fd, apk_scripts_file);
|
||||||
if (!IS_ERR_OR_NULL(is)) {
|
if (!IS_ERR_OR_NULL(is)) {
|
||||||
apk_tar_parse(is, apk_read_script_archive_entry, db,
|
apk_tar_parse(is, apk_read_script_archive_entry, db,
|
||||||
FALSE, &db->id_cache);
|
&db->id_cache);
|
||||||
apk_istream_close(is);
|
apk_istream_close(is);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2205,7 +2205,7 @@ static int load_index(struct apk_database *db, struct apk_bstream *bs,
|
||||||
ctx.found = 0;
|
ctx.found = 0;
|
||||||
apk_sign_ctx_init(&ctx.sctx, APK_SIGN_VERIFY, NULL, db->keys_fd);
|
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);
|
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_istream_close(is);
|
||||||
apk_sign_ctx_free(&ctx.sctx);
|
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);
|
memcpy(&file->csum, &link_target_file->csum, sizeof file->csum);
|
||||||
else
|
else
|
||||||
memcpy(&file->csum, &ae->csum, sizeof file->csum);
|
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;
|
break;
|
||||||
case -ENOTSUP:
|
case -ENOTSUP:
|
||||||
ipkg->broken_xattr = 1;
|
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);
|
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);
|
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_sign_ctx_free(&ctx.sctx);
|
||||||
apk_istream_close(tar);
|
apk_istream_close(tar);
|
||||||
|
|
||||||
|
|
|
@ -99,7 +99,7 @@ static void process_file(struct apk_database *db, const char *match)
|
||||||
return;
|
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);
|
apk_istream_close(is);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -931,7 +931,7 @@ int apk_pkg_read(struct apk_database *db, const char *file,
|
||||||
ctx.pkg->size = fi.size;
|
ctx.pkg->size = fi.size;
|
||||||
|
|
||||||
tar = apk_bstream_gunzip_mpart(bs, apk_sign_ctx_mpart_cb, sctx);
|
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);
|
apk_istream_close(tar);
|
||||||
if (r < 0 && r != -ECANCELED)
|
if (r < 0 && r != -ECANCELED)
|
||||||
goto err;
|
goto err;
|
||||||
|
|
|
@ -37,7 +37,7 @@ static int verify_main(void *ctx, struct apk_database *db, struct apk_string_arr
|
||||||
rc++;
|
rc++;
|
||||||
continue;
|
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);
|
apk_istream_close(is);
|
||||||
ok = sctx.control_verified && sctx.data_verified;
|
ok = sctx.control_verified && sctx.data_verified;
|
||||||
if (apk_verbosity >= 1)
|
if (apk_verbosity >= 1)
|
||||||
|
|
Loading…
Reference in New Issue