Debian Codegraph @

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

raw symbols SCIP
1 /**
2 * @file rpmverifypackage_probe.c
3 * @brief rpmverifypackage probe
4 * @author "Daniel Kopecek" <[email protected]>
5 * @author "Petr Lautrbach" <[email protected]>
6 *
7 */
8
9 /*
10 * Copyright 2012 Red Hat Inc., Durham, North Carolina.
11 * All Rights Reserved.
12 *
13 * This library is free software; you can redistribute it and/or
14 * modify it under the terms of the GNU Lesser General Public
15 * License as published by the Free Software Foundation; either
16 * version 2.1 of the License, or (at your option) any later version.
17 *
18 * This library is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
21 * Lesser General Public License for more details.
22 *
23 * You should have received a copy of the GNU Lesser General Public
24 * License along with this library; if not, write to the Free Software
25 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
26 *
27 * Authors:
28 * "Daniel Kopecek" <[email protected]>
29 * "Petr Lautrbach" <[email protected]>
30 */
31
32 #ifdef HAVE_CONFIG_Hcxx . . $ `<built-in>:409:9`!
33 #include <config.h>cxx . . $ `<file>/build/config.h`/
34 #endif
35
36 #include <stdio.h>
37 #include <string.h>
38 #include <errno.h>
39 #include <assert.h>
40 #include <limits.h>
41 #include <sys/types.h>
42 #include <sys/stat.h>
43 #include <fcntl.h>
44
45 #include "rpm-helper.h"cxx . . $ `<file>/src/OVAL/probes/unix/linux/rpm-helper.h`/
46 #include "probe-chroot.h"cxx . . $ `<file>/src/OVAL/probes/unix/linux/probe-chroot.h`/
47
48 /* Individual RPM headers */
49 #include <rpm/rpmfi.h>
50 #include <rpm/rpmcli.h>
51 #include <popt.h>
52
53 /* SEAP */
54 #include <probe-api.h>cxx . . $ `<file>/src/OVAL/probes/public/probe-api.h`/
55 #include "debug_priv.h"cxx . . $ `<file>/src/common/debug_priv.h`/
56 #include "probe/entcmp.h"cxx . . $ `<file>/src/OVAL/probes/probe/entcmp.h`/
57
58 #include <probe/probe.h>cxx . . $ `<file>/src/OVAL/probes/probe/probe.h`/
59 #include <probe/option.h>cxx . . $ `<file>/src/OVAL/probes/probe/option.h`/
60
61 #include "rpmverifypackage_probe.h"cxx . . $ `<file>/src/OVAL/probes/unix/linux/rpmverifypackage_probe.h`/
62
63 typedef structcxx . . $ $anonymous_type_9049a4a8312490a_0# {
64 const char *a_namecxx . . $ $anonymous_type_9049a4a8312490a_0#a_name.;
65 uint64_tcxx . . $ uint64_t# a_flagcxx . . $ $anonymous_type_9049a4a8312490a_0#a_flag.;
66 const char *a_optioncxx . . $ $anonymous_type_9049a4a8312490a_0#a_option.;
67 } rpmverifypackage_bhmap_tcxx . . $ rpmverifypackage_bhmap_t#;
68
69 const rpmverifypackage_bhmap_tcxx . . $ rpmverifypackage_bhmap_t# rpmverifypackage_bhmapcxx . . $ rpmverifypackage_bhmap.[] = {
70 { "nodeps", (uint64_tcxx . . $ uint64_t#)VERIFY_DEPScxx . . $ VERIFY_DEPS. , "--nodeps"},
71 { "noscripts", (uint64_tcxx . . $ uint64_t#)VERIFY_SCRIPTcxx . . $ VERIFY_SCRIPT. , "--noscript"},
72 };
73
74 struct rpmverify_rescxx . . $ rpmverify_res# {
75 char *namecxx . . $ rpmverify_res#name.; /**< package name */
76 char *epochcxx . . $ rpmverify_res#epoch.;
77 char *versioncxx . . $ rpmverify_res#version.;
78 char *releasecxx . . $ rpmverify_res#release.;
79 char *archcxx . . $ rpmverify_res#arch.;
80 char extended_namecxx . . $ rpmverify_res#extended_name.[1024];
81 uint64_tcxx . . $ uint64_t# vflagscxx . . $ rpmverify_res#vflags.; /**< rpm verify flags */
82 uint64_tcxx . . $ uint64_t# vresultscxx . . $ rpmverify_res#vresults.;
83 };
84
85 #define RPMVERIFY_SKIP_CONFIGcxx . . $ `src/OVAL/probes/unix/linux/rpmverifypackage_probe.c:85:9`! 0x1000000000000000
86 #define RPMVERIFY_SKIP_GHOSTcxx . . $ `src/OVAL/probes/unix/linux/rpmverifypackage_probe.c:86:9`! 0x2000000000000000
87 #define RPMVERIFY_RPMATTRMASKcxx . . $ `src/OVAL/probes/unix/linux/rpmverifypackage_probe.c:87:9`! 0x00000000ffffffff
88
89 struct verifypackage_globalcxx . . $ verifypackage_global# {
90 struct rpm_probe_globalcxx . . $ rpm_probe_global# rpmcxx . . $ verifypackage_global#rpm.;
91 struct probe_chrootcxx . . $ probe_chroot# chrcxx . . $ verifypackage_global#chr.;
92 };
93
94 static struct poptOptioncxx . . $ poptOption# optionsTablecxx . . $ optionsTable.[] = {
95 { NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!, '\0', POPT_ARG_INCLUDE_TABLEcxx . . $ `<external>/16232926639102580118/popt.h:22:9`!, rpmcliAllPoptTablecxx . . $ rpmcliAllPoptTable., 0,
96 "Common options for all rpm modes and executables:", NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`! },
97 { NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!, '\0', POPT_ARG_INCLUDE_TABLEcxx . . $ `<external>/16232926639102580118/popt.h:22:9`!, rpmVerifyPoptTablecxx . . $ rpmVerifyPoptTable., 0,
98 "Query options (with -q or --query):", NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`! },
99 POPT_AUTOALIAScxx . . $ `<external>/16232926639102580118/popt.h:148:9`!
100 POPT_AUTOHELPcxx . . $ `<external>/16232926639102580118/popt.h:158:9`!
101 POPT_TABLEENDcxx . . $ `<external>/16232926639102580118/popt.h:161:9`!
102 };
103
104 #define RPMVERIFY_LOCKcxx . . $ `src/OVAL/probes/unix/linux/rpmverifypackage_probe.c:104:9`! RPM_MUTEX_LOCKcxx . . $ `src/OVAL/probes/unix/linux/rpm-helper.h:59:9`!(&g_rpm->rpm.mutex)
105
106 #define RPMVERIFY_UNLOCKcxx . . $ `src/OVAL/probes/unix/linux/rpmverifypackage_probe.c:106:9`! RPM_MUTEX_UNLOCKcxx . . $ `src/OVAL/probes/unix/linux/rpm-helper.h:69:9`!(&g_rpm->rpm.mutex)
107
108 #define CHROOT_ENTERcxx . . $ `src/OVAL/probes/unix/linux/rpmverifypackage_probe.c:108:9`!() probe_chroot_enter(&g_rpm->chr)
109
110 #define CHROOT_LEAVEcxx . . $ `src/OVAL/probes/unix/linux/rpmverifypackage_probe.c:110:9`!() probe_chroot_leave(&g_rpm->chr)
111
112 #define CHROOT_IS_SETcxx . . $ `src/OVAL/probes/unix/linux/rpmverifypackage_probe.c:112:9`!() probe_chroot_is_set(&g_rpm->chr)
113
114 #define CHROOT_PATHcxx . . $ `src/OVAL/probes/unix/linux/rpmverifypackage_probe.c:114:9`!() probe_chroot_get_path(&g_rpm->chr)
115
116 /* modify passed-in iterator to test also given entity */
117 static int adjust_filtercxx . . $ adjust_filter(d18df26666f416ae).(rpmdbMatchIteratorcxx . . $ rpmdbMatchIterator# iterator, SEXP_tcxx . . $ SEXP_t# *ent, rpmTagcxx . . $ rpmTag# rpm_tag) {
118 oval_operation_tcxx . . $ oval_operation_t# ent_op;
119 char ent_str[1024] = "";
120 int ret = 0;
121
122 if (ent) {
123 ent_op = probe_ent_getoperationcxx . . $ probe_ent_getoperation(8f085ec993ec77d).(ent, OVAL_OPERATION_EQUALScxx . . $ OVAL_OPERATION_EQUALS.);
124 PROBE_ENT_STRVALcxx . . $ `src/OVAL/probes/public/probe-api.h:487:9`!(ent, ent_str, sizeof ent_str, /* void */, strcpy(ent_str, ""););
125 if (rpm_tag == RPMTAG_EPOCHcxx . . $ RPMTAG_EPOCH. && strcmpcxx . . $ strcmp(5ae29d726ae57f88).(ent_str, "(none)") == 0) {
126 return ret;
127 }
128
129 switch (ent_op) {
130 case OVAL_OPERATION_EQUALScxx . . $ OVAL_OPERATION_EQUALS.:
131 if (rpmdbSetIteratorREcxx . . $ rpmdbSetIteratorRE(24a7459ecac1f13c). (iterator, rpm_tag, RPMMIRE_STRCMPcxx . . $ RPMMIRE_STRCMP., ent_str) != 0)
132 ret = -1;
133
134 break;
135 case OVAL_OPERATION_PATTERN_MATCHcxx . . $ OVAL_OPERATION_PATTERN_MATCH.:
136 if (rpmdbSetIteratorREcxx . . $ rpmdbSetIteratorRE(24a7459ecac1f13c). (iterator, rpm_tag, RPMMIRE_REGEXcxx . . $ RPMMIRE_REGEX.,
137 (const char *)ent_str) != 0)
138 ret = -1;
139
140 break;
141 default:
142 ret = 0;
143 }
144 }
145 return ret;
146 }
147
148 static int rpmverify_collectcxx . . $ rpmverify_collect(1840ae91e4a6ed85).(probe_ctxcxx . . $ probe_ctx# *ctx,
149 SEXP_tcxx . . $ SEXP_t# *name_ent, SEXP_tcxx . . $ SEXP_t# *epoch_ent, SEXP_tcxx . . $ SEXP_t# *version_ent, SEXP_tcxx . . $ SEXP_t# *release_ent, SEXP_tcxx . . $ SEXP_t# *arch_ent,
150 uint64_tcxx . . $ uint64_t# flags,
151 int (*callback)(probe_ctxcxx . . $ probe_ctx# *, struct rpmverify_rescxx . . $ rpmverify_res# *),
152 struct verifypackage_globalcxx . . $ verifypackage_global# *g_rpm)
153 {
154 rpmdbMatchIteratorcxx . . $ rpmdbMatchIterator# match;
155 Headercxx . . $ Header# pkgh;
156 int ret = -1;
157 unsigned int i, j, rpmcli_argc = 0;
158 const char * rpmcli_argv[10];
159 poptContextcxx . . $ poptContext# rpmcli_context;
160 QVA_tcxx . . $ QVA_t# qva;
161
162 RPMVERIFY_LOCKcxx . . $ `src/OVAL/probes/unix/linux/rpmverifypackage_probe.c:104:9`!;
163
164 match = rpmtsInitIteratorcxx . . $ rpmtsInitIterator(41c3f6b2f2ef385d). (g_rpm->rpmcxx . . $ verifypackage_global#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);
165 if (match == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) {
166 ret = 0;
167 goto ret;
168 }
169
170 if ((ret = adjust_filtercxx . . $ adjust_filter(d18df26666f416ae).(match, name_ent, RPMTAG_NAMEcxx . . $ RPMTAG_NAME.)) == -1) {
171 dEcxx . . $ `src/common/debug_priv.h:63:9`!("can't adjust filter with name");
172 goto ret;
173 }
174 if ((ret = adjust_filtercxx . . $ adjust_filter(d18df26666f416ae).(match, epoch_ent, RPMTAG_EPOCHcxx . . $ RPMTAG_EPOCH.)) == -1) {
175 dEcxx . . $ `src/common/debug_priv.h:63:9`!("can't adjust filter with epoch");
176 goto ret;
177 }
178 if ((ret = adjust_filtercxx . . $ adjust_filter(d18df26666f416ae).(match, version_ent, RPMTAG_VERSIONcxx . . $ RPMTAG_VERSION.)) == -1) {
179 dEcxx . . $ `src/common/debug_priv.h:63:9`!("can't adjust filter with version");
180 goto ret;
181 }
182 if ((ret = adjust_filtercxx . . $ adjust_filter(d18df26666f416ae).(match, release_ent, RPMTAG_RELEASEcxx . . $ RPMTAG_RELEASE.)) == -1) {
183 dEcxx . . $ `src/common/debug_priv.h:63:9`!("can't adjust filter with version");
184 goto ret;
185 }
186 if ((ret = adjust_filtercxx . . $ adjust_filter(d18df26666f416ae).(match, arch_ent, RPMTAG_ARCHcxx . . $ RPMTAG_ARCH.)) == -1) {
187 dEcxx . . $ `src/common/debug_priv.h:63:9`!("can't adjust filter with version");
188 goto ret;
189 }
190
191 if (RPMTAG_BASENAMEScxx . . $ RPMTAG_BASENAMES. == 0 || RPMTAG_DIRNAMEScxx . . $ RPMTAG_DIRNAMES. == 0) {
192 return -1;
193 }
194
195 rpmcli_argv[0] = "probe_rpmverifypackage";
196 rpmcli_argv[1] = "--quiet";
197 rpmcli_argv[2] = "--nofiles";
198
199 while ((pkgh = rpmdbNextIteratorcxx . . $ rpmdbNextIterator(12a0bfe3c2421784). (match)) != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) {
200 SEXP_tcxx . . $ SEXP_t# *ent;
201 struct rpmverify_rescxx . . $ rpmverify_res# res;
202 errmsg_tcxx . . $ errmsg_t# rpmerr;
203
204 #define COMPARE_ENTcxx . . $ `src/OVAL/probes/unix/linux/rpmverifypackage_probe.c:204:9`!(XXX) \
205 if (XXX ## _ent != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) { \
206 ent = probe_entval_from_cstr( \
207 probe_ent_getdatatype(XXX ## _ent), res.XXX, strlen(res.XXX) \
208 ); \
209 if (ent != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`! && probe_entobj_cmp(XXX ## _ent, ent) != OVAL_RESULT_TRUE) { \
210 SEXP_free(ent); \
211 continue; \
212 } \
213 SEXP_free(ent); \
214 }
215
216 res.namecxx . . $ rpmverify_res#name. = headerFormatcxx . . $ headerFormat(ff7bd715129ef29).(pkgh, "%{NAME}", &rpmerr);
217 COMPARE_ENTcxx . . $ `src/OVAL/probes/unix/linux/rpmverifypackage_probe.c:204:9`!(name);
218
219 res.epochcxx . . $ rpmverify_res#epoch. = headerFormatcxx . . $ headerFormat(ff7bd715129ef29).(pkgh, "%{EPOCH}", &rpmerr);
220 COMPARE_ENTcxx . . $ `src/OVAL/probes/unix/linux/rpmverifypackage_probe.c:204:9`!(epoch);
221
222 res.versioncxx . . $ rpmverify_res#version. = headerFormatcxx . . $ headerFormat(ff7bd715129ef29).(pkgh, "%{VERSION}", &rpmerr);
223 COMPARE_ENTcxx . . $ `src/OVAL/probes/unix/linux/rpmverifypackage_probe.c:204:9`!(version);
224 res.releasecxx . . $ rpmverify_res#release. = headerFormatcxx . . $ headerFormat(ff7bd715129ef29).(pkgh, "%{RELEASE}", &rpmerr);
225 COMPARE_ENTcxx . . $ `src/OVAL/probes/unix/linux/rpmverifypackage_probe.c:204:9`!(release);
226 res.archcxx . . $ rpmverify_res#arch. = headerFormatcxx . . $ headerFormat(ff7bd715129ef29).(pkgh, "%{ARCH}", &rpmerr);
227 COMPARE_ENTcxx . . $ `src/OVAL/probes/unix/linux/rpmverifypackage_probe.c:204:9`!(arch);
228 snprintfcxx . . $ snprintf(ea502d73e74c754c).(res.extended_namecxx . . $ rpmverify_res#extended_name., 1024, "%s-%s:%s-%s.%s", res.namecxx . . $ rpmverify_res#name.,
229 oscap_streqcxx . . $ oscap_streq(b7a7aa4a824b7595).(res.epochcxx . . $ rpmverify_res#epoch., "(none)") ? "0" : res.epochcxx . . $ rpmverify_res#epoch.,
230 res.versioncxx . . $ rpmverify_res#version., res.releasecxx . . $ rpmverify_res#release., res.archcxx . . $ rpmverify_res#arch.);
231
232 /*
233 * Verify package
234 */
235 res.vflagscxx . . $ rpmverify_res#vflags. = res.vresultscxx . . $ rpmverify_res#vresults. = 0;
236
237 /* if a --no<flag> is set then we don't run rpmVerify else
238 * we need to run rpm -V with all other --no<flags>
239 */
240 for (i = 0; i < sizeof rpmverifypackage_bhmapcxx . . $ rpmverifypackage_bhmap./sizeof(rpmverifypackage_bhmap_tcxx . . $ rpmverifypackage_bhmap_t#); ++i) {
241 rpmcli_argc = 3;
242 if (flags & rpmverifypackage_bhmapcxx . . $ rpmverifypackage_bhmap.[i].a_flagcxx . . $ $anonymous_type_9049a4a8312490a_0#a_flag.)
243 continue;
244
245 for (j = 0; j < sizeof rpmverifypackage_bhmapcxx . . $ rpmverifypackage_bhmap./sizeof(rpmverifypackage_bhmap_tcxx . . $ rpmverifypackage_bhmap_t#); ++j) {
246 if (j == i)
247 continue;
248
249 rpmcli_argv[rpmcli_argc++] = rpmverifypackage_bhmapcxx . . $ rpmverifypackage_bhmap.[j].a_optioncxx . . $ $anonymous_type_9049a4a8312490a_0#a_option.;
250 }
251 rpmcli_argv[rpmcli_argc++] = res.namecxx . . $ rpmverify_res#name.;
252 rpmcli_argv[rpmcli_argc] = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!;
253
254 if (CHROOT_IS_SETcxx . . $ `src/OVAL/probes/unix/linux/rpmverifypackage_probe.c:112:9`!())
255 {
256 rpmLibsPreloadcxx . . $ rpmLibsPreload(49f6e7a06ebc5aa8).();
257 if (CHROOT_ENTERcxx . . $ `src/OVAL/probes/unix/linux/rpmverifypackage_probe.c:108:9`!() < 0) {
258 ret = 1;
259 goto ret;
260 }
261 }
262
263 rpmcli_context = rpmcliInitcxx . . $ rpmcliInit(18993e8489873e32).(rpmcli_argc, (char * const*)rpmcli_argv, optionsTablecxx . . $ optionsTable.);
264 qva = &rpmQVKArgscxx . . $ rpmQVKArgs.;
265 rpmVerifyFlagscxx . . $ rpmVerifyFlags# verifyFlags = VERIFY_ALLcxx . . $ `<external>/7353663954505164557/rpmcli.h:273:9`!;
266 verifyFlags &= ~qva->qva_flagscxx . . $ rpmQVKArguments_s#qva_flags.;
267 qva->qva_flagscxx . . $ rpmQVKArguments_s#qva_flags. = (rpmQueryFlagscxx . . $ rpmQueryFlags#) verifyFlags;
268
269 // rpmcliFini() causes free of rpmrc, macros, ...
270 // so we have to reload everything again
271 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`!);
272
273 /*
274 * Fedora >=36 changed the default dbpath in librpm from /var/lib/rpm to /usr/lib/sysimage/rpm
275 * See: https://fedoraproject.org/wiki/Changes/RelocateRPMToUsr
276 * Therefore, when running openscap on a Fedora >=36 system scanning another systems (such as RHEL, SLES, Fedora<36)
277 * openscap's librpm will try to read the rpm db from /usr/lib/sysimage/rpm which doesn't exist and therefore won't work.
278 * In implementing this change, /var/lib/rpm is still a symlink to /usr/lib/sysimage/rpm
279 * so /var/lib/rpm still works. So /var/lib/rpm is a dbpath that will work on all systems.
280 * Therefore, set the dbpath to be /var/lib/rpm, allow openscap running on any system to scan any system.
281 */
282 rpmPushMacrocxx . . $ rpmPushMacro(d3a70335639f9adf).(NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!, "_dbpath", NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!, "/var/lib/rpm", RMIL_CMDLINEcxx . . $ `<external>/2040797851061054216/rpmmacro.h:47:9`!);
283
284 rpmtscxx . . $ rpmts# ts = rpmtsCreatecxx . . $ rpmtsCreate(17624c196b75261f).();
285 char* const * args = (char* const *)poptGetArgscxx . . $ poptGetArgs(a29d6e5da170a4c3).(rpmcli_context);
286
287 if (CHROOT_IS_SETcxx . . $ `src/OVAL/probes/unix/linux/rpmverifypackage_probe.c:112:9`!()){
288
289 // plugins for offline mode can cause, that .so from
290 // container are loaded - we don't want it
291 DISABLE_PLUGINScxx . . $ `src/OVAL/probes/unix/linux/rpm-helper.h:88:9`!(ts);
292 CHROOT_LEAVEcxx . . $ `src/OVAL/probes/unix/linux/rpmverifypackage_probe.c:110:9`!();
293 } else {
294 ret = rpmcliVerifycxx . . $ rpmcliVerify(c534e904b3ee72ac).(ts, qva, args);
295 }
296
297 ts = rpmtsFreecxx . . $ rpmtsFree(39c31376fa367c52).(ts);
298 rpmcli_context = rpmcliFinicxx . . $ rpmcliFini(c32b9b4db48a8347).(rpmcli_context);
299
300 res.vflagscxx . . $ rpmverify_res#vflags. |= rpmverifypackage_bhmapcxx . . $ rpmverifypackage_bhmap.[i].a_flagcxx . . $ $anonymous_type_9049a4a8312490a_0#a_flag.;
301 if (ret == 0)
302 res.vresultscxx . . $ rpmverify_res#vresults. |= rpmverifypackage_bhmapcxx . . $ rpmverifypackage_bhmap.[i].a_flagcxx . . $ $anonymous_type_9049a4a8312490a_0#a_flag.;
303
304 }
305 if (callback(ctx, &res)) {
306 ret = 1;
307 goto ret;
308 }
309 freecxx . . $ free(5d22bdacc48458e8).(res.namecxx . . $ rpmverify_res#name.);
310 freecxx . . $ free(5d22bdacc48458e8).(res.epochcxx . . $ rpmverify_res#epoch.);
311 freecxx . . $ free(5d22bdacc48458e8).(res.versioncxx . . $ rpmverify_res#version.);
312 freecxx . . $ free(5d22bdacc48458e8).(res.releasecxx . . $ rpmverify_res#release.);
313 freecxx . . $ free(5d22bdacc48458e8).(res.archcxx . . $ rpmverify_res#arch.);
314 }
315
316 match = rpmdbFreeIteratorcxx . . $ rpmdbFreeIterator(8defa6d083da6e8). (match);
317 ret = 0;
318 ret:
319 RPMVERIFY_UNLOCKcxx . . $ `src/OVAL/probes/unix/linux/rpmverifypackage_probe.c:106:9`!;
320 return (ret);
321 }
322
323 int rpmverifypackage_probe_offline_mode_supportedcxx . . $ rpmverifypackage_probe_offline_mode_supported(b126dc7c1de90089).()
324 {
325 return PROBE_OFFLINE_OWNcxx . . $ PROBE_OFFLINE_OWN.;
326 }
327
328 void *rpmverifypackage_probe_initcxx . . $ rpmverifypackage_probe_init(50c7df7de5344ebb).(void)
329 {
330 const char* root = getenvcxx . . $ getenv(a8b8e32347182212).("OSCAP_PROBE_ROOT");
331 if ((root!= NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) && (strlencxx . . $ strlen(751346f8406fd082).(root) == 0)) {
332 root = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!;
333 }
334
335 struct verifypackage_globalcxx . . $ verifypackage_global# *g_rpm = malloccxx . . $ malloc(bfcfa4d6b7f7ef64).(sizeof(struct verifypackage_globalcxx . . $ verifypackage_global#));
336 probe_chroot_initcxx . . $ probe_chroot_init(a29411824056a).(&g_rpm->chrcxx . . $ verifypackage_global#chr., root);
337
338 #ifdef RPM46_FOUNDcxx . . $ `build/config.h:46:9`!
339 rpmlogSetCallbackcxx . . $ rpmlogSetCallback(3af8381b9d28b514).(rpmErrorCbcxx . . $ rpmErrorCb(fff58a40e215938)., NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!);
340 #endif
341
342 if (CHROOT_IS_SETcxx . . $ `src/OVAL/probes/unix/linux/rpmverifypackage_probe.c:112:9`!()) {
343 rpmLibsPreloadcxx . . $ rpmLibsPreload(49f6e7a06ebc5aa8).();
344 if (CHROOT_ENTERcxx . . $ `src/OVAL/probes/unix/linux/rpmverifypackage_probe.c:108:9`!() < 0) {
345 probe_chroot_freecxx . . $ probe_chroot_free(139f9897610b6464).(&g_rpm->chrcxx . . $ verifypackage_global#chr.);
346 freecxx . . $ free(5d22bdacc48458e8).(g_rpm);
347 return (NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!);
348 }
349 }
350
351 if (rpmReadConfigFilescxx . . $ rpmReadConfigFiles(5ae29d726ae57f88). (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) {
352 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`!));
353 g_rpm->rpmcxx . . $ verifypackage_global#rpm..rpmtscxx . . $ rpm_probe_global#rpmts. = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!;
354 return ((void *)g_rpm);
355 }
356
357
358 g_rpm->rpmcxx . . $ verifypackage_global#rpm..rpmtscxx . . $ rpm_probe_global#rpmts. = rpmtsCreatecxx . . $ rpmtsCreate(17624c196b75261f).();
359
360 if (CHROOT_IS_SETcxx . . $ `src/OVAL/probes/unix/linux/rpmverifypackage_probe.c:112:9`!()) {
361 CHROOT_LEAVEcxx . . $ `src/OVAL/probes/unix/linux/rpmverifypackage_probe.c:110:9`!();
362
363 // plugins for offline mode can cause, that .so from
364 // container are loaded - we don't want it
365 DISABLE_PLUGINScxx . . $ `src/OVAL/probes/unix/linux/rpm-helper.h:88:9`!(g_rpm->rpm.rpmts);
366
367 rpmtsSetRootDircxx . . $ rpmtsSetRootDir(23a209d8fccc3ea8).(g_rpm->rpmcxx . . $ verifypackage_global#rpm..rpmtscxx . . $ rpm_probe_global#rpmts., CHROOT_PATHcxx . . $ `src/OVAL/probes/unix/linux/rpmverifypackage_probe.c:114:9`!());
368 }
369
370 set_rpm_db_pathcxx . . $ set_rpm_db_path(49f6e7a06ebc5aa8).();
371 pthread_mutex_initcxx . . $ pthread_mutex_init(db9d29dab44ea1aa).(&(g_rpm->rpmcxx . . $ verifypackage_global#rpm..mutexcxx . . $ rpm_probe_global#mutex.), NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!);
372 return ((void *)g_rpm);
373 }
374
375 void rpmverifypackage_probe_finicxx . . $ rpmverifypackage_probe_fini(5d22bdacc48458e8).(void *ptr)
376 {
377 struct verifypackage_globalcxx . . $ verifypackage_global# *r = (struct verifypackage_globalcxx . . $ verifypackage_global# *)ptr;
378
379 rpmFreeCryptocxx . . $ rpmFreeCrypto(b126dc7c1de90089).();
380 rpmFreeRpmrccxx . . $ rpmFreeRpmrc(49f6e7a06ebc5aa8).();
381 rpmFreeMacroscxx . . $ rpmFreeMacros(9f41120681ff0556).(NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!);
382 rpmlogClosecxx . . $ rpmlogClose(49f6e7a06ebc5aa8).();
383
384 // If r is null, probe_init() failed during chroot
385 if (r == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!)
386 return;
387
388 // This will be always set by probe_init(), lets free it
389 probe_chroot_freecxx . . $ probe_chroot_free(139f9897610b6464).(&r->chrcxx . . $ verifypackage_global#chr.);
390
391 // If r->rpm.rpmts was not initialized the mutex was not as well
392 if (r->rpmcxx . . $ verifypackage_global#rpm..rpmtscxx . . $ rpm_probe_global#rpmts. == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!)
393 return;
394
395 rpmtsFreecxx . . $ rpmtsFree(39c31376fa367c52).(r->rpmcxx . . $ verifypackage_global#rpm..rpmtscxx . . $ rpm_probe_global#rpmts.);
396 pthread_mutex_destroycxx . . $ pthread_mutex_destroy(d89ae235521888f9). (&(r->rpmcxx . . $ verifypackage_global#rpm..mutexcxx . . $ rpm_probe_global#mutex.));
397
398 freecxx . . $ free(5d22bdacc48458e8).(r);
399 return;
400 }
401
402 static int rpmverifypackage_additemcxx . . $ rpmverifypackage_additem(e8a8575ef97ee980).(probe_ctxcxx . . $ probe_ctx# *ctx, struct rpmverify_rescxx . . $ rpmverify_res# *res)
403 {
404 SEXP_tcxx . . $ SEXP_t# *item, *value;
405
406 item = probe_item_createcxx . . $ probe_item_create(36b16a6622050a9c).(OVAL_LINUX_RPMVERIFYPACKAGEcxx . . $ OVAL_LINUX_RPMVERIFYPACKAGE., NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!,
407 "name", OVAL_DATATYPE_STRINGcxx . . $ OVAL_DATATYPE_STRING., res->namecxx . . $ rpmverify_res#name.,
408 "epoch", OVAL_DATATYPE_STRINGcxx . . $ OVAL_DATATYPE_STRING., res->epochcxx . . $ rpmverify_res#epoch.,
409 "version", OVAL_DATATYPE_STRINGcxx . . $ OVAL_DATATYPE_STRING., res->versioncxx . . $ rpmverify_res#version.,
410 "release", OVAL_DATATYPE_STRINGcxx . . $ OVAL_DATATYPE_STRING., res->releasecxx . . $ rpmverify_res#release.,
411 "arch", OVAL_DATATYPE_STRINGcxx . . $ OVAL_DATATYPE_STRING., res->archcxx . . $ rpmverify_res#arch.,
412 "extended_name", OVAL_DATATYPE_STRINGcxx . . $ OVAL_DATATYPE_STRING., res->extended_namecxx . . $ rpmverify_res#extended_name.,
413 NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!);
414
415 if (res->vflagscxx . . $ rpmverify_res#vflags. & VERIFY_DEPScxx . . $ VERIFY_DEPS.) {
416 dDcxx . . $ `src/common/debug_priv.h:64:9`!("VERIFY_DEPS %lu", res->vresults & VERIFY_DEPS);
417 value = probe_entval_from_cstrcxx . . $ probe_entval_from_cstr(abb8c272acf0bd7e).(OVAL_DATATYPE_BOOLEANcxx . . $ OVAL_DATATYPE_BOOLEAN., (res->vresultscxx . . $ rpmverify_res#vresults. & VERIFY_DEPScxx . . $ VERIFY_DEPS. ? "1" : "0"), 1);
418 probe_item_ent_addcxx . . $ probe_item_ent_add(9f488d3b029fc9d1).(item, "dependency_check_passed", NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!, value);
419 SEXP_freecxx . . $ SEXP_free(c6b28547479798f4).(value);
420 }
421 if (res->vflagscxx . . $ rpmverify_res#vflags. & VERIFY_SCRIPTcxx . . $ VERIFY_SCRIPT.) {
422 dDcxx . . $ `src/common/debug_priv.h:64:9`!("VERIFY_SCRIPT %lu", res->vresults & VERIFY_SCRIPT);
423 value = probe_entval_from_cstrcxx . . $ probe_entval_from_cstr(abb8c272acf0bd7e).(OVAL_DATATYPE_BOOLEANcxx . . $ OVAL_DATATYPE_BOOLEAN., (res->vresultscxx . . $ rpmverify_res#vresults. & VERIFY_SCRIPTcxx . . $ VERIFY_SCRIPT. ? "1" : "0"), 1);
424 probe_item_ent_addcxx . . $ probe_item_ent_add(9f488d3b029fc9d1).(item, "verification_script_successful", NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!, value);
425 SEXP_freecxx . . $ SEXP_free(c6b28547479798f4).(value);
426 }
427
428 return probe_item_collectcxx . . $ probe_item_collect(11bb80e0c30650d7).(ctx, item) == 2 ? 1 : 0;
429 }
430 int rpmverifypackage_probe_maincxx . . $ rpmverifypackage_probe_main(470536d3ffacaf10).(probe_ctxcxx . . $ probe_ctx# *ctx, void *arg)
431 {
432 SEXP_tcxx . . $ SEXP_t# *probe_in, *bh_ent;
433 SEXP_tcxx . . $ SEXP_t# *name_ent, *epoch_ent, *version_ent, *release_ent, *arch_ent;
434 uint64_tcxx . . $ uint64_t# collect_flags = 0;
435 unsigned int i;
436
437 // arg is NULL if we were not able to chroot during probe_init()
438 if (arg == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) {
439 return PROBE_EINITcxx . . $ `src/OVAL/probes/public/probe-common.h:12:9`!;
440 }
441 struct verifypackage_globalcxx . . $ verifypackage_global# *g_rpm = (struct verifypackage_globalcxx . . $ verifypackage_global# *)arg;
442
443 // There was no rpm config files
444 if (g_rpm->rpmcxx . . $ verifypackage_global#rpm..rpmtscxx . . $ rpm_probe_global#rpmts. == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) {
445 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.);
446 return 0;
447 }
448
449 /*
450 * Get refs to object entities
451 */
452 probe_in = probe_ctx_getobjectcxx . . $ probe_ctx_getobject(4299b6b53fa804a5).(ctx);
453
454 name_ent = probe_obj_getentcxx . . $ probe_obj_getent(7907a01f2ff841f3).(probe_in, "name", 1);
455 epoch_ent = probe_obj_getentcxx . . $ probe_obj_getent(7907a01f2ff841f3).(probe_in, "epoch", 1);
456 version_ent = probe_obj_getentcxx . . $ probe_obj_getent(7907a01f2ff841f3).(probe_in, "version", 1);
457 release_ent = probe_obj_getentcxx . . $ probe_obj_getent(7907a01f2ff841f3).(probe_in, "release", 1);
458 arch_ent = probe_obj_getentcxx . . $ probe_obj_getent(7907a01f2ff841f3).(probe_in, "arch", 1);
459
460 /*
461 * Parse behaviors
462 */
463 bh_ent = probe_obj_getentcxx . . $ probe_obj_getent(7907a01f2ff841f3).(probe_in, "behaviors", 1);
464
465 if (bh_ent != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) {
466 SEXP_tcxx . . $ SEXP_t# *aval;
467
468 for (i = 0; i < sizeof rpmverifypackage_bhmapcxx . . $ rpmverifypackage_bhmap./sizeof(rpmverifypackage_bhmap_tcxx . . $ rpmverifypackage_bhmap_t#); ++i) {
469 aval = probe_ent_getattrvalcxx . . $ probe_ent_getattrval(42b37380d22a3312).(bh_ent, rpmverifypackage_bhmapcxx . . $ rpmverifypackage_bhmap.[i].a_namecxx . . $ $anonymous_type_9049a4a8312490a_0#a_name.);
470
471 if (aval != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) {
472 if (SEXP_strcmpcxx . . $ SEXP_strcmp(3ef1a37bcb3c2a).(aval, "true") == 0) {
473 dDcxx . . $ `src/common/debug_priv.h:64:9`!("omit verify attr: %s", rpmverifypackage_bhmap[i].a_name);
474 collect_flags |= rpmverifypackage_bhmapcxx . . $ rpmverifypackage_bhmap.[i].a_flagcxx . . $ $anonymous_type_9049a4a8312490a_0#a_flag.;
475 }
476
477 SEXP_freecxx . . $ SEXP_free(c6b28547479798f4).(aval);
478 }
479 }
480
481 SEXP_freecxx . . $ SEXP_free(c6b28547479798f4).(bh_ent);
482 }
483
484 if (rpmverify_collectcxx . . $ rpmverify_collect(1840ae91e4a6ed85).(ctx, name_ent, epoch_ent, version_ent, release_ent,
485 arch_ent, collect_flags, rpmverifypackage_additemcxx . . $ rpmverifypackage_additem(e8a8575ef97ee980)., g_rpm) != 0)
486 {
487 dEcxx . . $ `src/common/debug_priv.h:63:9`!("An error ocured while collecting rpmverifypackage data");
488 probe_cobj_set_flagcxx . . $ probe_cobj_set_flag(644bab5dffe689c).(probe_ctx_getresultcxx . . $ probe_ctx_getresult(4299b6b53fa804a5).(ctx), SYSCHAR_FLAG_ERRORcxx . . $ SYSCHAR_FLAG_ERROR.);
489 }
490
491 SEXP_freecxx . . $ SEXP_free(c6b28547479798f4).(name_ent);
492 SEXP_freecxx . . $ SEXP_free(c6b28547479798f4).(epoch_ent);
493 SEXP_freecxx . . $ SEXP_free(c6b28547479798f4).(version_ent);
494 SEXP_freecxx . . $ SEXP_free(c6b28547479798f4).(release_ent);
495 SEXP_freecxx . . $ SEXP_free(c6b28547479798f4).(arch_ent);
496
497 return 0;
498 }