/[packages]/cauldron/abrt/current/SOURCES/abrt-1.1.14-rpm5.patch
ViewVC logotype

Contents of /cauldron/abrt/current/SOURCES/abrt-1.1.14-rpm5.patch

Parent Directory Parent Directory | Revision Log Revision Log


Revision 21273 - (show annotations) (download)
Mon Jan 17 13:41:48 2011 UTC (9 years, 2 months ago) by blino
File size: 8605 byte(s)
imported package abrt
1 diff --git a/src/Daemon/Makefile.am b/src/Daemon/Makefile.am
2 index ef67726..9316aeb 100644
3 --- a/src/Daemon/Makefile.am
4 +++ b/src/Daemon/Makefile.am
5 @@ -24,6 +24,7 @@ abrtd_CPPFLAGS = \
6 -DPLUGINS_CONF_DIR=\"$(PLUGINS_CONF_DIR)\" \
7 $(GLIB_CFLAGS) \
8 $(DBUS_CFLAGS) \
9 + $(RPM_CFLAGS) \
10 $(XMLRPC_CFLAGS) $(XMLRPC_CLIENT_CFLAGS) \
11 $(ENABLE_SOCKET_OR_DBUS) \
12 -D_GNU_SOURCE \
13 diff --git a/src/Daemon/RPM.cpp b/src/Daemon/RPM.cpp
14 index e4208a2..0b45877 100644
15 --- a/src/Daemon/RPM.cpp
16 +++ b/src/Daemon/RPM.cpp
17 @@ -28,7 +28,6 @@ CRPM::CRPM()
18
19 CRPM::~CRPM()
20 {
21 - rpmFreeCrypto();
22 rpmFreeRpmrc();
23 rpmcliFini(m_poptContext);
24 }
25 @@ -50,7 +49,6 @@ void CRPM::LoadOpenGPGPublicKey(const char* pFileName)
26 if (fedoraFingerprint != NULL)
27 {
28 m_setFingerprints.insert(fedoraFingerprint);
29 - free(fedoraFingerprint);
30 }
31 }
32 free(pkt);
33 @@ -60,45 +58,38 @@ bool CRPM::CheckFingerprint(const char* pPackage)
34 {
35 bool ret = false;
36 rpmts ts = rpmtsCreate();
37 - rpmdbMatchIterator iter = rpmtsInitIterator(ts, RPMTAG_NAME, pPackage, 0);
38 - Header header = rpmdbNextIterator(iter);
39 + rpmmi iter = rpmtsInitIterator(ts, RPMTAG_NAME, pPackage, 0);
40 + Header header = rpmmiNext(iter);
41
42 if (header != NULL)
43 {
44 - rpmTag rpmTags[] = { RPMTAG_DSAHEADER, RPMTAG_RSAHEADER, RPMTAG_SHA1HEADER };
45 - int ii;
46 - for (ii = 0; ii < 3; ii++)
47 - {
48 - if (headerIsEntry(header, rpmTags[ii]))
49 - {
50 - rpmtd td = rpmtdNew();
51 - headerGet(header, rpmTags[ii] , td, HEADERGET_DEFAULT);
52 - char* pgpsig = rpmtdFormat(td, RPMTD_FORMAT_PGPSIG , NULL);
53 - rpmtdFree(td);
54 - if (pgpsig)
55 - {
56 - std::string PGPSignatureText = pgpsig;
57 - free(pgpsig);
58 -
59 - size_t Key_ID_pos = PGPSignatureText.find(" Key ID ");
60 - if (Key_ID_pos != std::string::npos)
61 - {
62 - std::string headerFingerprint = PGPSignatureText.substr(Key_ID_pos + sizeof (" Key ID ") - 1);
63 -
64 - if (headerFingerprint != "")
65 - {
66 - if (m_setFingerprints.find(headerFingerprint) != m_setFingerprints.end())
67 - {
68 - ret = true;
69 - break;
70 - }
71 - }
72 - }
73 - }
74 - }
75 - }
76 + char *pgpsig = headerSprintf(
77 + header,
78 + "%|DSAHEADER?{%{DSAHEADER:pgpsig}}:{%|RSAHEADER?{%{RSAHEADER:pgpsig}}:"
79 + "{%|SIGGPG?{%{SIGGPG:pgpsig}}:{%|SIGPGP?{%{SIGPGP:pgpsig}}:{(none)}|}|}|}|",
80 + NULL,
81 + NULL,
82 + NULL);
83 + if(pgpsig) {
84 + std::string PGPSignatureText = pgpsig;
85 + free(pgpsig);
86 +
87 + size_t Key_ID_pos = PGPSignatureText.find(" Key ID ");
88 + if (Key_ID_pos != std::string::npos)
89 + {
90 + std::string headerFingerprint = PGPSignatureText.substr(Key_ID_pos + sizeof (" Key ID ") - 1);
91 +
92 + if (headerFingerprint != "")
93 + {
94 + if (m_setFingerprints.find(headerFingerprint) != m_setFingerprints.end())
95 + {
96 + ret = true;
97 + }
98 + }
99 + }
100 + }
101 }
102 - rpmdbFreeIterator(iter);
103 + rpmmiFree(iter);
104 rpmtsFree(ts);
105 return ret;
106 }
107 @@ -107,28 +98,49 @@ bool CheckHash(const char* pPackage, const char* pPath)
108 {
109 bool ret = false;
110 rpmts ts = rpmtsCreate();
111 - rpmdbMatchIterator iter = rpmtsInitIterator(ts, RPMTAG_NAME, pPackage, 0);
112 - Header header = rpmdbNextIterator(iter);
113 + rpmmi iter = rpmtsInitIterator(ts, RPMTAG_NAME, pPackage, 0);
114 + Header header = rpmmiNext(iter);
115 if (header != NULL)
116 {
117 rpmfi fi = rpmfiNew(ts, header, RPMTAG_BASENAMES, 0);
118 pgpHashAlgo hashAlgo;
119 std::string headerHash;
120 char computedHash[1024] = "";
121 + const unsigned char *digest = NULL;
122 + char * pgpHex = NULL;
123 + size_t lenp;
124 + struct stat sb;
125 + size_t digestlen = 0;
126 + char buf[8*BUFSIZ];
127 + size_t nb;
128 + int xx;
129
130 while (rpmfiNext(fi) != -1)
131 {
132 if (strcmp(pPath, rpmfiFN(fi)) == 0)
133 {
134 - headerHash = rpmfiFDigestHex(fi, &hashAlgo);
135 - rpmDoDigest(hashAlgo, pPath, 1, (unsigned char*) computedHash, NULL);
136 + digest = rpmfiDigest(fi, reinterpret_cast<int*>(&hashAlgo), &lenp);
137 + pgpHex = pgpHexStr(digest, lenp);
138 + headerHash = std::string((const char*)digest, lenp*2);
139 +
140 + if(Stat(pPath, &sb) >= 0) {
141 + DIGEST_CTX ctx = rpmDigestInit(hashAlgo, RPMDIGEST_NONE);
142 + FD_t fd = Fopen(pPath, "r");
143 +
144 + while ((nb = Fread(buf, sizeof(buf[0]), sizeof(buf), fd)) > 0)
145 + xx = rpmDigestUpdate(ctx, buf, nb);
146 + xx = Fclose(fd); fd = NULL;
147 + xx = rpmDigestFinal(ctx, &digest, &digestlen, 0);
148 + pgpHex = pgpHexStr(digest, digestlen);
149 + snprintf(computedHash, digestlen*2, "%s", pgpHex);
150 + }
151 ret = (headerHash != "" && headerHash == computedHash);
152 break;
153 }
154 }
155 rpmfiFree(fi);
156 }
157 - rpmdbFreeIterator(iter);
158 + rpmmiFree(iter);
159 rpmtsFree(ts);
160 return ret;
161 }
162 @@ -137,20 +149,26 @@ std::string GetDescription(const char* pPackage)
163 {
164 std::string pDescription;
165 rpmts ts = rpmtsCreate();
166 - rpmdbMatchIterator iter = rpmtsInitIterator(ts, RPMTAG_NAME, pPackage, 0);
167 - Header header = rpmdbNextIterator(iter);
168 + rpmmi iter = rpmtsInitIterator(ts, RPMTAG_NAME, pPackage, 0);
169 + Header header = rpmmiNext(iter);
170 if (header != NULL)
171 {
172 - rpmtd td = rpmtdNew();
173 - headerGet(header, RPMTAG_SUMMARY, td, HEADERGET_DEFAULT);
174 - const char* summary = rpmtdGetString(td);
175 - headerGet(header, RPMTAG_DESCRIPTION, td, HEADERGET_DEFAULT);
176 - const char* description = rpmtdGetString(td);
177 - pDescription = summary + std::string("\n\n") + description;
178 - rpmtdFree(td);
179 + HE_t he = (HE_t)memset(alloca(sizeof(*he)), 0, sizeof(*he));
180 + he->tag = RPMTAG_SUMMARY;
181 + if(headerGet(header, he, 0))
182 + {
183 + pDescription += he->p.str;
184 + _free(he->p.ptr);
185 + }
186 + pDescription += "\n\n";
187 + he->tag = RPMTAG_DESCRIPTION;
188 + if(headerGet(header, he, 0))
189 + {
190 + pDescription += he->p.str;
191 + _free(he->p.ptr);
192 + }
193 }
194 - rpmdbFreeIterator(iter);
195 - rpmtsFree(ts);
196 + rpmmiFree(iter);
197 return pDescription;
198 }
199
200 @@ -159,23 +177,21 @@ std::string GetComponent(const char* pFileName)
201 std::string ret;
202 char *package_name;
203 rpmts ts = rpmtsCreate();
204 - rpmdbMatchIterator iter = rpmtsInitIterator(ts, RPMTAG_BASENAMES, pFileName, 0);
205 - Header header = rpmdbNextIterator(iter);
206 + rpmmi iter = rpmtsInitIterator(ts, RPMTAG_BASENAMES, pFileName, 0);
207 + Header header = rpmmiNext(iter);
208 if (header != NULL)
209 {
210 - rpmtd td = rpmtdNew();
211 - headerGet(header, RPMTAG_SOURCERPM, td, HEADERGET_DEFAULT);
212 - const char * srpm = rpmtdGetString(td);
213 - if (srpm != NULL)
214 + HE_t he = (HE_t)memset(alloca(sizeof(*he)), 0, sizeof(*he));
215 + he->tag = RPMTAG_SOURCERPM;
216 + if(headerGet(header, he, 0))
217 {
218 - package_name = get_package_name_from_NVR_or_NULL(srpm);
219 + package_name = get_package_name_from_NVR_or_NULL(he->p.str);
220 ret = std::string(package_name);
221 - free(package_name);
222 + _free(he->p.ptr);
223 }
224 - rpmtdFree(td);
225 }
226
227 - rpmdbFreeIterator(iter);
228 + rpmmiFree(iter);
229 rpmtsFree(ts);
230 return ret;
231 }
232 @@ -184,14 +200,14 @@ char* GetPackage(const char* pFileName)
233 {
234 char* ret = NULL;
235 rpmts ts = rpmtsCreate();
236 - rpmdbMatchIterator iter = rpmtsInitIterator(ts, RPMTAG_BASENAMES, pFileName, 0);
237 - Header header = rpmdbNextIterator(iter);
238 + rpmmi iter = rpmtsInitIterator(ts, RPMTAG_BASENAMES, pFileName, 0);
239 + Header header = rpmmiNext(iter);
240 if (header != NULL)
241 {
242 - ret = headerGetNEVR(header, NULL);
243 + ret = headerSprintf(header, "%{name}-%{version}-%{release}", NULL, NULL, NULL);
244 }
245
246 - rpmdbFreeIterator(iter);
247 + rpmmiFree(iter);
248 rpmtsFree(ts);
249 return ret;
250 }
251 diff --git a/src/Daemon/RPM.h b/src/Daemon/RPM.h
252 index 4df868d..db77137 100644
253 --- a/src/Daemon/RPM.h
254 +++ b/src/Daemon/RPM.h
255 @@ -22,9 +22,10 @@
256 #ifndef RPM_H_
257 #define RPM_H_
258
259 -#include <rpm/rpmcli.h>
260 -#include <rpm/rpmts.h>
261 -#include <rpm/rpmdb.h>
262 +#include <rpmcli.h>
263 +#include <rpmts.h>
264 +#include <rpmdb.h>
265 +#include <rpmio.h>
266 #include "abrt_types.h"
267
268 /**

  ViewVC Help
Powered by ViewVC 1.1.26