Debian Codegraph @

src/OVAL/probes/unix/linux/rpminfo_probe.c

raw symbols SCIP
1 /**
2 * @file rpminfo_probe.c
3 * @brief rpminfo probe
4 * @author "Daniel Kopecek" <[email protected]>
5 *
6 * 2010/06/13 [email protected]
7 * This probe is able to process a rpminfo_object as defined in OVAL 5.4 and 5.5.
8 *
9 */
10
11 /*
12 * Copyright 2009 Red Hat Inc., Durham, North Carolina.
13 * All Rights Reserved.
14 *
15 * This library is free software; you can redistribute it and/or
16 * modify it under the terms of the GNU Lesser General Public
17 * License as published by the Free Software Foundation; either
18 * version 2.1 of the License, or (at your option) any later version.
19 *
20 * This library is distributed in the hope that it will be useful,
21 * but WITHOUT ANY WARRANTY; without even the implied warranty of
22 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
23 * Lesser General Public License for more details.
24 *
25 * You should have received a copy of the GNU Lesser General Public
26 * License along with this library; if not, write to the Free Software
27 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
28 *
29 * Authors:
30 * "Daniel Kopecek" <[email protected]>
31 */
32
33 /*
34 * rpminfo probe:
35 *
36 * rpminfo_object(string name)
37 *
38 * rpminfo_state(string name,
39 * string arch,
40 * string epoch,
41 * string release,
42 * string version,
43 * string evr,
44 * string signature_keyid
45 * string extended_status OVAL >= 5.10
46 * )
47 */
48
49 #ifdef HAVE_CONFIG_Hcxx . . $ `<built-in>:409:9`!
50 #include <config.h>cxx . . $ `<file>/build/config.h`/
51 #endif
52
53 #include <stdio.h>
54 #include <string.h>
55 #include <errno.h>
56 #include <assert.h>
57 #include <sys/types.h>
58 #include <sys/stat.h>
59 #include <fcntl.h>
60 #include <regex.h>
61
62 /* RPM headers */
63 #include "rpm-helper.h"cxx . . $ `<file>/src/OVAL/probes/unix/linux/rpm-helper.h`/
64
65 /* SEAP */
66 #include "_seap.h"cxx . . $ `<file>/src/OVAL/probes/SEAP/_seap.h`/
67 #include <probe-api.h>cxx . . $ `<file>/src/OVAL/probes/public/probe-api.h`/
68 #include <probe/probe.h>cxx . . $ `<file>/src/OVAL/probes/probe/probe.h`/
69 #include <probe/option.h>cxx . . $ `<file>/src/OVAL/probes/probe/option.h`/
70 #include "probe/entcmp.h"cxx . . $ `<file>/src/OVAL/probes/probe/entcmp.h`/
71 #include "common/debug_priv.h"cxx . . $ `<file>/src/common/debug_priv.h`/
72 #include "rpminfo_probe.h"cxx . . $ `<file>/src/OVAL/probes/unix/linux/rpminfo_probe.h`/
73
74
75 struct rpminfo_reqcxx . . $ rpminfo_req# {
76 char *namecxx . . $ rpminfo_req#name.;
77 oval_operation_tcxx . . $ oval_operation_t# opcxx . . $ rpminfo_req#op.;
78 };
79
80 struct rpminfo_repcxx . . $ rpminfo_rep# {
81 char *namecxx . . $ rpminfo_rep#name.;
82 char *archcxx . . $ rpminfo_rep#arch.;
83 char *epochcxx . . $ rpminfo_rep#epoch.;
84 char *releasecxx . . $ rpminfo_rep#release.;
85 char *versioncxx . . $ rpminfo_rep#version.;
86 char *evrcxx . . $ rpminfo_rep#evr.;
87 char *signature_keyidcxx . . $ rpminfo_rep#signature_keyid.;
88 char extended_namecxx . . $ rpminfo_rep#extended_name.[1024];
89 };
90
91 #define RPMINFO_LOCKcxx . . $ `src/OVAL/probes/unix/linux/rpminfo_probe.c:91:9`! RPM_MUTEX_LOCKcxx . . $ `src/OVAL/probes/unix/linux/rpm-helper.h:59:9`!(&g_rpm->mutex)
92
93 #define RPMINFO_UNLOCKcxx . . $ `src/OVAL/probes/unix/linux/rpminfo_probe.c:93:9`! RPM_MUTEX_UNLOCKcxx . . $ `src/OVAL/probes/unix/linux/rpm-helper.h:69:9`!(&g_rpm->mutex)
94
95 static const char g_keyid_regex_stringcxx . . $ g_keyid_regex_string.[] = "Key ID [a-fA-F0-9]{16}";
96
97 static void __rpminfo_rep_freecxx . . $ __rpminfo_rep_free(cec4f44b99565f0c). (struct rpminfo_repcxx . . $ rpminfo_rep# *ptr)
98 {
99 freecxx . . $ free(5d22bdacc48458e8). (ptr->namecxx . . $ rpminfo_rep#name.);
100 freecxx . . $ free(5d22bdacc48458e8). (ptr->archcxx . . $ rpminfo_rep#arch.);
101 freecxx . . $ free(5d22bdacc48458e8). (ptr->epochcxx . . $ rpminfo_rep#epoch.);
102 freecxx . . $ free(5d22bdacc48458e8). (ptr->releasecxx . . $ rpminfo_rep#release.);
103 freecxx . . $ free(5d22bdacc48458e8). (ptr->versioncxx . . $ rpminfo_rep#version.);
104 freecxx . . $ free(5d22bdacc48458e8). (ptr->evrcxx . . $ rpminfo_rep#evr.);
105 freecxx . . $ free(5d22bdacc48458e8). (ptr->signature_keyidcxx . . $ rpminfo_rep#signature_keyid.);
106 }
107
108 static void pkgh2repcxx . . $ pkgh2rep(f0fd5d7f1ecfc028).(Headercxx . . $ Header# h, struct rpminfo_repcxx . . $ rpminfo_rep# *r, regex_tcxx . . $ regex_t# *keyid_regex)
109 {
110 errmsg_tcxx . . $ errmsg_t# rpmerr;
111 char *str, *sid;
112 char *epoch_override = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!;
113 size_t len;
114 regmatch_tcxx . . $ regmatch_t# keyid_match[1];
115
116 if (h == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`! || r == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) {
117 return;
118 }
119
120 r->namecxx . . $ rpminfo_rep#name. = headerFormatcxx . . $ headerFormat(ff7bd715129ef29). (h, "%{NAME}", &rpmerr);
121 r->archcxx . . $ rpminfo_rep#arch. = headerFormatcxx . . $ headerFormat(ff7bd715129ef29). (h, "%{ARCH}", &rpmerr);
122 r->epochcxx . . $ rpminfo_rep#epoch. = headerFormatcxx . . $ headerFormat(ff7bd715129ef29). (h, "%{EPOCH}", &rpmerr);
123 r->releasecxx . . $ rpminfo_rep#release. = headerFormatcxx . . $ headerFormat(ff7bd715129ef29). (h, "%{RELEASE}", &rpmerr);
124 r->versioncxx . . $ rpminfo_rep#version. = headerFormatcxx . . $ headerFormat(ff7bd715129ef29). (h, "%{VERSION}", &rpmerr);
125 epoch_override = oscap_streqcxx . . $ oscap_streq(b7a7aa4a824b7595).(r->epochcxx . . $ rpminfo_rep#epoch., "(none)") ? "0" : r->epochcxx . . $ rpminfo_rep#epoch.;
126 snprintfcxx . . $ snprintf(ea502d73e74c754c).(r->extended_namecxx . . $ rpminfo_rep#extended_name., 1024, "%s-%s:%s-%s.%s", r->namecxx . . $ rpminfo_rep#name., epoch_override, r->versioncxx . . $ rpminfo_rep#version., r->releasecxx . . $ rpminfo_rep#release., r->archcxx . . $ rpminfo_rep#arch.);
127
128 len = (strlencxx . . $ strlen(751346f8406fd082).(epoch_override) +
129 strlencxx . . $ strlen(751346f8406fd082). (r->releasecxx . . $ rpminfo_rep#release.) +
130 strlencxx . . $ strlen(751346f8406fd082). (r->versioncxx . . $ rpminfo_rep#version.) + 2);
131
132 str = malloccxx . . $ malloc(bfcfa4d6b7f7ef64). (sizeof (char) * (len + 1));
133 snprintfcxx . . $ snprintf(ea502d73e74c754c). (str, len + 1, "%s:%s-%s",
134 epoch_override,
135 r->versioncxx . . $ rpminfo_rep#version.,
136 r->releasecxx . . $ rpminfo_rep#release.);
137
138 r->evrcxx . . $ rpminfo_rep#evr. = str;
139
140 str = headerFormatcxx . . $ headerFormat(ff7bd715129ef29). (
141 h,
142 "%|DSAHEADER?{%{DSAHEADER:pgpsig}}:{%|RSAHEADER?{%{RSAHEADER:pgpsig}}:{%|SIGGPG?{%{SIGGPG:pgpsig}}:{%|SIGPGP?{%{SIGPGP:pgpsig}}:{(none)}|}|}|}|",
143 &rpmerr);
144
145 if (regexeccxx . . $ regexec(7b724a18a85d26ac).(keyid_regex, str, 1, keyid_match, 0) != 0) {
146 sid = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!;
147 dDcxx . . $ `src/common/debug_priv.h:64:9`!("Failed to extract the Key ID value: regex=\"%s\", string=\"%s\"",
148 g_keyid_regex_string, str);
149 } else {
150 size_t keyid_start, keyid_length;
151
152 if (keyid_match[0].rm_socxx . . $ $anonymous_type_2410a2af4c2f900a_1#rm_so. < 0 || keyid_match[0].rm_eocxx . . $ $anonymous_type_2410a2af4c2f900a_1#rm_eo. < 0)
153 sid = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!;
154 else {
155 keyid_start = keyid_match[0].rm_socxx . . $ $anonymous_type_2410a2af4c2f900a_1#rm_so. + strlencxx . . $ strlen(751346f8406fd082).("Key ID ");
156 keyid_length = keyid_match[0].rm_eocxx . . $ $anonymous_type_2410a2af4c2f900a_1#rm_eo. - keyid_start;
157 sid = str + keyid_start;
158 sid[keyid_length] = '\0';
159 }
160 }
161
162 r->signature_keyidcxx . . $ rpminfo_rep#signature_keyid. = strdupcxx . . $ strdup(a8b8e32347182212).(sid != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`! ? sid : "0");
163 freecxx . . $ free(5d22bdacc48458e8). (str);
164 }
165
166 /*
167 * req - Structure containing the name of the package.
168 * rep - Pointer to rpminfo_rep structure pointer. An
169 * array of rpminfo_rep structures will be allocated
170 * here.
171 *
172 * The return value on error is -1. Otherwise the number of
173 * rpminfo_rep structures allocated in *rep is returned.
174 */
175 static int get_rpminfocxx . . $ get_rpminfo(6e853c90470b9331).(struct rpminfo_reqcxx . . $ rpminfo_req# *req, struct rpminfo_repcxx . . $ rpminfo_rep# **rep, struct rpm_probe_globalcxx . . $ rpm_probe_global# *g_rpm)
176 {
177 rpmdbMatchIteratorcxx . . $ rpmdbMatchIterator# match;
178 Headercxx . . $ Header# pkgh;
179 int ret = 0, i;
180 regex_tcxx . . $ regex_t# keyid_regex;
181
182 if (regcompcxx . . $ regcomp(aa05013d3db24b3e).(&keyid_regex, g_keyid_regex_stringcxx . . $ g_keyid_regex_string., REG_EXTENDEDcxx . . $ `<external>/18190116149591951179/regex.h:310:9`!) != 0) {
183 dEcxx . . $ `src/common/debug_priv.h:63:9`!("regcomp(%s) failed.", g_keyid_regex_string);
184 return -1;
185 }
186
187 RPMINFO_LOCKcxx . . $ `src/OVAL/probes/unix/linux/rpminfo_probe.c:91:9`!;
188
189 ret = -1;
190
191 switch (req->opcxx . . $ rpminfo_req#op.) {
192 case OVAL_OPERATION_EQUALScxx . . $ OVAL_OPERATION_EQUALS.:
193 match = rpmtsInitIteratorcxx . . $ rpmtsInitIterator(41c3f6b2f2ef385d).(g_rpm->rpmtscxx . . $ rpm_probe_global#rpmts., RPMTAG_NAMEcxx . . $ RPMTAG_NAME., (const void *)req->namecxx . . $ rpminfo_req#name., 0);
194
195 if (match == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) {
196 ret = 0;
197 goto ret;
198 }
199
200 ret = rpmdbGetIteratorCountcxx . . $ rpmdbGetIteratorCount(41af5f9a5d46e265). (match);
201
202 break;
203 case OVAL_OPERATION_NOT_EQUALcxx . . $ OVAL_OPERATION_NOT_EQUAL.:
204 match = rpmtsInitIteratorcxx . . $ rpmtsInitIterator(41c3f6b2f2ef385d).(g_rpm->rpmtscxx . . $ rpm_probe_global#rpmts., RPMDBI_PACKAGEScxx . . $ RPMDBI_PACKAGES., NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!, 0);
205 if (match == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) {
206 ret = 0;
207 goto ret;
208 }
209
210 if (rpmdbSetIteratorREcxx . . $ rpmdbSetIteratorRE(24a7459ecac1f13c). (match, RPMTAG_NAMEcxx . . $ RPMTAG_NAME., RPMMIRE_GLOBcxx . . $ RPMMIRE_GLOB., "*") != 0)
211 {
212 ret = -1;
213 goto ret;
214 }
215
216 break;
217 case OVAL_OPERATION_PATTERN_MATCHcxx . . $ OVAL_OPERATION_PATTERN_MATCH.:
218 match = rpmtsInitIteratorcxx . . $ rpmtsInitIterator(41c3f6b2f2ef385d).(g_rpm->rpmtscxx . . $ rpm_probe_global#rpmts., RPMDBI_PACKAGEScxx . . $ RPMDBI_PACKAGES., NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!, 0);
219
220 if (match == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) {
221 ret = 0;
222 goto ret;
223 }
224
225 if (rpmdbSetIteratorREcxx . . $ rpmdbSetIteratorRE(24a7459ecac1f13c). (match, RPMTAG_NAMEcxx . . $ RPMTAG_NAME., RPMMIRE_REGEXcxx . . $ RPMMIRE_REGEX.,
226 (const char *)req->namecxx . . $ rpminfo_req#name.) != 0)
227 {
228 ret = -1;
229 goto ret;
230 }
231
232 break;
233 default:
234 /* not supported */
235 ret = -1;
236 goto ret;
237 }
238
239 if (ret != -1) {
240 /*
241 * We can allocate all memory needed now because we know the number
242 * of results.
243 */
244 void *new_rep = realloccxx . . $ realloc(417ab160f6baadc6). (*rep, sizeof (struct rpminfo_repcxx . . $ rpminfo_rep#) * ret);
245 if (new_rep == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) {
246 ret = -2;
247 goto ret;
248 }
249 (*rep) = new_rep;
250 for (i = 0; i < ret; ++i) {
251 pkgh = rpmdbNextIteratorcxx . . $ rpmdbNextIterator(12a0bfe3c2421784). (match);
252
253 if (pkgh != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!)
254 pkgh2repcxx . . $ pkgh2rep(f0fd5d7f1ecfc028).(pkgh, (*rep) + i, &keyid_regex);
255 else {
256 /* XXX: emit warning */
257 memsetcxx . . $ memset(d1de1e4fb215f1c6).((*rep) + i, 0, sizeof(struct rpminfo_repcxx . . $ rpminfo_rep#));
258 break;
259 }
260 }
261 } else {
262 ret = 0;
263
264 while ((pkgh = rpmdbNextIteratorcxx . . $ rpmdbNextIterator(12a0bfe3c2421784). (match)) != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) {
265 void *new_rep = realloccxx . . $ realloc(417ab160f6baadc6). (*rep, sizeof (struct rpminfo_repcxx . . $ rpminfo_rep#) * ++ret);
266 if (new_rep == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) {
267 ret = -2;
268 goto ret;
269 }
270 (*rep) = new_rep;
271 pkgh2repcxx . . $ pkgh2rep(f0fd5d7f1ecfc028).(pkgh, (*rep) + (ret - 1), &keyid_regex);
272 }
273 }
274
275 match = rpmdbFreeIteratorcxx . . $ rpmdbFreeIterator(8defa6d083da6e8). (match);
276 ret:
277 RPMINFO_UNLOCKcxx . . $ `src/OVAL/probes/unix/linux/rpminfo_probe.c:93:9`!;
278
279 regfreecxx . . $ regfree(b1814a8fd6af504b).(&keyid_regex);
280 return (ret);
281 }
282
283 int rpminfo_probe_offline_mode_supportedcxx . . $ rpminfo_probe_offline_mode_supported(b126dc7c1de90089).()
284 {
285 return PROBE_OFFLINE_CHROOTcxx . . $ PROBE_OFFLINE_CHROOT.;
286 }
287
288 void *rpminfo_probe_initcxx . . $ rpminfo_probe_init(50c7df7de5344ebb).(void)
289 {
290 #ifdef RPM46_FOUNDcxx . . $ `build/config.h:46:9`!
291 rpmlogSetCallbackcxx . . $ rpmlogSetCallback(3af8381b9d28b514).(rpmErrorCbcxx . . $ rpmErrorCb(fff58a40e215938)., NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!);
292 #endif
293 struct rpm_probe_globalcxx . . $ rpm_probe_global# *g_rpm = malloccxx . . $ malloc(bfcfa4d6b7f7ef64).(sizeof(struct rpm_probe_globalcxx . . $ rpm_probe_global#));
294 if (rpmReadConfigFilescxx . . $ rpmReadConfigFiles(5ae29d726ae57f88). ((const char *)NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!, (const char *)NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) != 0) {
295 dDcxx . . $ `src/common/debug_priv.h:64:9`!("rpmReadConfigFiles failed: %u, %s.", errnocxx . . $ `<external>/17633486526465735210/errno.h:38:10`!, strerror (errnocxx . . $ `<external>/17633486526465735210/errno.h:38:10`!));
296 g_rpm->rpmtscxx . . $ rpm_probe_global#rpmts. = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!;
297 return ((void *)g_rpm);
298 }
299
300 set_rpm_db_pathcxx . . $ set_rpm_db_path(49f6e7a06ebc5aa8).();
301 g_rpm->rpmtscxx . . $ rpm_probe_global#rpmts. = rpmtsCreatecxx . . $ rpmtsCreate(17624c196b75261f).();
302 pthread_mutex_initcxx . . $ pthread_mutex_init(db9d29dab44ea1aa). (&(g_rpm->mutexcxx . . $ rpm_probe_global#mutex.), NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!);
303
304 return ((void *)g_rpm);
305 }
306
307 void rpminfo_probe_finicxx . . $ rpminfo_probe_fini(5d22bdacc48458e8). (void *ptr)
308 {
309 struct rpm_probe_globalcxx . . $ rpm_probe_global# *r = (struct rpm_probe_globalcxx . . $ rpm_probe_global# *)ptr;
310
311 rpmFreeCryptocxx . . $ rpmFreeCrypto(b126dc7c1de90089).();
312 rpmFreeRpmrccxx . . $ rpmFreeRpmrc(49f6e7a06ebc5aa8).();
313 rpmFreeMacroscxx . . $ rpmFreeMacros(9f41120681ff0556).(NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!);
314 rpmlogClosecxx . . $ rpmlogClose(49f6e7a06ebc5aa8).();
315
316 if (r == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!)
317 return;
318
319
320 if (r->rpmtscxx . . $ rpm_probe_global#rpmts. == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!)
321 return;
322
323 rpmtsFreecxx . . $ rpmtsFree(39c31376fa367c52).(r->rpmtscxx . . $ rpm_probe_global#rpmts.);
324 pthread_mutex_destroycxx . . $ pthread_mutex_destroy(d89ae235521888f9). (&(r->mutexcxx . . $ rpm_probe_global#mutex.));
325
326 freecxx . . $ free(5d22bdacc48458e8).(r);
327 return;
328 }
329
330 static int collect_rpm_filescxx . . $ collect_rpm_files(6251b7da74f7bdf2).(SEXP_tcxx . . $ SEXP_t# *item, const struct rpminfo_repcxx . . $ rpminfo_rep# *rep, struct rpm_probe_globalcxx . . $ rpm_probe_global# *g_rpm)
331 {
332 SEXP_tcxx . . $ SEXP_t# *value;
333 rpmdbMatchIteratorcxx . . $ rpmdbMatchIterator# ts;
334 Headercxx . . $ Header# pkgh;
335 rpmficxx . . $ rpmfi# fi;
336 rpmTagcxx . . $ rpmTag# tag[2] = { RPMTAG_BASENAMEScxx . . $ RPMTAG_BASENAMES., RPMTAG_DIRNAMEScxx . . $ RPMTAG_DIRNAMES. };
337 int i, ret = 0;
338
339 ts = rpmtsInitIteratorcxx . . $ rpmtsInitIterator(41c3f6b2f2ef385d).(g_rpm->rpmtscxx . . $ rpm_probe_global#rpmts., RPMDBI_PACKAGEScxx . . $ RPMDBI_PACKAGES., NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!, 0);
340 if (ts == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) {
341 return -1;
342 }
343
344 if (rpmdbSetIteratorREcxx . . $ rpmdbSetIteratorRE(24a7459ecac1f13c).(ts, RPMTAG_NAMEcxx . . $ RPMTAG_NAME., RPMMIRE_STRCMPcxx . . $ RPMMIRE_STRCMP., rep->namecxx . . $ rpminfo_rep#name.) != 0) {
345 ret = -1;
346 goto cleanup;
347 }
348 char *epoch_override = oscap_streqcxx . . $ oscap_streq(b7a7aa4a824b7595).(rep->epochcxx . . $ rpminfo_rep#epoch., "(none)") ? "0" : rep->epochcxx . . $ rpminfo_rep#epoch.;
349 if (rpmdbSetIteratorREcxx . . $ rpmdbSetIteratorRE(24a7459ecac1f13c).(ts, RPMTAG_EPOCHcxx . . $ RPMTAG_EPOCH., RPMMIRE_STRCMPcxx . . $ RPMMIRE_STRCMP., epoch_override) != 0) {
350 ret = -1;
351 goto cleanup;
352 }
353 if (rpmdbSetIteratorREcxx . . $ rpmdbSetIteratorRE(24a7459ecac1f13c).(ts, RPMTAG_VERSIONcxx . . $ RPMTAG_VERSION., RPMMIRE_STRCMPcxx . . $ RPMMIRE_STRCMP., rep->versioncxx . . $ rpminfo_rep#version.) != 0) {
354 ret = -1;
355 goto cleanup;
356 }
357 if (rpmdbSetIteratorREcxx . . $ rpmdbSetIteratorRE(24a7459ecac1f13c).(ts, RPMTAG_RELEASEcxx . . $ RPMTAG_RELEASE., RPMMIRE_STRCMPcxx . . $ RPMMIRE_STRCMP., rep->releasecxx . . $ rpminfo_rep#release.) != 0) {
358 ret = -1;
359 goto cleanup;
360 }
361 if (rpmdbSetIteratorREcxx . . $ rpmdbSetIteratorRE(24a7459ecac1f13c).(ts, RPMTAG_ARCHcxx . . $ RPMTAG_ARCH., RPMMIRE_STRCMPcxx . . $ RPMMIRE_STRCMP., rep->archcxx . . $ rpminfo_rep#arch.) != 0) {
362 ret = -1;
363 goto cleanup;
364 }
365
366 while ((pkgh = rpmdbNextIteratorcxx . . $ rpmdbNextIterator(12a0bfe3c2421784).(ts)) != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) {
367 /*
368 * Inspect package files & directories
369 */
370 for (i = 0; i < 2; ++i) {
371 fi = rpmfiNewcxx . . $ rpmfiNew(765de6e9cbcb5527).(g_rpm->rpmtscxx . . $ rpm_probe_global#rpmts., pkgh, tag[i], 1);
372
373 while (rpmfiNextcxx . . $ rpmfiNext(b7df0ed902649c2e).(fi) != -1) {
374 const char *filepath;
375 filepath = rpmfiFNcxx . . $ rpmfiFN(24fadc50c126301f).(fi);
376 value = probe_entval_from_cstrcxx . . $ probe_entval_from_cstr(abb8c272acf0bd7e).(
377 OVAL_DATATYPE_STRINGcxx . . $ OVAL_DATATYPE_STRING.,
378 filepath,
379 strlencxx . . $ strlen(751346f8406fd082).(filepath)
380 );
381 if (value != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) {
382 probe_item_ent_addcxx . . $ probe_item_ent_add(9f488d3b029fc9d1).(item, "filepath", NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!, value);
383 SEXP_freecxx . . $ SEXP_free(c6b28547479798f4).(value);
384 }
385 }
386 rpmfiFreecxx . . $ rpmfiFree(cff0d0dd50e20ae4).(fi);
387 }
388
389 }
390 cleanup:
391 ts = rpmdbFreeIteratorcxx . . $ rpmdbFreeIterator(8defa6d083da6e8).(ts);
392 return ret;
393 }
394
395 int rpminfo_probe_maincxx . . $ rpminfo_probe_main(470536d3ffacaf10).(probe_ctxcxx . . $ probe_ctx# *ctx, void *arg)
396 {
397 SEXP_tcxx . . $ SEXP_t# *val, *item, *ent, *probe_in;
398 oval_schema_version_tcxx . . $ oval_schema_version_t# over;
399 int rpmret, i;
400
401 struct rpminfo_reqcxx . . $ rpminfo_req# request_st;
402 struct rpminfo_repcxx . . $ rpminfo_rep# *reply_st;
403
404 // arg is NULL if regex compilation failed
405 if (arg == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) {
406 return PROBE_EINITcxx . . $ `src/OVAL/probes/public/probe-common.h:12:9`!;
407 }
408
409 struct rpm_probe_globalcxx . . $ rpm_probe_global# *g_rpm = (struct rpm_probe_globalcxx . . $ rpm_probe_global# *)arg;
410
411 // There was no rpm config files
412 if (g_rpm->rpmtscxx . . $ rpm_probe_global#rpmts. == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) {
413 probe_cobj_set_flagcxx . . $ probe_cobj_set_flag(644bab5dffe689c).(probe_ctx_getresultcxx . . $ probe_ctx_getresult(4299b6b53fa804a5).(ctx), SYSCHAR_FLAG_NOT_APPLICABLEcxx . . $ SYSCHAR_FLAG_NOT_APPLICABLE.);
414 return 0;
415 }
416
417 if (ctx->offline_modecxx . . $ probe_ctx#offline_mode. & PROBE_OFFLINE_OWNcxx . . $ PROBE_OFFLINE_OWN.) {
418 const char* root = getenvcxx . . $ getenv(a8b8e32347182212).("OSCAP_PROBE_ROOT");
419 rpmtsSetRootDircxx . . $ rpmtsSetRootDir(23a209d8fccc3ea8).(g_rpm->rpmtscxx . . $ rpm_probe_global#rpmts., root);
420 }
421
422 probe_in = probe_ctx_getobjectcxx . . $ probe_ctx_getobject(4299b6b53fa804a5).(ctx);
423 if (probe_in == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!)
424 return PROBE_ENOOBJcxx . . $ `src/OVAL/probes/public/probe-common.h:21:9`!;
425
426 over = probe_obj_get_platform_schema_versioncxx . . $ probe_obj_get_platform_schema_version(5bacca80194debea).(probe_in);
427
428 ent = probe_obj_getentcxx . . $ probe_obj_getent(7907a01f2ff841f3). (probe_in, "name", 1);
429
430 if (ent == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) {
431 return (PROBE_ENOENTcxx . . $ `src/OVAL/probes/public/probe-common.h:20:9`!);
432 }
433
434 val = probe_ent_getvalcxx . . $ probe_ent_getval(2f7f980afaaae0f0). (ent);
435
436 if (val == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) {
437 dDcxx . . $ `src/common/debug_priv.h:64:9`!("%s: no value", "name");
438 SEXP_freecxx . . $ SEXP_free(c6b28547479798f4). (ent);
439 return (PROBE_ENOVALcxx . . $ `src/OVAL/probes/public/probe-common.h:10:9`!);
440 }
441
442 request_st.namecxx . . $ rpminfo_req#name. = SEXP_string_cstrcxx . . $ SEXP_string_cstr(c831a2fa12818dfe). (val);
443 SEXP_freecxx . . $ SEXP_free(c6b28547479798f4). (val);
444
445 val = probe_ent_getattrvalcxx . . $ probe_ent_getattrval(42b37380d22a3312). (ent, "operation");
446
447 if (val == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) {
448 request_st.opcxx . . $ rpminfo_req#op. = OVAL_OPERATION_EQUALScxx . . $ OVAL_OPERATION_EQUALS.;
449 } else {
450 request_st.opcxx . . $ rpminfo_req#op. = (oval_operation_tcxx . . $ oval_operation_t#) SEXP_number_geti_32cxx . . $ SEXP_number_geti_32(e77439d026b7e3ce). (val);
451
452 switch (request_st.opcxx . . $ rpminfo_req#op.) {
453 case OVAL_OPERATION_EQUALScxx . . $ OVAL_OPERATION_EQUALS.:
454 case OVAL_OPERATION_NOT_EQUALcxx . . $ OVAL_OPERATION_NOT_EQUAL.:
455 case OVAL_OPERATION_PATTERN_MATCHcxx . . $ OVAL_OPERATION_PATTERN_MATCH.:
456 break;
457 default:
458 SEXP_freecxx . . $ SEXP_free(c6b28547479798f4). (val);
459 SEXP_freecxx . . $ SEXP_free(c6b28547479798f4). (ent);
460 freecxx . . $ free(5d22bdacc48458e8). (request_st.namecxx . . $ rpminfo_req#name.);
461 return (PROBE_EOPNOTSUPPcxx . . $ `src/OVAL/probes/public/probe-common.h:14:9`!);
462 }
463
464 SEXP_freecxx . . $ SEXP_free(c6b28547479798f4). (val);
465 }
466
467 if (request_st.namecxx . . $ rpminfo_req#name. == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) {
468 SEXP_freecxx . . $ SEXP_free(c6b28547479798f4). (ent);
469 switch (errnocxx . . $ `<external>/17633486526465735210/errno.h:38:10`!) {
470 case EINVALcxx . . $ `<external>/8987895939074593727/errno-base.h:26:9`!:
471 dDcxx . . $ `src/common/debug_priv.h:64:9`!("%s: invalid value type", "name");
472 return PROBE_EINVALcxx . . $ `src/OVAL/probes/public/probe-common.h:8:9`!;
473 break;
474 case EFAULTcxx . . $ `<external>/8987895939074593727/errno-base.h:18:9`!:
475 dDcxx . . $ `src/common/debug_priv.h:64:9`!("%s: element not found", "name");
476 return PROBE_ENOELMcxx . . $ `src/OVAL/probes/public/probe-common.h:9:9`!;
477 break;
478 default:
479 return PROBE_EUNKNOWNcxx . . $ `src/OVAL/probes/public/probe-common.h:24:9`!;
480 }
481 }
482
483 reply_st = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!;
484
485 /* get info from RPM db */
486 switch (rpmret = get_rpminfocxx . . $ get_rpminfo(6e853c90470b9331).(&request_st, &reply_st, g_rpm)) {
487 case 0: /* Not found */
488 dIcxx . . $ `src/common/debug_priv.h:61:9`!("Package \"%s\" not found.", request_st.name);
489 break;
490 case -1: /* Error */
491 dDcxx . . $ `src/common/debug_priv.h:64:9`!("get_rpminfo failed");
492
493 item = probe_item_createcxx . . $ probe_item_create(36b16a6622050a9c).(OVAL_LINUX_RPM_INFOcxx . . $ OVAL_LINUX_RPM_INFO., NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!,
494 "name", OVAL_DATATYPE_STRINGcxx . . $ OVAL_DATATYPE_STRING., request_st.namecxx . . $ rpminfo_req#name.,
495 NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!);
496
497 probe_item_setstatuscxx . . $ probe_item_setstatus(112b785eb420e6c0). (item, SYSCHAR_STATUS_ERRORcxx . . $ SYSCHAR_STATUS_ERROR.);
498 probe_item_collectcxx . . $ probe_item_collect(11bb80e0c30650d7).(ctx, item);
499 break;
500 default: /* Ok */
501 _Acxx . . $ `src/common/debug_priv.h:43:9`!(rpmret >= 0);
502 _Acxx . . $ `src/common/debug_priv.h:43:9`!(reply_st != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!);
503 {
504 SEXP_tcxx . . $ SEXP_t# *name;
505
506 for (i = 0; i < rpmret; ++i) {
507 name = SEXP_string_newfcxx . . $ SEXP_string_newf(b2137ed863725962).("%s", reply_st[i].namecxx . . $ rpminfo_rep#name.);
508
509 if (probe_entobj_cmpcxx . . $ probe_entobj_cmp(e245451a1311e799).(ent, name) != OVAL_RESULT_TRUEcxx . . $ OVAL_RESULT_TRUE.) {
510 SEXP_freecxx . . $ SEXP_free(c6b28547479798f4).(name);
511 continue;
512 }
513
514 item = probe_item_createcxx . . $ probe_item_create(36b16a6622050a9c).(OVAL_LINUX_RPM_INFOcxx . . $ OVAL_LINUX_RPM_INFO., NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!,
515 "name", OVAL_DATATYPE_SEXPcxx . . $ OVAL_DATATYPE_SEXP., name,
516 "arch", OVAL_DATATYPE_STRINGcxx . . $ OVAL_DATATYPE_STRING., reply_st[i].archcxx . . $ rpminfo_rep#arch.,
517 "epoch", OVAL_DATATYPE_STRINGcxx . . $ OVAL_DATATYPE_STRING., reply_st[i].epochcxx . . $ rpminfo_rep#epoch.,
518 "release", OVAL_DATATYPE_STRINGcxx . . $ OVAL_DATATYPE_STRING., reply_st[i].releasecxx . . $ rpminfo_rep#release.,
519 "version", OVAL_DATATYPE_STRINGcxx . . $ OVAL_DATATYPE_STRING., reply_st[i].versioncxx . . $ rpminfo_rep#version.,
520 "evr", OVAL_DATATYPE_EVR_STRINGcxx . . $ OVAL_DATATYPE_EVR_STRING., reply_st[i].evrcxx . . $ rpminfo_rep#evr.,
521 "signature_keyid", OVAL_DATATYPE_STRINGcxx . . $ OVAL_DATATYPE_STRING., reply_st[i].signature_keyidcxx . . $ rpminfo_rep#signature_keyid.,
522 NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!);
523
524 /* OVAL 5.10 added extended_name and filepaths behavior */
525 if (oval_schema_version_cmpcxx . . $ oval_schema_version_cmp(b4d0c2bfb97f274f).(over, OVAL_SCHEMA_VERSIONcxx . . $ `src/OVAL/public/oval_schema_version.h:39:9`!(5.10)) >= 0) {
526 SEXP_tcxx . . $ SEXP_t# *value, *bh_value;
527 value = probe_entval_from_cstrcxx . . $ probe_entval_from_cstr(abb8c272acf0bd7e).(
528 OVAL_DATATYPE_STRINGcxx . . $ OVAL_DATATYPE_STRING.,
529 reply_st[i].extended_namecxx . . $ rpminfo_rep#extended_name.,
530 strlencxx . . $ strlen(751346f8406fd082).(reply_st[i].extended_namecxx . . $ rpminfo_rep#extended_name.)
531 );
532 probe_item_ent_addcxx . . $ probe_item_ent_add(9f488d3b029fc9d1).(item, "extended_name", NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!, value);
533 SEXP_freecxx . . $ SEXP_free(c6b28547479798f4).(value);
534
535 /*
536 * Parse behaviors
537 */
538 value = probe_obj_getentcxx . . $ probe_obj_getent(7907a01f2ff841f3).(probe_in, "behaviors", 1);
539 if (value != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) {
540 bh_value = probe_ent_getattrvalcxx . . $ probe_ent_getattrval(42b37380d22a3312).(value, "filepaths");
541 if (bh_value != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) {
542 if (SEXP_strcmpcxx . . $ SEXP_strcmp(3ef1a37bcb3c2a).(bh_value, "true") == 0) {
543 /* collect package files */
544 collect_rpm_filescxx . . $ collect_rpm_files(6251b7da74f7bdf2).(item, &reply_st[i], g_rpm);
545
546 }
547 SEXP_freecxx . . $ SEXP_free(c6b28547479798f4).(bh_value);
548 }
549 SEXP_freecxx . . $ SEXP_free(c6b28547479798f4).(value);
550 }
551
552 }
553
554
555 SEXP_freecxx . . $ SEXP_free(c6b28547479798f4).(name);
556 __rpminfo_rep_freecxx . . $ __rpminfo_rep_free(cec4f44b99565f0c). (&(reply_st[i]));
557
558 if (probe_item_collectcxx . . $ probe_item_collect(11bb80e0c30650d7).(ctx, item) < 0) {
559 SEXP_freecxx . . $ SEXP_free(c6b28547479798f4).(ent);
560 return PROBE_EUNKNOWNcxx . . $ `src/OVAL/probes/public/probe-common.h:24:9`!;
561 }
562 }
563
564 freecxx . . $ free(5d22bdacc48458e8). (reply_st);
565 }
566 }
567
568 SEXP_freecxx . . $ SEXP_free(c6b28547479798f4).(ent);
569 freecxx . . $ free(5d22bdacc48458e8).(request_st.namecxx . . $ rpminfo_req#name.);
570
571 return 0;
572 }