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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
|
diff --git a/configure.ac b/configure.ac
index 192a838..4ddd127 100644
--- a/configure.ac
+++ b/configure.ac
@@ -200,12 +200,11 @@ AC_CHECK_LIB(bz2, BZ2_decompress,
AM_CONDITIONAL(HAVE_BZ2, false))],
AM_CONDITIONAL(HAVE_BZ2, false))
-AC_CHECK_LIB(rpm, rpmReadPackageFile,
- [AC_CHECK_HEADERS([rpm/rpmlib.h],
- AM_CONDITIONAL(HAVE_LIBRPM, true)
- AC_DEFINE(HAVE_LIBRPM,1,[Have librpm]),
- AM_CONDITIONAL(HAVE_LIBRPM, false))],
- AM_CONDITIONAL(HAVE_LIBRPM, false))
+PKG_CHECK_MODULES(RPM, rpm,
+ AM_CONDITIONAL(HAVE_LIBRPM, true)
+ AC_DEFINE([HAVE_LIBRPM],[1], "RPM..."),
+ AM_CONDITIONAL(HAVE_LIBRPM, false)
+ )
AC_CHECK_LIB(mpeg2, mpeg2_init,
[AC_CHECK_HEADERS([mpeg2dec/mpeg2.h],
--- libextractor-1.6/src/plugins/Makefile.am.orig 2017-10-09 15:29:32.000000000 +0200
+++ libextractor-1.6/src/plugins/Makefile.am 2017-12-07 18:27:17.926353030 +0100
@@ -1,7 +1,8 @@
# This Makefile.am is in the public domain
AM_CPPFLAGS = \
-I$(top_srcdir)/src/include \
- -I$(top_srcdir)/src/common
+ -I$(top_srcdir)/src/common \
+ $(RPM_CFLAGS)
# install plugins under:
--- libextractor-1.10/src/plugins/rpm_extractor.c.orig 2020-03-03 12:54:56.000000000 +0100
+++ libextractor-1.10/src/plugins/rpm_extractor.c 2020-07-04 18:52:32.521839942 +0200
@@ -25,9 +25,10 @@
#include "platform.h"
#include "extractor.h"
#include <stdint.h>
-#include <rpm/rpmlib.h>
-#include <rpm/rpmts.h>
-#include <rpm/rpmlog.h>
+#include <rpmio.h>
+#include <rpmcli.h>
+#include <rpmts.h>
+#include <rpmlog.h>
#if SOMEBSD
#include <pthread_np.h>
#else
@@ -128,6 +129,7 @@ pipe_feeder (void *args)
* LOG callback called by librpm. Does nothing, we
* just need this to override the default behavior.
*/
+#ifdef RPMLOG_DEFAULT
static int
discard_log_callback (rpmlogRec rec,
void *ctx)
@@ -135,6 +137,9 @@ discard_log_callback (rpmlogRec rec,
/* do nothing! */
return 0;
}
+#else
+static void discard_log_callback() { }
+#endif
/**
@@ -240,6 +245,12 @@ static struct Matches tests[] = {
{0, 0}
};
+#ifndef H_RPMTAG
+static int headerNext(HeaderIterator hi, HE_t he, /*@unused@*/ unsigned int flags)
+{
+ return headerNextIterator(hi, &he->tag, &he->t, &he->p.ptr, &he->c);
+}
+#endif
/**
* Main entry method for the 'application/x-rpm' extraction plugin.
@@ -255,7 +266,7 @@ EXTRACTOR_rpm_extract_method (struct EXT
const char *str;
Header hdr;
HeaderIterator hi;
- rpmtd p;
+ HE_t p;
int i;
FD_t fdi;
rpmRC rc;
@@ -286,7 +297,11 @@ EXTRACTOR_rpm_extract_method (struct EXT
CLOSE (parg.pi[1]);
return;
}
+#ifdef RPMLOG_DEFAULT
rpmlogSetCallback (&discard_log_callback, NULL);
+#else
+ rpmlogSetCallback (&discard_log_callback);
+#endif
fdi = fdDup (parg.pi[0]);
ts = rpmtsCreate ();
rc = rpmReadPackageFile (ts, fdi, "GNU libextractor", &hdr);
@@ -314,19 +329,35 @@ EXTRACTOR_rpm_extract_method (struct EXT
goto END;
}
pthread_mutex_unlock (&parg.lock);
+#ifdef H_RPMTAG
+ hi = headerInit (hdr);
+ p = (HE_t)memset(alloca(sizeof(*p)), 0, sizeof(*p));
+ while (1 == headerNext (hi, p, 0))
+#else
hi = headerInitIterator (hdr);
p = rpmtdNew ();
while (1 == headerNext (hi, p))
+#endif
for (i = 0; 0 != tests[i].rtype; i++)
{
if (tests[i].rtype != p->tag)
continue;
- switch (p->type)
+ switch (p->t)
{
+ case RPM_STRING_TYPE:
+ {
+ pthread_mutex_lock (&parg.lock);
+ if (0 != ec->proc (ec->cls, "rpm", tests[i].type, EXTRACTOR_METAFORMAT_UTF8,
+ "text/plain", p->p.str, strlen (p->p.str) +1)) {
+ pthread_mutex_unlock (&parg.lock);
+ return;
+ }
+ pthread_mutex_unlock (&parg.lock);
+ }
+ break;
case RPM_STRING_ARRAY_TYPE:
case RPM_I18NSTRING_TYPE:
- case RPM_STRING_TYPE:
- while (NULL != (str = rpmtdNextString (p)))
+ for(p->ix = 0; p->ix < p->c; p->ix++)
{
pthread_mutex_lock (&parg.lock);
if (0 != ec->proc (ec->cls,
@@ -334,8 +365,8 @@ EXTRACTOR_rpm_extract_method (struct EXT
tests[i].type,
EXTRACTOR_METAFORMAT_UTF8,
"text/plain",
- str,
- strlen (str) + 1))
+ p->p.argv[p->ix],
+ strlen (p->p.argv[p->ix]) + 1))
{
pthread_mutex_unlock (&parg.lock);
@@ -344,12 +375,12 @@ EXTRACTOR_rpm_extract_method (struct EXT
pthread_mutex_unlock (&parg.lock);
}
break;
- case RPM_INT32_TYPE:
+ case RPM_UINT32_TYPE:
{
if (p->tag == RPMTAG_BUILDTIME)
{
char tmp[80];
- uint32_t *v = rpmtdNextUint32 (p);
+ uint32_t *v = p->p.ui32p;
time_t tp = (time_t) *v;
if (NULL == ctime_r (&tp, tmp))
@@ -374,7 +405,7 @@ EXTRACTOR_rpm_extract_method (struct EXT
else
{
char tmp[14];
- uint32_t *s = rpmtdNextUint32 (p);
+ uint32_t *s = p->p.ui32p;
snprintf (tmp,
sizeof (tmp),
@@ -401,7 +432,6 @@ EXTRACTOR_rpm_extract_method (struct EXT
}
}
CLEANUP:
- rpmtdFree (p);
headerFreeIterator (hi);
END:
|