From: Michael Tremer Date: Fri, 19 Jan 2018 16:09:28 +0000 (+0100) Subject: libpakfire: Implement verify step which verifies the downloaded archive X-Git-Tag: 0.9.28~1285^2~1153 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=8fe8fe0ff3562e856cd6fc7c67bf138067cc1d3a;p=pakfire.git libpakfire: Implement verify step which verifies the downloaded archive Signed-off-by: Michael Tremer --- diff --git a/src/libpakfire/include/pakfire/package.h b/src/libpakfire/include/pakfire/package.h index b6835146c..f53657291 100644 --- a/src/libpakfire/include/pakfire/package.h +++ b/src/libpakfire/include/pakfire/package.h @@ -108,6 +108,8 @@ char* pakfire_package_get_location(PakfirePackage pkg); char* pakfire_package_dump(PakfirePackage pkg, int flags); +PakfireArchive pakfire_package_get_archive(PakfirePackage pkg); + int pakfire_package_is_cached(PakfirePackage pkg); char* pakfire_package_get_cache_path(PakfirePackage pkg); char* pakfire_package_get_cache_full_path(PakfirePackage pkg); diff --git a/src/libpakfire/step.c b/src/libpakfire/step.c index 66e8f1404..108493a4b 100644 --- a/src/libpakfire/step.c +++ b/src/libpakfire/step.c @@ -23,6 +23,7 @@ #include #include +#include #include #include #include @@ -217,9 +218,26 @@ static int pakfire_step_verify(PakfireStep step) { if (pakfire_step_needs_download(step)) return 1; - // TODO verify package and signature + // Fetch the archive + PakfireArchive archive = pakfire_package_get_archive(step->package); + if (!archive) { + char* nevra = pakfire_package_get_nevra(step->package); + char* cache_path = pakfire_package_get_cache_path(step->package); - return 0; + ERROR("Could not open package archive for %s: %s\n", nevra, cache_path); + + pakfire_free(nevra); + pakfire_free(cache_path); + + return -1; + } + + // Verify the archive + pakfire_archive_verify_status_t status = pakfire_archive_verify(archive); + + pakfire_archive_unref(archive); + + return status; } static int pakfire_step_run_script(PakfireStep step, pakfire_script_type script) {