From e09334091d5678b666ea4e92d1a4b55838aa1a41 Mon Sep 17 00:00:00 2001 From: Panu Matilainen Date: Tue, 11 Jun 2019 16:12:55 +0300 Subject: [PATCH 1/3] Handle rpmVerifyFile() removal in rpm >= 4.15 Using rpmfiVerify() directly would be simpler but if upstream wants to preserve compatibility with older rpms... --- CMakeLists.txt | 1 + src/OVAL/probes/unix/linux/rpm-helper.c | 12 ++++++++++++ src/OVAL/probes/unix/linux/rpm-helper.h | 5 +++++ 3 files changed, 18 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index 720d8d8eb..058319599 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -132,6 +132,7 @@ if(RPM_FOUND) check_library_exists("${RPM_LIBRARY}" headerFormat "" HAVE_HEADERFORMAT) check_library_exists("${RPMIO_LIBRARY}" rpmFreeCrypto "" HAVE_RPMFREECRYPTO) check_library_exists("${RPM_LIBRARY}" rpmFreeFilesystems "" HAVE_RPMFREEFILESYSTEMS) + check_library_exists("${RPM_LIBRARY}" rpmVerifyFile "" HAVE_RPMVERIFYFILE) set(HAVE_RPMVERCMP 1) endif() diff --git a/src/OVAL/probes/unix/linux/rpm-helper.c b/src/OVAL/probes/unix/linux/rpm-helper.c index bfb95c363..4d23cf202 100644 --- a/src/OVAL/probes/unix/linux/rpm-helper.c +++ b/src/OVAL/probes/unix/linux/rpm-helper.c @@ -32,6 +32,18 @@ int rpmErrorCb (rpmlogRec rec, rpmlogCallbackData data) } #endif +#ifndef HAVE_RPMVERIFYFILE +int rpmVerifyFile(const rpmts ts, const rpmfi fi, + rpmVerifyAttrs * res, rpmVerifyAttrs omitMask) +{ + rpmVerifyAttrs vfy = rpmfiVerify(fi, omitMask); + if (res) + *res = vfy; + + return (vfy & RPMVERIFY_LSTATFAIL) ? 1 : 0; +} +#endif + void rpmLibsPreload() { // Don't load rpmrc files. The are useless for us, diff --git a/src/OVAL/probes/unix/linux/rpm-helper.h b/src/OVAL/probes/unix/linux/rpm-helper.h index 4e9af8702..f879a5a5b 100644 --- a/src/OVAL/probes/unix/linux/rpm-helper.h +++ b/src/OVAL/probes/unix/linux/rpm-helper.h @@ -87,6 +87,11 @@ int rpmErrorCb (rpmlogRec rec, rpmlogCallbackData data); #define DISABLE_PLUGINS(ts) rpmDefineMacro(NULL,"__plugindir \"\"", 0); #endif +#ifndef HAVE_RPMVERIFYFILE +int rpmVerifyFile(const rpmts ts, const rpmfi fi, + rpmVerifyAttrs * res, rpmVerifyAttrs omitMask); +#endif + /** * Preload libraries required by rpm * It destroy error callback! -- 2.22.0