aboutsummaryrefslogtreecommitdiffstats
path: root/testing/openscap/0001-Handle-rpmVerifyFile-removal-in-rpm-4.15.patch
blob: aa78a80064538b4153932f40ebcef0d63573b85c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
From e09334091d5678b666ea4e92d1a4b55838aa1a41 Mon Sep 17 00:00:00 2001
From: Panu Matilainen <pmatilai@redhat.com>
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