| 1 | /** |
| 2 | * @file rpmverify_probe.c |
| 3 | * @brief rpmverify probe |
| 4 | * @author "Daniel Kopecek" <[email protected]> |
| 5 | * |
| 6 | */ |
| 7 | |
| 8 | /* |
| 9 | * Copyright 2011 Red Hat Inc., Durham, North Carolina. |
| 10 | * All Rights Reserved. |
| 11 | * |
| 12 | * This library is free software; you can redistribute it and/or |
| 13 | * modify it under the terms of the GNU Lesser General Public |
| 14 | * License as published by the Free Software Foundation; either |
| 15 | * version 2.1 of the License, or (at your option) any later version. |
| 16 | * |
| 17 | * This library is distributed in the hope that it will be useful, |
| 18 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 19 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 20 | * Lesser General Public License for more details. |
| 21 | * |
| 22 | * You should have received a copy of the GNU Lesser General Public |
| 23 | * License along with this library; if not, write to the Free Software |
| 24 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA |
| 25 | * |
| 26 | * Authors: |
| 27 | * "Daniel Kopecek" <[email protected]> |
| 28 | */ |
| 29 | |
| 30 | #ifdef HAVE_CONFIG_Hcxx . . $ `<built-in>:409:9`! |
| 31 | #include <config.h>cxx . . $ `<file>/build/config.h`/ |
| 32 | #endif |
| 33 | |
| 34 | #include <stdio.h> |
| 35 | #include <string.h> |
| 36 | #include <errno.h> |
| 37 | #include <assert.h> |
| 38 | #include <limits.h> |
| 39 | #include <sys/types.h> |
| 40 | #include <sys/stat.h> |
| 41 | #include <fcntl.h> |
| 42 | |
| 43 | #include "rpm-helper.h"cxx . . $ `<file>/src/OVAL/probes/unix/linux/rpm-helper.h`/ |
| 44 | |
| 45 | /* Individual RPM headers */ |
| 46 | #include <rpm/rpmfi.h> |
| 47 | #include <rpm/rpmcli.h> |
| 48 | |
| 49 | /* SEAP */ |
| 50 | #include <probe-api.h>cxx . . $ `<file>/src/OVAL/probes/public/probe-api.h`/ |
| 51 | #include "debug_priv.h"cxx . . $ `<file>/src/common/debug_priv.h`/ |
| 52 | #include "probe/entcmp.h"cxx . . $ `<file>/src/OVAL/probes/probe/entcmp.h`/ |
| 53 | |
| 54 | #include <probe/probe.h>cxx . . $ `<file>/src/OVAL/probes/probe/probe.h`/ |
| 55 | #include <probe/option.h>cxx . . $ `<file>/src/OVAL/probes/probe/option.h`/ |
| 56 | #include "common/oscap_pcre.h"cxx . . $ `<file>/src/common/oscap_pcre.h`/ |
| 57 | |
| 58 | #include "rpmverify_probe.h"cxx . . $ `<file>/src/OVAL/probes/unix/linux/rpmverify_probe.h`/ |
| 59 | |
| 60 | struct rpmverify_rescxx . . $ rpmverify_res# { |
| 61 | char *namecxx . . $ rpmverify_res#name.; /**< package name */ |
| 62 | char *filecxx . . $ rpmverify_res#file.; /**< filepath */ |
| 63 | rpmVerifyAttrscxx . . $ rpmVerifyAttrs# vflagscxx . . $ rpmverify_res#vflags.; /**< rpm verify flags */ |
| 64 | rpmVerifyAttrscxx . . $ rpmVerifyAttrs# oflagscxx . . $ rpmverify_res#oflags.; /**< rpm verify omit flags */ |
| 65 | rpmfileAttrscxx . . $ rpmfileAttrs# fflagscxx . . $ rpmverify_res#fflags.; /**< rpm file flags */ |
| 66 | }; |
| 67 | |
| 68 | #define RPMVERIFY_SKIP_CONFIGcxx . . $ `src/OVAL/probes/unix/linux/rpmverify_probe.c:68:9`! 0x1000000000000000 |
| 69 | #define RPMVERIFY_SKIP_GHOSTcxx . . $ `src/OVAL/probes/unix/linux/rpmverify_probe.c:69:9`! 0x2000000000000000 |
| 70 | #define RPMVERIFY_RPMATTRMASKcxx . . $ `src/OVAL/probes/unix/linux/rpmverify_probe.c:70:9`! 0x00000000ffffffff |
| 71 | |
| 72 | #define RPMVERIFY_LOCKcxx . . $ `src/OVAL/probes/unix/linux/rpmverify_probe.c:72:9`! RPM_MUTEX_LOCKcxx . . $ `src/OVAL/probes/unix/linux/rpm-helper.h:59:9`!(&g_rpm->mutex) |
| 73 | #define RPMVERIFY_UNLOCKcxx . . $ `src/OVAL/probes/unix/linux/rpmverify_probe.c:73:9`! RPM_MUTEX_UNLOCKcxx . . $ `src/OVAL/probes/unix/linux/rpm-helper.h:69:9`!(&g_rpm->mutex) |
| 74 | |
| 75 | static int rpmverify_collectcxx . . $ rpmverify_collect(c80ac3e3d5df773f).(probe_ctxcxx . . $ probe_ctx# *ctx, |
| 76 | const char *name, oval_operation_tcxx . . $ oval_operation_t# name_op, |
| 77 | const char *file, oval_operation_tcxx . . $ oval_operation_t# file_op, |
| 78 | SEXP_tcxx . . $ SEXP_t# *name_ent, SEXP_tcxx . . $ SEXP_t# *filepath_ent, |
| 79 | uint64_tcxx . . $ uint64_t# flags, |
| 80 | void (*callback)(probe_ctxcxx . . $ probe_ctx# *, struct rpmverify_rescxx . . $ rpmverify_res# *), |
| 81 | struct rpm_probe_globalcxx . . $ rpm_probe_global# *g_rpm) |
| 82 | { |
| 83 | rpmdbMatchIteratorcxx . . $ rpmdbMatchIterator# match; |
| 84 | rpmVerifyAttrscxx . . $ rpmVerifyAttrs# omit = (rpmVerifyAttrscxx . . $ rpmVerifyAttrs#)(flags & RPMVERIFY_RPMATTRMASKcxx . . $ `src/OVAL/probes/unix/linux/rpmverify_probe.c:70:9`!); |
| 85 | Headercxx . . $ Header# pkgh; |
| 86 | oscap_pcre_tcxx . . $ oscap_pcre_t# *re = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!; |
| 87 | int ret = -1; |
| 88 | |
| 89 | /* pre-compile regex if needed */ |
| 90 | if (file_op == OVAL_OPERATION_PATTERN_MATCHcxx . . $ OVAL_OPERATION_PATTERN_MATCH.) { |
| 91 | char *errmsg; |
| 92 | int erroff; |
| 93 | |
| 94 | re = oscap_pcre_compilecxx . . $ oscap_pcre_compile(29ca11f2d36a957a).(file, OSCAP_PCRE_OPTS_UTF8cxx . . $ OSCAP_PCRE_OPTS_UTF8., &errmsg, &erroff); |
| 95 | |
| 96 | if (re == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) { |
| 97 | /* TODO */ |
| 98 | oscap_pcre_err_freecxx . . $ oscap_pcre_err_free(fda57c8427c60377).(errmsg); |
| 99 | return (-1); |
| 100 | } |
| 101 | } |
| 102 | |
| 103 | RPMVERIFY_LOCKcxx . . $ `src/OVAL/probes/unix/linux/rpmverify_probe.c:72:9`!; |
| 104 | |
| 105 | switch (name_op) { |
| 106 | case OVAL_OPERATION_EQUALScxx . . $ OVAL_OPERATION_EQUALS.: |
| 107 | match = rpmtsInitIteratorcxx . . $ rpmtsInitIterator(41c3f6b2f2ef385d).(g_rpm->rpmtscxx . . $ rpm_probe_global#rpmts., RPMTAG_NAMEcxx . . $ RPMTAG_NAME., (const void *)name, 0); |
| 108 | |
| 109 | if (match == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) { |
| 110 | ret = 0; |
| 111 | goto ret; |
| 112 | } |
| 113 | |
| 114 | ret = rpmdbGetIteratorCountcxx . . $ rpmdbGetIteratorCount(41af5f9a5d46e265). (match); |
| 115 | |
| 116 | break; |
| 117 | case OVAL_OPERATION_NOT_EQUALcxx . . $ OVAL_OPERATION_NOT_EQUAL.: |
| 118 | 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); |
| 119 | |
| 120 | if (match == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) { |
| 121 | ret = 0; |
| 122 | goto ret; |
| 123 | } |
| 124 | |
| 125 | if (rpmdbSetIteratorREcxx . . $ rpmdbSetIteratorRE(24a7459ecac1f13c). (match, RPMTAG_NAMEcxx . . $ RPMTAG_NAME., RPMMIRE_GLOBcxx . . $ RPMMIRE_GLOB., "*") != 0) |
| 126 | { |
| 127 | ret = -1; |
| 128 | goto ret; |
| 129 | } |
| 130 | |
| 131 | break; |
| 132 | case OVAL_OPERATION_PATTERN_MATCHcxx . . $ OVAL_OPERATION_PATTERN_MATCH.: |
| 133 | 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); |
| 134 | |
| 135 | if (match == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) { |
| 136 | ret = 0; |
| 137 | goto ret; |
| 138 | } |
| 139 | |
| 140 | if (rpmdbSetIteratorREcxx . . $ rpmdbSetIteratorRE(24a7459ecac1f13c). (match, RPMTAG_NAMEcxx . . $ RPMTAG_NAME., RPMMIRE_REGEXcxx . . $ RPMMIRE_REGEX., |
| 141 | (const char *)name) != 0) |
| 142 | { |
| 143 | ret = -1; |
| 144 | goto ret; |
| 145 | } |
| 146 | |
| 147 | break; |
| 148 | default: |
| 149 | /* not supported */ |
| 150 | dEcxx . . $ `src/common/debug_priv.h:63:9`!("package name: operation not supported"); |
| 151 | ret = -1; |
| 152 | goto ret; |
| 153 | } |
| 154 | |
| 155 | if (RPMTAG_BASENAMEScxx . . $ RPMTAG_BASENAMES. == 0 || RPMTAG_DIRNAMEScxx . . $ RPMTAG_DIRNAMES. == 0) { |
| 156 | return -1; |
| 157 | } |
| 158 | |
| 159 | while ((pkgh = rpmdbNextIteratorcxx . . $ rpmdbNextIterator(12a0bfe3c2421784). (match)) != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) { |
| 160 | rpmficxx . . $ rpmfi# fi; |
| 161 | rpmTagcxx . . $ rpmTag# tag[2] = { RPMTAG_BASENAMEScxx . . $ RPMTAG_BASENAMES., RPMTAG_DIRNAMEScxx . . $ RPMTAG_DIRNAMES. }; |
| 162 | struct rpmverify_rescxx . . $ rpmverify_res# res; |
| 163 | errmsg_tcxx . . $ errmsg_t# rpmerr; |
| 164 | int i; |
| 165 | SEXP_tcxx . . $ SEXP_t# *name_sexp; |
| 166 | |
| 167 | res.namecxx . . $ rpmverify_res#name. = headerFormatcxx . . $ headerFormat(ff7bd715129ef29).(pkgh, "%{NAME}", &rpmerr); |
| 168 | |
| 169 | name_sexp = SEXP_string_newfcxx . . $ SEXP_string_newf(b2137ed863725962).("%s", res.namecxx . . $ rpmverify_res#name.); |
| 170 | if (probe_entobj_cmpcxx . . $ probe_entobj_cmp(e245451a1311e799).(name_ent, name_sexp) != OVAL_RESULT_TRUEcxx . . $ OVAL_RESULT_TRUE.) { |
| 171 | SEXP_freecxx . . $ SEXP_free(c6b28547479798f4).(name_sexp); |
| 172 | continue; |
| 173 | } |
| 174 | SEXP_freecxx . . $ SEXP_free(c6b28547479798f4).(name_sexp); |
| 175 | |
| 176 | /* |
| 177 | * Inspect package files & directories |
| 178 | */ |
| 179 | for (i = 0; i < 2; ++i) { |
| 180 | fi = rpmfiNewcxx . . $ rpmfiNew(765de6e9cbcb5527).(g_rpm->rpmtscxx . . $ rpm_probe_global#rpmts., pkgh, tag[i], 1); |
| 181 | |
| 182 | while (rpmfiNextcxx . . $ rpmfiNext(b7df0ed902649c2e).(fi) != -1) { |
| 183 | SEXP_tcxx . . $ SEXP_t# *filepath_sexp; |
| 184 | |
| 185 | res.fflagscxx . . $ rpmverify_res#fflags. = rpmfiFFlagscxx . . $ rpmfiFFlags(c56bffef931de6c8).(fi); |
| 186 | res.oflagscxx . . $ rpmverify_res#oflags. = omit; |
| 187 | |
| 188 | if (((res.fflagscxx . . $ rpmverify_res#fflags. & RPMFILE_CONFIGcxx . . $ RPMFILE_CONFIG.) && (flags & RPMVERIFY_SKIP_CONFIGcxx . . $ `src/OVAL/probes/unix/linux/rpmverify_probe.c:68:9`!)) || |
| 189 | ((res.fflagscxx . . $ rpmverify_res#fflags. & RPMFILE_GHOSTcxx . . $ RPMFILE_GHOST.) && (flags & RPMVERIFY_SKIP_GHOSTcxx . . $ `src/OVAL/probes/unix/linux/rpmverify_probe.c:69:9`!))) |
| 190 | continue; |
| 191 | |
| 192 | res.filecxx . . $ rpmverify_res#file. = strdupcxx . . $ strdup(a8b8e32347182212).(rpmfiFNcxx . . $ rpmfiFN(24fadc50c126301f).(fi)); |
| 193 | |
| 194 | filepath_sexp = SEXP_string_newfcxx . . $ SEXP_string_newf(b2137ed863725962).("%s", res.filecxx . . $ rpmverify_res#file.); |
| 195 | if (probe_entobj_cmpcxx . . $ probe_entobj_cmp(e245451a1311e799).(filepath_ent, filepath_sexp) != OVAL_RESULT_TRUEcxx . . $ OVAL_RESULT_TRUE.) { |
| 196 | SEXP_freecxx . . $ SEXP_free(c6b28547479798f4).(filepath_sexp); |
| 197 | freecxx . . $ free(5d22bdacc48458e8).(res.filecxx . . $ rpmverify_res#file.); |
| 198 | continue; |
| 199 | } |
| 200 | SEXP_freecxx . . $ SEXP_free(c6b28547479798f4).(filepath_sexp); |
| 201 | |
| 202 | if (rpmVerifyFilecxx . . $ rpmVerifyFile(3d59f9e68d5ecc36).(g_rpm->rpmtscxx . . $ rpm_probe_global#rpmts., fi, &res.vflagscxx . . $ rpmverify_res#vflags., omit) != 0) |
| 203 | res.vflagscxx . . $ rpmverify_res#vflags. = RPMVERIFY_FAILUREScxx . . $ `<external>/1632812796624396431/rpmfiles.h:97:9`!; |
| 204 | |
| 205 | callback(ctx, &res); |
| 206 | freecxx . . $ free(5d22bdacc48458e8).(res.filecxx . . $ rpmverify_res#file.); |
| 207 | } |
| 208 | |
| 209 | rpmfiFreecxx . . $ rpmfiFree(cff0d0dd50e20ae4).(fi); |
| 210 | } |
| 211 | } |
| 212 | |
| 213 | match = rpmdbFreeIteratorcxx . . $ rpmdbFreeIterator(8defa6d083da6e8). (match); |
| 214 | ret = 0; |
| 215 | ret: |
| 216 | if (re != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) |
| 217 | oscap_pcre_freecxx . . $ oscap_pcre_free(804bb72472b0846e).(re); |
| 218 | |
| 219 | RPMVERIFY_UNLOCKcxx . . $ `src/OVAL/probes/unix/linux/rpmverify_probe.c:73:9`!; |
| 220 | return (ret); |
| 221 | } |
| 222 | |
| 223 | int rpmverify_probe_offline_mode_supportedcxx . . $ rpmverify_probe_offline_mode_supported(b126dc7c1de90089).() |
| 224 | { |
| 225 | // TODO: Switch this to OFFLINE_MODE_OWN once rpmtsSetRootDir is fully supported by librpm |
| 226 | return PROBE_OFFLINE_CHROOTcxx . . $ PROBE_OFFLINE_CHROOT.; |
| 227 | } |
| 228 | |
| 229 | void *rpmverify_probe_initcxx . . $ rpmverify_probe_init(50c7df7de5344ebb).(void) |
| 230 | { |
| 231 | #ifdef RPM46_FOUNDcxx . . $ `build/config.h:46:9`! |
| 232 | rpmlogSetCallbackcxx . . $ rpmlogSetCallback(3af8381b9d28b514).(rpmErrorCbcxx . . $ rpmErrorCb(fff58a40e215938)., NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!); |
| 233 | #endif |
| 234 | 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) { |
| 235 | 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`!)); |
| 236 | return (NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!); |
| 237 | } |
| 238 | |
| 239 | set_rpm_db_pathcxx . . $ set_rpm_db_path(49f6e7a06ebc5aa8).(); |
| 240 | |
| 241 | struct rpm_probe_globalcxx . . $ rpm_probe_global# *g_rpm = malloccxx . . $ malloc(bfcfa4d6b7f7ef64).(sizeof(struct rpm_probe_globalcxx . . $ rpm_probe_global#)); |
| 242 | g_rpm->rpmtscxx . . $ rpm_probe_global#rpmts. = rpmtsCreatecxx . . $ rpmtsCreate(17624c196b75261f).(); |
| 243 | |
| 244 | 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`!); |
| 245 | return ((void *)g_rpm); |
| 246 | } |
| 247 | |
| 248 | void rpmverify_probe_finicxx . . $ rpmverify_probe_fini(5d22bdacc48458e8).(void *ptr) |
| 249 | { |
| 250 | struct rpm_probe_globalcxx . . $ rpm_probe_global# *r = (struct rpm_probe_globalcxx . . $ rpm_probe_global# *)ptr; |
| 251 | |
| 252 | rpmFreeCryptocxx . . $ rpmFreeCrypto(b126dc7c1de90089).(); |
| 253 | rpmFreeRpmrccxx . . $ rpmFreeRpmrc(49f6e7a06ebc5aa8).(); |
| 254 | rpmFreeMacroscxx . . $ rpmFreeMacros(9f41120681ff0556).(NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!); |
| 255 | rpmlogClosecxx . . $ rpmlogClose(49f6e7a06ebc5aa8).(); |
| 256 | |
| 257 | // If probe_init() failed r->rpmts and r->mutex were not initialized |
| 258 | if (r == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) |
| 259 | return; |
| 260 | |
| 261 | rpmtsFreecxx . . $ rpmtsFree(39c31376fa367c52).(r->rpmtscxx . . $ rpm_probe_global#rpmts.); |
| 262 | pthread_mutex_destroycxx . . $ pthread_mutex_destroy(d89ae235521888f9). (&(r->mutexcxx . . $ rpm_probe_global#mutex.)); |
| 263 | freecxx . . $ free(5d22bdacc48458e8).(r); |
| 264 | |
| 265 | return; |
| 266 | } |
| 267 | |
| 268 | static void rpmverify_additemcxx . . $ rpmverify_additem(c12d6aa141cc97c8).(probe_ctxcxx . . $ probe_ctx# *ctx, struct rpmverify_rescxx . . $ rpmverify_res# *res) |
| 269 | { |
| 270 | SEXP_tcxx . . $ SEXP_t# *item; |
| 271 | |
| 272 | #define VF_RESULTcxx . . $ `src/OVAL/probes/unix/linux/rpmverify_probe.c:272:9`!(f) (res->oflags & (f) ? "not performed" : (res->vflags & RPMVERIFY_FAILUREScxx . . $ `<external>/1632812796624396431/rpmfiles.h:97:9`! ? "not performed" : (res->vflags & (f) ? "fail" : "pass"))) |
| 273 | #define FF_RESULTcxx . . $ `src/OVAL/probes/unix/linux/rpmverify_probe.c:273:9`!(f) (res->fflags & (f) ? truecxx . . $ `<external>/14268322491693841775/stdbool.h:37:9`! : falsecxx . . $ `<external>/14268322491693841775/stdbool.h:38:9`!) |
| 274 | |
| 275 | item = probe_item_createcxx . . $ probe_item_create(36b16a6622050a9c).(OVAL_LINUX_RPMVERIFYcxx . . $ OVAL_LINUX_RPMVERIFY., NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!, |
| 276 | "name", OVAL_DATATYPE_STRINGcxx . . $ OVAL_DATATYPE_STRING., res->namecxx . . $ rpmverify_res#name., |
| 277 | "filepath", OVAL_DATATYPE_STRINGcxx . . $ OVAL_DATATYPE_STRING., res->filecxx . . $ rpmverify_res#file., |
| 278 | "size_differs", OVAL_DATATYPE_STRINGcxx . . $ OVAL_DATATYPE_STRING., VF_RESULTcxx . . $ `src/OVAL/probes/unix/linux/rpmverify_probe.c:272:9`!(RPMVERIFY_FILESIZE), |
| 279 | "mode_differs", OVAL_DATATYPE_STRINGcxx . . $ OVAL_DATATYPE_STRING., VF_RESULTcxx . . $ `src/OVAL/probes/unix/linux/rpmverify_probe.c:272:9`!(RPMVERIFY_MODE), |
| 280 | "md5_differs", OVAL_DATATYPE_STRINGcxx . . $ OVAL_DATATYPE_STRING., VF_RESULTcxx . . $ `src/OVAL/probes/unix/linux/rpmverify_probe.c:272:9`!(RPMVERIFY_MD5), |
| 281 | "device_differs", OVAL_DATATYPE_STRINGcxx . . $ OVAL_DATATYPE_STRING., VF_RESULTcxx . . $ `src/OVAL/probes/unix/linux/rpmverify_probe.c:272:9`!(RPMVERIFY_RDEV), |
| 282 | "link_mismatch", OVAL_DATATYPE_STRINGcxx . . $ OVAL_DATATYPE_STRING., VF_RESULTcxx . . $ `src/OVAL/probes/unix/linux/rpmverify_probe.c:272:9`!(RPMVERIFY_LINKTO), |
| 283 | "ownership_differs", OVAL_DATATYPE_STRINGcxx . . $ OVAL_DATATYPE_STRING., VF_RESULTcxx . . $ `src/OVAL/probes/unix/linux/rpmverify_probe.c:272:9`!(RPMVERIFY_USER), |
| 284 | "group_differs", OVAL_DATATYPE_STRINGcxx . . $ OVAL_DATATYPE_STRING., VF_RESULTcxx . . $ `src/OVAL/probes/unix/linux/rpmverify_probe.c:272:9`!(RPMVERIFY_GROUP), |
| 285 | "mtime_differs", OVAL_DATATYPE_STRINGcxx . . $ OVAL_DATATYPE_STRING., VF_RESULTcxx . . $ `src/OVAL/probes/unix/linux/rpmverify_probe.c:272:9`!(RPMVERIFY_MTIME), |
| 286 | #ifndef HAVE_LIBRPM44 |
| 287 | "capabilities_differ", OVAL_DATATYPE_STRINGcxx . . $ OVAL_DATATYPE_STRING., VF_RESULTcxx . . $ `src/OVAL/probes/unix/linux/rpmverify_probe.c:272:9`!(RPMVERIFY_CAPS), |
| 288 | #endif |
| 289 | "configuration_file", OVAL_DATATYPE_BOOLEANcxx . . $ OVAL_DATATYPE_BOOLEAN., FF_RESULTcxx . . $ `src/OVAL/probes/unix/linux/rpmverify_probe.c:273:9`!(RPMFILE_CONFIG), |
| 290 | "documentation_file", OVAL_DATATYPE_BOOLEANcxx . . $ OVAL_DATATYPE_BOOLEAN., FF_RESULTcxx . . $ `src/OVAL/probes/unix/linux/rpmverify_probe.c:273:9`!(RPMFILE_DOC), |
| 291 | "ghost_file", OVAL_DATATYPE_BOOLEANcxx . . $ OVAL_DATATYPE_BOOLEAN., FF_RESULTcxx . . $ `src/OVAL/probes/unix/linux/rpmverify_probe.c:273:9`!(RPMFILE_GHOST), |
| 292 | "license_file", OVAL_DATATYPE_BOOLEANcxx . . $ OVAL_DATATYPE_BOOLEAN., FF_RESULTcxx . . $ `src/OVAL/probes/unix/linux/rpmverify_probe.c:273:9`!(RPMFILE_LICENSE), |
| 293 | "readme_file", OVAL_DATATYPE_BOOLEANcxx . . $ OVAL_DATATYPE_BOOLEAN., FF_RESULTcxx . . $ `src/OVAL/probes/unix/linux/rpmverify_probe.c:273:9`!(RPMFILE_README), |
| 294 | NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!); |
| 295 | |
| 296 | probe_item_collectcxx . . $ probe_item_collect(11bb80e0c30650d7).(ctx, item); |
| 297 | } |
| 298 | |
| 299 | typedef structcxx . . $ $anonymous_type_e9b10a0f920280a3_0# { |
| 300 | const char *a_namecxx . . $ $anonymous_type_e9b10a0f920280a3_0#a_name.; |
| 301 | uint64_tcxx . . $ uint64_t# a_flagcxx . . $ $anonymous_type_e9b10a0f920280a3_0#a_flag.; |
| 302 | } rpmverify_bhmap_tcxx . . $ rpmverify_bhmap_t#; |
| 303 | |
| 304 | const rpmverify_bhmap_tcxx . . $ rpmverify_bhmap_t# rpmverify_bhmapcxx . . $ rpmverify_bhmap.[] = { |
| 305 | { "nolinkto", (uint64_tcxx . . $ uint64_t#)RPMVERIFY_LINKTOcxx . . $ RPMVERIFY_LINKTO. }, |
| 306 | { "nomd5", (uint64_tcxx . . $ uint64_t#)RPMVERIFY_MD5cxx . . $ RPMVERIFY_MD5. }, |
| 307 | { "nosize", (uint64_tcxx . . $ uint64_t#)RPMVERIFY_FILESIZEcxx . . $ RPMVERIFY_FILESIZE. }, |
| 308 | { "nouser", (uint64_tcxx . . $ uint64_t#)RPMVERIFY_USERcxx . . $ RPMVERIFY_USER. }, |
| 309 | { "nogroup", (uint64_tcxx . . $ uint64_t#)RPMVERIFY_GROUPcxx . . $ RPMVERIFY_GROUP. }, |
| 310 | { "nomtime", (uint64_tcxx . . $ uint64_t#)RPMVERIFY_MTIMEcxx . . $ RPMVERIFY_MTIME. }, |
| 311 | { "nomode", (uint64_tcxx . . $ uint64_t#)RPMVERIFY_MODEcxx . . $ RPMVERIFY_MODE. }, |
| 312 | { "nordev", (uint64_tcxx . . $ uint64_t#)RPMVERIFY_RDEVcxx . . $ RPMVERIFY_RDEV. }, |
| 313 | { "noconfigfiles", RPMVERIFY_SKIP_CONFIGcxx . . $ `src/OVAL/probes/unix/linux/rpmverify_probe.c:68:9`! }, |
| 314 | { "noghostfiles", RPMVERIFY_SKIP_GHOSTcxx . . $ `src/OVAL/probes/unix/linux/rpmverify_probe.c:69:9`! } |
| 315 | }; |
| 316 | |
| 317 | int rpmverify_probe_maincxx . . $ rpmverify_probe_main(470536d3ffacaf10).(probe_ctxcxx . . $ probe_ctx# *ctx, void *arg) |
| 318 | { |
| 319 | SEXP_tcxx . . $ SEXP_t# *probe_in, *name_ent, *file_ent, *bh_ent; |
| 320 | char file[PATH_MAXcxx . . $ `<external>/6347054901304145714/limits.h:13:9`!]; |
| 321 | size_t file_len = sizeof file; |
| 322 | char name[64]; |
| 323 | size_t name_len = sizeof name; |
| 324 | oval_operation_tcxx . . $ oval_operation_t# name_op, file_op; |
| 325 | uint64_tcxx . . $ uint64_t# collect_flags = 0; |
| 326 | unsigned int i; |
| 327 | |
| 328 | // If probe_init() failed it's because there was no rpm config files |
| 329 | if (arg == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) { |
| 330 | 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.); |
| 331 | return 0; |
| 332 | } |
| 333 | struct rpm_probe_globalcxx . . $ rpm_probe_global# *g_rpm = (struct rpm_probe_globalcxx . . $ rpm_probe_global# *)arg; |
| 334 | |
| 335 | if (ctx->offline_modecxx . . $ probe_ctx#offline_mode. & PROBE_OFFLINE_OWNcxx . . $ PROBE_OFFLINE_OWN.) { |
| 336 | const char* root = getenvcxx . . $ getenv(a8b8e32347182212).("OSCAP_PROBE_ROOT"); |
| 337 | rpmtsSetRootDircxx . . $ rpmtsSetRootDir(23a209d8fccc3ea8).(g_rpm->rpmtscxx . . $ rpm_probe_global#rpmts., root); |
| 338 | } |
| 339 | |
| 340 | /* |
| 341 | * Get refs to object entities |
| 342 | */ |
| 343 | probe_in = probe_ctx_getobjectcxx . . $ probe_ctx_getobject(4299b6b53fa804a5).(ctx); |
| 344 | name_ent = probe_obj_getentcxx . . $ probe_obj_getent(7907a01f2ff841f3).(probe_in, "name", 1); |
| 345 | file_ent = probe_obj_getentcxx . . $ probe_obj_getent(7907a01f2ff841f3).(probe_in, "filepath", 1); |
| 346 | |
| 347 | if (name_ent == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`! || file_ent == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) { |
| 348 | dEcxx . . $ `src/common/debug_priv.h:63:9`!("Missing \"name\" (%p) or \"filepath\" (%p) entity", name_ent, file_ent); |
| 349 | |
| 350 | SEXP_freecxx . . $ SEXP_free(c6b28547479798f4).(name_ent); |
| 351 | SEXP_freecxx . . $ SEXP_free(c6b28547479798f4).(file_ent); |
| 352 | |
| 353 | return (PROBE_ENOENTcxx . . $ `src/OVAL/probes/public/probe-common.h:20:9`!); |
| 354 | } |
| 355 | |
| 356 | /* |
| 357 | * Extract the requested operation for each entity |
| 358 | */ |
| 359 | name_op = probe_ent_getoperationcxx . . $ probe_ent_getoperation(8f085ec993ec77d).(name_ent, OVAL_OPERATION_EQUALScxx . . $ OVAL_OPERATION_EQUALS.); |
| 360 | file_op = probe_ent_getoperationcxx . . $ probe_ent_getoperation(8f085ec993ec77d).(file_ent, OVAL_OPERATION_EQUALScxx . . $ OVAL_OPERATION_EQUALS.); |
| 361 | |
| 362 | if (name_op == OVAL_OPERATION_UNKNOWNcxx . . $ OVAL_OPERATION_UNKNOWN. || |
| 363 | file_op == OVAL_OPERATION_UNKNOWNcxx . . $ OVAL_OPERATION_UNKNOWN.) |
| 364 | { |
| 365 | SEXP_freecxx . . $ SEXP_free(c6b28547479798f4).(name_ent); |
| 366 | SEXP_freecxx . . $ SEXP_free(c6b28547479798f4).(file_ent); |
| 367 | |
| 368 | return (PROBE_EINVALcxx . . $ `src/OVAL/probes/public/probe-common.h:8:9`!); |
| 369 | } |
| 370 | |
| 371 | /* |
| 372 | * Extract entity values |
| 373 | */ |
| 374 | PROBE_ENT_STRVALcxx . . $ `src/OVAL/probes/public/probe-api.h:487:9`!(name_ent, name, name_len, /* void */, strcpy(name, "");); |
| 375 | PROBE_ENT_STRVALcxx . . $ `src/OVAL/probes/public/probe-api.h:487:9`!(file_ent, file, file_len, /* void */, strcpy(file, "");); |
| 376 | |
| 377 | /* |
| 378 | * Parse behaviors |
| 379 | */ |
| 380 | bh_ent = probe_obj_getentcxx . . $ probe_obj_getent(7907a01f2ff841f3).(probe_in, "behaviors", 1); |
| 381 | |
| 382 | if (bh_ent != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) { |
| 383 | SEXP_tcxx . . $ SEXP_t# *aval; |
| 384 | |
| 385 | for (i = 0; i < sizeof rpmverify_bhmapcxx . . $ rpmverify_bhmap./sizeof(rpmverify_bhmap_tcxx . . $ rpmverify_bhmap_t#); ++i) { |
| 386 | aval = probe_ent_getattrvalcxx . . $ probe_ent_getattrval(42b37380d22a3312).(bh_ent, rpmverify_bhmapcxx . . $ rpmverify_bhmap.[i].a_namecxx . . $ $anonymous_type_e9b10a0f920280a3_0#a_name.); |
| 387 | |
| 388 | if (aval != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) { |
| 389 | if (SEXP_strcmpcxx . . $ SEXP_strcmp(3ef1a37bcb3c2a).(aval, "true") == 0) { |
| 390 | dDcxx . . $ `src/common/debug_priv.h:64:9`!("omit verify attr: %s", rpmverify_bhmap[i].a_name); |
| 391 | collect_flags |= rpmverify_bhmapcxx . . $ rpmverify_bhmap.[i].a_flagcxx . . $ $anonymous_type_e9b10a0f920280a3_0#a_flag.; |
| 392 | } |
| 393 | |
| 394 | SEXP_freecxx . . $ SEXP_free(c6b28547479798f4).(aval); |
| 395 | } |
| 396 | } |
| 397 | |
| 398 | SEXP_freecxx . . $ SEXP_free(c6b28547479798f4).(bh_ent); |
| 399 | } |
| 400 | |
| 401 | dIcxx . . $ `src/common/debug_priv.h:61:9`!("Collecting rpmverify data, query: n=\"%s\" (%d), f=\"%s\" (%d)", |
| 402 | name, name_op, file, file_op); |
| 403 | |
| 404 | if (rpmverify_collectcxx . . $ rpmverify_collect(c80ac3e3d5df773f).(ctx, |
| 405 | name, name_op, |
| 406 | file, file_op, |
| 407 | name_ent, file_ent, |
| 408 | collect_flags, |
| 409 | rpmverify_additemcxx . . $ rpmverify_additem(c12d6aa141cc97c8)., g_rpm) != 0) |
| 410 | { |
| 411 | dEcxx . . $ `src/common/debug_priv.h:63:9`!("An error ocured while collecting rpmverify data"); |
| 412 | probe_cobj_set_flagcxx . . $ probe_cobj_set_flag(644bab5dffe689c).(probe_ctx_getresultcxx . . $ probe_ctx_getresult(4299b6b53fa804a5).(ctx), SYSCHAR_FLAG_ERRORcxx . . $ SYSCHAR_FLAG_ERROR.); |
| 413 | } |
| 414 | |
| 415 | SEXP_freecxx . . $ SEXP_free(c6b28547479798f4).(name_ent); |
| 416 | SEXP_freecxx . . $ SEXP_free(c6b28547479798f4).(file_ent); |
| 417 | |
| 418 | return 0; |
| 419 | } |