| 1 | /* |
| 2 | * Copyright 2010-2011 Red Hat Inc., Durham, North Carolina. |
| 3 | * All Rights Reserved. |
| 4 | * |
| 5 | * This library is free software; you can redistribute it and/or |
| 6 | * modify it under the terms of the GNU Lesser General Public |
| 7 | * License as published by the Free Software Foundation; either |
| 8 | * version 2.1 of the License, or (at your option) any later version. |
| 9 | * |
| 10 | * This library is distributed in the hope that it will be useful, |
| 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 13 | * Lesser General Public License for more details. |
| 14 | * |
| 15 | * You should have received a copy of the GNU Lesser General Public |
| 16 | * License along with this library; if not, write to the Free Software |
| 17 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA |
| 18 | * |
| 19 | * Authors: |
| 20 | * "Daniel Kopecek" <[email protected]> |
| 21 | * "Tomas Heinrich" <[email protected]> |
| 22 | */ |
| 23 | |
| 24 | #ifdef HAVE_CONFIG_Hcxx . . $ `<built-in>:409:9`! |
| 25 | #include <config.h>cxx . . $ `<file>/build/config.h`/ |
| 26 | #endif |
| 27 | |
| 28 | #include <stdint.h> |
| 29 | #include <stdbool.h> |
| 30 | #include <string.h> |
| 31 | #include <sys/types.h> |
| 32 | #include <sys/stat.h> |
| 33 | #include <limits.h> |
| 34 | #include <errno.h> |
| 35 | |
| 36 | #include "oscap_helpers.h"cxx . . $ `<file>/src/common/public/oscap_helpers.h`/ |
| 37 | #include "fsdev.h"cxx . . $ `<file>/src/OVAL/probes/fsdev.h`/ |
| 38 | #include "_probe-api.h"cxx . . $ `<file>/src/OVAL/probes/_probe-api.h`/ |
| 39 | #include "probe/entcmp.h"cxx . . $ `<file>/src/OVAL/probes/probe/entcmp.h`/ |
| 40 | #include "debug_priv.h"cxx . . $ `<file>/src/common/debug_priv.h`/ |
| 41 | #include "oval_fts.h"cxx . . $ `<file>/src/OVAL/probes/oval_fts.h`/ |
| 42 | #if defined(OS_SOLARIS) |
| 43 | #include "fts_sun.h" |
| 44 | #include <sys/mntent.h> |
| 45 | #include <libzonecfg.h> |
| 46 | #include <sys/avl.h> |
| 47 | #elif defined(OS_AIX) |
| 48 | #include "fts_sun.h" |
| 49 | #else |
| 50 | #include <fts.h> |
| 51 | #endif |
| 52 | |
| 53 | #undef OSCAP_FTS_DEBUG |
| 54 | |
| 55 | static OVAL_FTScxx . . $ OVAL_FTS# *OVAL_FTS_newcxx . . $ OVAL_FTS_new(18ecb4464872cead).() |
| 56 | { |
| 57 | OVAL_FTScxx . . $ OVAL_FTS# *ofts = calloccxx . . $ calloc(63a7bf2941bfcd7a).(1, sizeof(OVAL_FTScxx . . $ OVAL_FTS#)); |
| 58 | |
| 59 | ofts->max_depthcxx . . $ $anonymous_type_ebdee0feb58b991e_0#max_depth. = -1; |
| 60 | ofts->directioncxx . . $ $anonymous_type_ebdee0feb58b991e_0#direction. = -1; |
| 61 | ofts->filesystemcxx . . $ $anonymous_type_ebdee0feb58b991e_0#filesystem. = -1; |
| 62 | |
| 63 | return (ofts); |
| 64 | } |
| 65 | |
| 66 | static void OVAL_FTS_freecxx . . $ OVAL_FTS_free(f2ac88db1829285e).(OVAL_FTScxx . . $ OVAL_FTS# *ofts) |
| 67 | { |
| 68 | if (ofts->ofts_match_path_ftscxx . . $ $anonymous_type_ebdee0feb58b991e_0#ofts_match_path_fts. != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) |
| 69 | fts_closecxx . . $ fts_close(465f0e4c9e45e83).(ofts->ofts_match_path_ftscxx . . $ $anonymous_type_ebdee0feb58b991e_0#ofts_match_path_fts.); |
| 70 | if (ofts->ofts_recurse_path_ftscxx . . $ $anonymous_type_ebdee0feb58b991e_0#ofts_recurse_path_fts. != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) |
| 71 | fts_closecxx . . $ fts_close(465f0e4c9e45e83).(ofts->ofts_recurse_path_ftscxx . . $ $anonymous_type_ebdee0feb58b991e_0#ofts_recurse_path_fts.); |
| 72 | |
| 73 | freecxx . . $ free(5d22bdacc48458e8).(ofts); |
| 74 | return; |
| 75 | } |
| 76 | |
| 77 | static int pathlen_from_ftsecxx . . $ pathlen_from_ftse(9b79fb6aee4c0440).(int fts_pathlen, int fts_namelen) |
| 78 | { |
| 79 | int pathlen; |
| 80 | |
| 81 | if (fts_pathlen > fts_namelen) { |
| 82 | pathlen = fts_pathlen - fts_namelen; |
| 83 | if (pathlen > 1) |
| 84 | pathlen--; /* strip last slash */ |
| 85 | } else { |
| 86 | pathlen = fts_pathlen; |
| 87 | } |
| 88 | |
| 89 | return pathlen; |
| 90 | } |
| 91 | |
| 92 | static OVAL_FTSENTcxx . . $ OVAL_FTSENT# *OVAL_FTSENT_newcxx . . $ OVAL_FTSENT_new(468998e9444d7313).(OVAL_FTScxx . . $ OVAL_FTS# *ofts, FTSENTcxx . . $ FTSENT# *fts_ent) |
| 93 | { |
| 94 | OVAL_FTSENTcxx . . $ OVAL_FTSENT# *ofts_ent = calloccxx . . $ calloc(63a7bf2941bfcd7a).(1, sizeof(OVAL_FTSENTcxx . . $ OVAL_FTSENT#)); |
| 95 | |
| 96 | ofts_ent->fts_infocxx . . $ $anonymous_type_ebdee0feb58b991e_1#fts_info. = fts_ent->fts_infocxx . . $ _ftsent#fts_info.; |
| 97 | /* The 'shift' variable stores length of the prefix if the prefix |
| 98 | * is defined, otherwise it is set to 0. The value of 'shift' gives |
| 99 | * us information how many characters of the path string are part of |
| 100 | * the prefix and also where the actual path begins. |
| 101 | * We use it to remove the prefix from the path. |
| 102 | */ |
| 103 | const size_t shift = ofts->prefixcxx . . $ $anonymous_type_ebdee0feb58b991e_0#prefix. ? strlencxx . . $ strlen(751346f8406fd082).(ofts->prefixcxx . . $ $anonymous_type_ebdee0feb58b991e_0#prefix.) : 0; |
| 104 | if (ofts->ofts_sfilenamecxx . . $ $anonymous_type_ebdee0feb58b991e_0#ofts_sfilename. || ofts->ofts_sfilepathcxx . . $ $anonymous_type_ebdee0feb58b991e_0#ofts_sfilepath.) { |
| 105 | ofts_ent->path_lencxx . . $ $anonymous_type_ebdee0feb58b991e_1#path_len. = pathlen_from_ftsecxx . . $ pathlen_from_ftse(9b79fb6aee4c0440).(fts_ent->fts_pathlencxx . . $ _ftsent#fts_pathlen., fts_ent->fts_namelencxx . . $ _ftsent#fts_namelen.) - shift; |
| 106 | if (ofts_ent->path_lencxx . . $ $anonymous_type_ebdee0feb58b991e_1#path_len. > 0) { |
| 107 | ofts_ent->pathcxx . . $ $anonymous_type_ebdee0feb58b991e_1#path. = malloccxx . . $ malloc(bfcfa4d6b7f7ef64).(ofts_ent->path_lencxx . . $ $anonymous_type_ebdee0feb58b991e_1#path_len. + 1); |
| 108 | strncpycxx . . $ strncpy(255158a415b673b0).(ofts_ent->pathcxx . . $ $anonymous_type_ebdee0feb58b991e_1#path., fts_ent->fts_pathcxx . . $ _ftsent#fts_path. + shift, ofts_ent->path_lencxx . . $ $anonymous_type_ebdee0feb58b991e_1#path_len.); |
| 109 | ofts_ent->pathcxx . . $ $anonymous_type_ebdee0feb58b991e_1#path.[ofts_ent->path_lencxx . . $ $anonymous_type_ebdee0feb58b991e_1#path_len.] = '\0'; |
| 110 | } else { |
| 111 | ofts_ent->path_lencxx . . $ $anonymous_type_ebdee0feb58b991e_1#path_len. = 1; |
| 112 | ofts_ent->pathcxx . . $ $anonymous_type_ebdee0feb58b991e_1#path. = strdupcxx . . $ strdup(a8b8e32347182212).("/"); |
| 113 | } |
| 114 | |
| 115 | ofts_ent->file_lencxx . . $ $anonymous_type_ebdee0feb58b991e_1#file_len. = fts_ent->fts_namelencxx . . $ _ftsent#fts_namelen.; |
| 116 | ofts_ent->filecxx . . $ $anonymous_type_ebdee0feb58b991e_1#file. = strdupcxx . . $ strdup(a8b8e32347182212).(fts_ent->fts_namecxx . . $ _ftsent#fts_name.); |
| 117 | } else { |
| 118 | ofts_ent->path_lencxx . . $ $anonymous_type_ebdee0feb58b991e_1#path_len. = fts_ent->fts_pathlencxx . . $ _ftsent#fts_pathlen. - shift; |
| 119 | if (ofts_ent->path_lencxx . . $ $anonymous_type_ebdee0feb58b991e_1#path_len. > 0) { |
| 120 | ofts_ent->pathcxx . . $ $anonymous_type_ebdee0feb58b991e_1#path. = strdupcxx . . $ strdup(a8b8e32347182212).(fts_ent->fts_pathcxx . . $ _ftsent#fts_path. + shift); |
| 121 | } else { |
| 122 | ofts_ent->path_lencxx . . $ $anonymous_type_ebdee0feb58b991e_1#path_len. = 1; |
| 123 | ofts_ent->pathcxx . . $ $anonymous_type_ebdee0feb58b991e_1#path. = strdupcxx . . $ strdup(a8b8e32347182212).("/"); |
| 124 | } |
| 125 | |
| 126 | ofts_ent->file_lencxx . . $ $anonymous_type_ebdee0feb58b991e_1#file_len. = -1; |
| 127 | ofts_ent->filecxx . . $ $anonymous_type_ebdee0feb58b991e_1#file. = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!; |
| 128 | } |
| 129 | |
| 130 | #if defined(OSCAP_FTS_DEBUG) |
| 131 | dD("New OVAL_FTSENT: file: '%s', path: '%s'.", ofts_ent->file, ofts_ent->path); |
| 132 | #endif |
| 133 | return (ofts_ent); |
| 134 | } |
| 135 | |
| 136 | static void OVAL_FTSENT_freecxx . . $ OVAL_FTSENT_free(7e09326da17d8ab0).(OVAL_FTSENTcxx . . $ OVAL_FTSENT# *ofts_ent) |
| 137 | { |
| 138 | freecxx . . $ free(5d22bdacc48458e8).(ofts_ent->pathcxx . . $ $anonymous_type_ebdee0feb58b991e_1#path.); |
| 139 | freecxx . . $ free(5d22bdacc48458e8).(ofts_ent->filecxx . . $ $anonymous_type_ebdee0feb58b991e_1#file.); |
| 140 | freecxx . . $ free(5d22bdacc48458e8).(ofts_ent); |
| 141 | return; |
| 142 | } |
| 143 | |
| 144 | #if defined(OS_SOLARIS) |
| 145 | #ifndef MNTTYPE_SMB |
| 146 | #define MNTTYPE_SMB "smb" |
| 147 | #endif |
| 148 | #ifndef MNTTYPE_SMBFS |
| 149 | #define MNTTYPE_SMBFS "smbfs" |
| 150 | #endif |
| 151 | #ifndef MNTTYPE_PROC |
| 152 | #define MNTTYPE_PROC "proc" |
| 153 | #endif |
| 154 | |
| 155 | typedef struct zone_path { |
| 156 | avl_node_t avl_link_next; |
| 157 | char zpath[MAXPATHLEN]; |
| 158 | } zone_path_t; |
| 159 | static avl_tree_t avl_tree_list; |
| 160 | |
| 161 | |
| 162 | static bool valid_remote_fs(char *fstype) |
| 163 | { |
| 164 | if (strcmp(fstype, MNTTYPE_NFS) == 0 || |
| 165 | strcmp(fstype, MNTTYPE_SMBFS) == 0 || |
| 166 | strcmp(fstype, MNTTYPE_SMB) == 0) |
| 167 | return (true); |
| 168 | return (false); |
| 169 | } |
| 170 | |
| 171 | static bool valid_local_fs(char *fstype) |
| 172 | { |
| 173 | if (strcmp(fstype, MNTTYPE_SWAP) == 0 || |
| 174 | strcmp(fstype, MNTTYPE_MNTFS) == 0 || |
| 175 | strcmp(fstype, MNTTYPE_CTFS) == 0 || |
| 176 | strcmp(fstype, MNTTYPE_OBJFS) == 0 || |
| 177 | strcmp(fstype, MNTTYPE_SHAREFS) == 0 || |
| 178 | strcmp(fstype, MNTTYPE_PROC) == 0 || |
| 179 | strcmp(fstype, MNTTYPE_LOFS) == 0 || |
| 180 | strcmp(fstype, MNTTYPE_AUTOFS) == 0) |
| 181 | return (false); |
| 182 | return (true); |
| 183 | } |
| 184 | |
| 185 | /* function to compare two avl nodes in the avl tree */ |
| 186 | static int compare_zoneroot(const void *entry1, const void *entry2) |
| 187 | { |
| 188 | zone_path_t *t1, *t2; |
| 189 | int comp; |
| 190 | |
| 191 | t1 = (zone_path_t *)entry1; |
| 192 | t2 = (zone_path_t *)entry2; |
| 193 | if ((comp = strcmp(t1->zpath, t2->zpath)) == 0) { |
| 194 | return (0); |
| 195 | } |
| 196 | return (comp > 0 ? 1 : -1); |
| 197 | } |
| 198 | |
| 199 | int load_zones_path_list() |
| 200 | { |
| 201 | FILE *cookie; |
| 202 | char *name; |
| 203 | zone_state_t state_num; |
| 204 | zone_path_t *temp = NULL; |
| 205 | avl_index_t where; |
| 206 | char rpath[MAXPATHLEN]; |
| 207 | |
| 208 | cookie = setzoneent(); |
| 209 | if (getzoneid() != GLOBAL_ZONEID) |
| 210 | return (0); |
| 211 | avl_create(&avl_tree_list, compare_zoneroot, |
| 212 | sizeof(zone_path_t), offsetof(zone_path_t, avl_link_next)); |
| 213 | while ((name = getzoneent(cookie)) != NULL) { |
| 214 | if (strcmp(name, "global") == 0) |
| 215 | continue; |
| 216 | if (zone_get_state(name, &state_num) != Z_OK) { |
| 217 | dE("Could not get zone state for %s", name); |
| 218 | continue; |
| 219 | } else if (state_num > ZONE_STATE_CONFIGURED) { |
| 220 | temp = malloc(sizeof(zone_path_t)); |
| 221 | if (temp == NULL) { |
| 222 | dE("Memory alloc failed"); |
| 223 | return(1); |
| 224 | } |
| 225 | if (zone_get_zonepath(name, rpath, |
| 226 | sizeof(rpath)) != Z_OK) { |
| 227 | dE("Could not get zone path for %s", |
| 228 | name); |
| 229 | continue; |
| 230 | } |
| 231 | if (oscap_realpath(rpath, temp->zpath) != NULL) |
| 232 | avl_add(&avl_tree_list, temp); |
| 233 | } |
| 234 | } |
| 235 | endzoneent(cookie); |
| 236 | return (0); |
| 237 | } |
| 238 | |
| 239 | static void free_zones_path_list() |
| 240 | { |
| 241 | zone_path_t *temp; |
| 242 | void* cookie = NULL; |
| 243 | |
| 244 | while ((temp = avl_destroy_nodes(&avl_tree_list, &cookie)) != NULL) { |
| 245 | free(temp); |
| 246 | } |
| 247 | avl_destroy(&avl_tree_list); |
| 248 | } |
| 249 | |
| 250 | static bool valid_local_zone(const char *path) |
| 251 | { |
| 252 | zone_path_t temp; |
| 253 | avl_index_t where; |
| 254 | |
| 255 | strlcpy(temp.zpath, path, sizeof(temp.zpath)); |
| 256 | if (avl_find(&avl_tree_list, &temp, &where) != NULL) |
| 257 | return (true); |
| 258 | |
| 259 | return (false); |
| 260 | } |
| 261 | |
| 262 | |
| 263 | #endif |
| 264 | |
| 265 | static boolcxx . . $ `<external>/14268322491693841775/stdbool.h:36:9`! OVAL_FTS_localpcxx . . $ OVAL_FTS_localp(88198641f3bcbed).(OVAL_FTScxx . . $ OVAL_FTS# *ofts, const char *path, void *id) |
| 266 | { |
| 267 | #if defined(OS_SOLARIS) |
| 268 | if (id != NULL && (*(char*)id) != '\0') { |
| 269 | /* if not a valid local fs skip */ |
| 270 | if (valid_local_fs((char*)id)) { |
| 271 | /* if recurse is local , skip remote fs |
| 272 | and non-global zones */ |
| 273 | if (ofts->filesystem == OVAL_RECURSE_FS_LOCAL) { |
| 274 | return (!(valid_remote_fs((char*)id) || |
| 275 | valid_local_zone(path))); |
| 276 | } |
| 277 | return (true); |
| 278 | } |
| 279 | return (false); |
| 280 | } else if (path != NULL) { |
| 281 | /* id was not set, because fts_read failed to stat the node */ |
| 282 | struct stat sb; |
| 283 | if ((stat(path, &sb) == 0) && (valid_local_fs(sb.st_fstype))) { |
| 284 | /* if recurse is local , skip remote fs |
| 285 | and non-global zones */ |
| 286 | if (ofts->filesystem == OVAL_RECURSE_FS_LOCAL) { |
| 287 | return (!(valid_remote_fs(sb.st_fstype) || |
| 288 | valid_local_zone(path))); |
| 289 | } |
| 290 | return (true); |
| 291 | } |
| 292 | return (false); |
| 293 | } else { |
| 294 | return (false); |
| 295 | } |
| 296 | #else |
| 297 | if (id != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) |
| 298 | return (fsdev_searchcxx . . $ fsdev_search(a29fa8ec2853d098).(ofts->localdevscxx . . $ $anonymous_type_ebdee0feb58b991e_0#localdevs., id) == 1 ? truecxx . . $ `<external>/14268322491693841775/stdbool.h:37:9`! : falsecxx . . $ `<external>/14268322491693841775/stdbool.h:38:9`!); |
| 299 | else if (path != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) |
| 300 | return (fsdev_pathcxx . . $ fsdev_path(f173a51f6dfb99a9).(ofts->localdevscxx . . $ $anonymous_type_ebdee0feb58b991e_0#localdevs., path) == 1 ? truecxx . . $ `<external>/14268322491693841775/stdbool.h:37:9`! : falsecxx . . $ `<external>/14268322491693841775/stdbool.h:38:9`!); |
| 301 | else |
| 302 | return (falsecxx . . $ `<external>/14268322491693841775/stdbool.h:38:9`!); |
| 303 | #endif |
| 304 | } |
| 305 | |
| 306 | static char *__regex_locatecxx . . $ __regex_locate(7a9722d75b371431).(char *str) |
| 307 | { |
| 308 | char *regex_sch = "^*?$.(["; /*<< regex start chars */ |
| 309 | boolcxx . . $ `<external>/14268322491693841775/stdbool.h:36:9`! escaped = falsecxx . . $ `<external>/14268322491693841775/stdbool.h:38:9`!; |
| 310 | |
| 311 | while (*str != '\0') { |
| 312 | if (*str == '\\') |
| 313 | escaped = !escaped; |
| 314 | else if (strchrcxx . . $ strchr(2050848944e00d54).(regex_sch, *str) != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) { |
| 315 | if (!escaped) |
| 316 | return (str); |
| 317 | else |
| 318 | escaped = falsecxx . . $ `<external>/14268322491693841775/stdbool.h:38:9`!; |
| 319 | } |
| 320 | ++str; |
| 321 | } |
| 322 | |
| 323 | return (str); |
| 324 | } |
| 325 | |
| 326 | static char *__string_unescapecxx . . $ __string_unescape(dff97f9eb74e1544).(char *str, size_t len) |
| 327 | { |
| 328 | char *ret_str; |
| 329 | size_t i, j; |
| 330 | |
| 331 | if (str == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`! || len == 0) |
| 332 | return NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!; |
| 333 | |
| 334 | ret_str = strndupcxx . . $ strndup(eabdfdef77619b3d).(str, len); |
| 335 | |
| 336 | if (ret_str == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) |
| 337 | return NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!; |
| 338 | |
| 339 | for (i = j = 0; i < len && j <= i; ++i) { |
| 340 | if (str[i] == '\\') { |
| 341 | if (str[i+1] == '\0') { |
| 342 | freecxx . . $ free(5d22bdacc48458e8).(ret_str); |
| 343 | return NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!; |
| 344 | } |
| 345 | ret_str[j] = str[i+1]; |
| 346 | ++j; |
| 347 | ++i; |
| 348 | } else { |
| 349 | ret_str[j] = str[i]; |
| 350 | ++j; |
| 351 | } |
| 352 | } |
| 353 | |
| 354 | ret_str[j] = '\0'; |
| 355 | |
| 356 | return ret_str; |
| 357 | } |
| 358 | |
| 359 | static char *extract_fixed_path_prefixcxx . . $ extract_fixed_path_prefix(7a9722d75b371431).(char *path) |
| 360 | { |
| 361 | char *s; |
| 362 | |
| 363 | if (path[0] == '^') |
| 364 | path++; |
| 365 | |
| 366 | s = __regex_locatecxx . . $ __regex_locate(7a9722d75b371431).(path); |
| 367 | if (*s != '\0') |
| 368 | for (s--; s > (path + 1) && *s != '/'; s--); |
| 369 | if (s > (path + 1)) { |
| 370 | s = __string_unescapecxx . . $ __string_unescape(dff97f9eb74e1544).(path, (size_t) (s - path)); |
| 371 | if (s != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) { |
| 372 | if (s[0] == '/') |
| 373 | return s; |
| 374 | freecxx . . $ free(5d22bdacc48458e8).(s); |
| 375 | } |
| 376 | } |
| 377 | |
| 378 | return strdupcxx . . $ strdup(a8b8e32347182212).("/"); |
| 379 | } |
| 380 | |
| 381 | #define TEST_PATH1cxx . . $ `src/OVAL/probes/oval_fts.c:381:9`! "/" |
| 382 | #define TEST_PATH2cxx . . $ `src/OVAL/probes/oval_fts.c:382:9`! "x" |
| 383 | |
| 384 | /* Verify that the path is usable and try to craft a regex to speed up |
| 385 | the filesystem traversal. If the path to match is ill-designed, an |
| 386 | ugly heuristic is employed to obtain something meaningfull. */ |
| 387 | static int process_pattern_matchcxx . . $ process_pattern_match(c4e09908c59384c8).(const char *path, oscap_pcre_tcxx . . $ oscap_pcre_t# **regex_out) |
| 388 | { |
| 389 | int ret, errofs = 0; |
| 390 | char *pattern; |
| 391 | const char *test_path1 = TEST_PATH1cxx . . $ `src/OVAL/probes/oval_fts.c:381:9`!; |
| 392 | //const char *test_path2 = TEST_PATH2; |
| 393 | char *errptr = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!; |
| 394 | oscap_pcre_tcxx . . $ oscap_pcre_t# *regex; |
| 395 | |
| 396 | if (path[0] != '^') { |
| 397 | /* Matching has to have a fixed starting point and thus |
| 398 | every pattern has to start with a caret. */ |
| 399 | size_t plen; |
| 400 | |
| 401 | plen = strlencxx . . $ strlen(751346f8406fd082).(path) + 1; |
| 402 | pattern = malloccxx . . $ malloc(bfcfa4d6b7f7ef64).(plen + 1); |
| 403 | pattern[0] = '^'; |
| 404 | memcpycxx . . $ memcpy(cc817cb175f282d).(pattern + 1, path, plen); |
| 405 | dIcxx . . $ `src/common/debug_priv.h:61:9`!("The pattern '%s' doesn't contain a leading caret - added. " |
| 406 | "All paths with the 'pattern match' operation must begin " |
| 407 | "with a caret.", path); |
| 408 | } else { |
| 409 | pattern = strdupcxx . . $ strdup(a8b8e32347182212).(path); |
| 410 | } |
| 411 | |
| 412 | regex = oscap_pcre_compilecxx . . $ oscap_pcre_compile(29ca11f2d36a957a).(pattern, 0, &errptr, &errofs); |
| 413 | if (regex == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) { |
| 414 | dEcxx . . $ `src/common/debug_priv.h:63:9`!("Failed to validate the pattern: oscap_pcre_compile(): " |
| 415 | "error offset: %d, error: '%s', pattern: '%s'.\n", |
| 416 | errofs, errptr, pattern); |
| 417 | freecxx . . $ free(5d22bdacc48458e8).(pattern); |
| 418 | oscap_pcre_err_freecxx . . $ oscap_pcre_err_free(fda57c8427c60377).(errptr); |
| 419 | return -1; |
| 420 | } |
| 421 | ret = oscap_pcre_execcxx . . $ oscap_pcre_exec(7630dfd25fd504ec).(regex, test_path1, strlencxx . . $ strlen(751346f8406fd082).(test_path1), 0, |
| 422 | OSCAP_PCRE_OPTS_PARTIALcxx . . $ OSCAP_PCRE_OPTS_PARTIAL., NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!, 0); |
| 423 | |
| 424 | switch (ret) { |
| 425 | case OSCAP_PCRE_ERR_PARTIALcxx . . $ OSCAP_PCRE_ERR_PARTIAL.: |
| 426 | /* The pattern has matched a prefix of the test path |
| 427 | and probably begins with a slash. Make sure that it |
| 428 | doesn't match an arbitrary prefix. */ |
| 429 | |
| 430 | /* todo: |
| 431 | Convince folks that they should really fix their |
| 432 | OVAL definitions that use ".*" as 'path' and then |
| 433 | uncomment this. |
| 434 | |
| 435 | dD("pcre_exec() returned PCRE_ERROR_PARTIAL for pattern '%s' " |
| 436 | "and test path '%s'.\n", pattern, test_path1); |
| 437 | ret = pcre_exec(regex, NULL, test_path2, strlen(test_path2), |
| 438 | 0, PCRE_PARTIAL, NULL, 0); |
| 439 | if (ret == PCRE_ERROR_PARTIAL || ret >= 0) { |
| 440 | dE("Failed to validate the pattern: test path '%s' " |
| 441 | "matched by pattern '%s' - the pattern is too " |
| 442 | "general, i.e. inefficient. This could take a " |
| 443 | "lifetime to complete.\n", test_path2, pattern); |
| 444 | pcre_free(regex); |
| 445 | free(pattern); |
| 446 | return -2; |
| 447 | } |
| 448 | */ |
| 449 | break; |
| 450 | case OSCAP_PCRE_ERR_NOMATCHcxx . . $ OSCAP_PCRE_ERR_NOMATCH.: |
| 451 | /* The pattern doesn't contain a leading slash (or |
| 452 | some part of this code is broken). Apologise to the |
| 453 | user and fail. */ |
| 454 | dEcxx . . $ `src/common/debug_priv.h:63:9`!("Failed to validate the pattern: oscap_pcre_exec() returned " |
| 455 | "PCRE_ERROR_NOMATCH for pattern '%s' and a test path '%s'. " |
| 456 | "This indicates the pattern doesn't match a leading '/'.\n", |
| 457 | pattern, test_path1); |
| 458 | oscap_pcre_freecxx . . $ oscap_pcre_free(804bb72472b0846e).(regex); |
| 459 | freecxx . . $ free(5d22bdacc48458e8).(pattern); |
| 460 | return -2; |
| 461 | default: |
| 462 | if (ret >= 0) { |
| 463 | /* The pattern actually matches the test |
| 464 | path. Iteresting… Make sure that it doesn't |
| 465 | match an arbitrary prefix. */ |
| 466 | |
| 467 | /* todo: |
| 468 | Convince folks that they should really fix |
| 469 | their OVAL definitions that use ".*" as |
| 470 | 'path' and then uncomment this. |
| 471 | |
| 472 | ret = pcre_exec(regex, NULL, test_path2, strlen(test_path2), |
| 473 | 0, PCRE_PARTIAL, NULL, 0); |
| 474 | if (ret == PCRE_ERROR_PARTIAL || ret >= 0) { |
| 475 | dE("Failed to validate the pattern: test path '%s' " |
| 476 | "matched by pattern '%s' - the pattern is too " |
| 477 | "general, i.e. inefficient. This could take a " |
| 478 | "lifetime to complete.\n", test_path2, pattern); |
| 479 | pcre_free(regex); |
| 480 | free(pattern); |
| 481 | return -2; |
| 482 | } |
| 483 | */ |
| 484 | break; |
| 485 | } |
| 486 | /* Some other error. */ |
| 487 | dEcxx . . $ `src/common/debug_priv.h:63:9`!("Failed to validate the pattern: oscap_pcre_exec() return " |
| 488 | "code: %d, pattern '%s', test path '%s'.\n", ret, |
| 489 | pattern, test_path1); |
| 490 | oscap_pcre_freecxx . . $ oscap_pcre_free(804bb72472b0846e).(regex); |
| 491 | freecxx . . $ free(5d22bdacc48458e8).(pattern); |
| 492 | return -1; |
| 493 | } |
| 494 | |
| 495 | if (regex == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) { |
| 496 | dDcxx . . $ `src/common/debug_priv.h:64:9`!("Disabling partial match optimization."); |
| 497 | } else { |
| 498 | dDcxx . . $ `src/common/debug_priv.h:64:9`!("Enabling partial match optimization using " |
| 499 | "pattern: '%s'.", pattern); |
| 500 | if (regex_out != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) |
| 501 | *regex_out = regex; |
| 502 | else |
| 503 | oscap_pcre_freecxx . . $ oscap_pcre_free(804bb72472b0846e).(regex); |
| 504 | } |
| 505 | |
| 506 | freecxx . . $ free(5d22bdacc48458e8).(pattern); |
| 507 | |
| 508 | return 0; |
| 509 | } |
| 510 | |
| 511 | |
| 512 | #undef TEST_PATH1cxx . . $ `src/OVAL/probes/oval_fts.c:381:9`! |
| 513 | #undef TEST_PATH2cxx . . $ `src/OVAL/probes/oval_fts.c:382:9`! |
| 514 | |
| 515 | OVAL_FTScxx . . $ OVAL_FTS# *oval_fts_opencxx . . $ oval_fts_open(ec388d9c23d3f6cb).(SEXP_tcxx . . $ SEXP_t# *path, SEXP_tcxx . . $ SEXP_t# *filename, SEXP_tcxx . . $ SEXP_t# *filepath, SEXP_tcxx . . $ SEXP_t# *behaviors, SEXP_tcxx . . $ SEXP_t#* result) |
| 516 | { |
| 517 | return oval_fts_open_prefixedcxx . . $ oval_fts_open_prefixed(d2d91f0fe545c5d7).(NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!, path, filename, filepath, behaviors, result); |
| 518 | } |
| 519 | |
| 520 | OVAL_FTScxx . . $ OVAL_FTS# *oval_fts_open_prefixedcxx . . $ oval_fts_open_prefixed(d2d91f0fe545c5d7).(const char *prefix, SEXP_tcxx . . $ SEXP_t# *path, SEXP_tcxx . . $ SEXP_t# *filename, SEXP_tcxx . . $ SEXP_t# *filepath, SEXP_tcxx . . $ SEXP_t# *behaviors, SEXP_tcxx . . $ SEXP_t#* result) |
| 521 | { |
| 522 | OVAL_FTScxx . . $ OVAL_FTS# *ofts; |
| 523 | |
| 524 | char cstr_path[PATH_MAXcxx . . $ `<external>/6347054901304145714/limits.h:13:9`!+1]; |
| 525 | char cstr_file[PATH_MAXcxx . . $ `<external>/6347054901304145714/limits.h:13:9`!+1]; |
| 526 | char cstr_buff[32]; |
| 527 | const char *paths[2] = { NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`! }; |
| 528 | |
| 529 | SEXP_tcxx . . $ SEXP_t# *r0; |
| 530 | |
| 531 | int mtc_fts_options = FTS_PHYSICALcxx . . $ `<external>/345209348829246610/fts.h:72:9`! | FTS_COMFOLLOWcxx . . $ `<external>/345209348829246610/fts.h:68:9`! | FTS_NOCHDIRcxx . . $ `<external>/345209348829246610/fts.h:70:9`!; |
| 532 | int rec_fts_options = FTS_PHYSICALcxx . . $ `<external>/345209348829246610/fts.h:72:9`! | FTS_COMFOLLOWcxx . . $ `<external>/345209348829246610/fts.h:68:9`! | FTS_NOCHDIRcxx . . $ `<external>/345209348829246610/fts.h:70:9`!; |
| 533 | int max_depth = -1; |
| 534 | int direction = -1; |
| 535 | int recurse = -1; |
| 536 | int filesystem = -1; |
| 537 | |
| 538 | uint32_tcxx . . $ uint32_t# path_op; |
| 539 | boolcxx . . $ `<external>/14268322491693841775/stdbool.h:36:9`! nilfilename = falsecxx . . $ `<external>/14268322491693841775/stdbool.h:38:9`!; |
| 540 | oscap_pcre_tcxx . . $ oscap_pcre_t# *regex = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!; |
| 541 | struct statcxx . . $ stat# st; |
| 542 | |
| 543 | if ((path != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`! || filename != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`! || filepath == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) |
| 544 | && (path == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`! || filepath != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!)) { |
| 545 | return NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!; |
| 546 | } |
| 547 | if (behaviors == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) { |
| 548 | return NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!; |
| 549 | } |
| 550 | |
| 551 | if (path) |
| 552 | PROBE_ENT_AREFcxx . . $ `src/OVAL/probes/public/probe-api.h:479:9`!(path, r0, "operation", /**/); |
| 553 | else |
| 554 | PROBE_ENT_AREFcxx . . $ `src/OVAL/probes/public/probe-api.h:479:9`!(filepath, r0, "operation", /**/); |
| 555 | |
| 556 | if (r0 != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) { |
| 557 | path_op = SEXP_number_getucxx . . $ `src/OVAL/probes/SEAP/public/sexp-manip.h:145:10`!(r0); |
| 558 | SEXP_freecxx . . $ SEXP_free(c6b28547479798f4).(r0); |
| 559 | } else { |
| 560 | path_op = OVAL_OPERATION_EQUALScxx . . $ OVAL_OPERATION_EQUALS.; |
| 561 | } |
| 562 | #if defined(OSCAP_FTS_DEBUG) |
| 563 | dD("path_op: %u, '%s'.", path_op, oval_operation_get_text(path_op)); |
| 564 | #endif |
| 565 | if (path) { /* filepath == NULL */ |
| 566 | PROBE_ENT_STRVALcxx . . $ `src/OVAL/probes/public/probe-api.h:487:9`!(path, cstr_path, sizeof cstr_path, |
| 567 | return NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!;, return NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!;); |
| 568 | if (probe_ent_getvalscxx . . $ probe_ent_getvals(87c285983fc46746).(filename, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) == 0) { |
| 569 | nilfilename = truecxx . . $ `<external>/14268322491693841775/stdbool.h:37:9`!; |
| 570 | } else { |
| 571 | PROBE_ENT_STRVALcxx . . $ `src/OVAL/probes/public/probe-api.h:487:9`!(filename, cstr_file, sizeof cstr_file, |
| 572 | return NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!;, /* noop */;); |
| 573 | } |
| 574 | #if defined(OSCAP_FTS_DEBUG) |
| 575 | dD("path: '%s', filename: '%s', filename: %d.", cstr_path, nilfilename ? "" : cstr_file, nilfilename); |
| 576 | #endif |
| 577 | } else { /* filepath != NULL */ |
| 578 | PROBE_ENT_STRVALcxx . . $ `src/OVAL/probes/public/probe-api.h:487:9`!(filepath, cstr_path, sizeof cstr_path, return NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!;, return NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!;); |
| 579 | } |
| 580 | |
| 581 | /* max_depth */ |
| 582 | PROBE_ENT_AREFcxx . . $ `src/OVAL/probes/public/probe-api.h:479:9`!(behaviors, r0, "max_depth", return NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!;); |
| 583 | SEXP_string_cstr_rcxx . . $ SEXP_string_cstr_r(ca07af91a4fa826f).(r0, cstr_buff, sizeof cstr_buff - 1); |
| 584 | errnocxx . . $ `<external>/17633486526465735210/errno.h:38:10`! = 0; |
| 585 | max_depth = strtolcxx . . $ strtol(44bbb87609b212fc).(cstr_buff, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!, 10); |
| 586 | if (errnocxx . . $ `<external>/17633486526465735210/errno.h:38:10`! == EINVALcxx . . $ `<external>/8987895939074593727/errno-base.h:26:9`! || errnocxx . . $ `<external>/17633486526465735210/errno.h:38:10`! == ERANGEcxx . . $ `<external>/8987895939074593727/errno-base.h:38:9`!) { |
| 587 | dEcxx . . $ `src/common/debug_priv.h:63:9`!("Invalid value of the `%s' attribute: %s", "recurse_direction", cstr_buff); |
| 588 | SEXP_freecxx . . $ SEXP_free(c6b28547479798f4).(r0); |
| 589 | return (NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!); |
| 590 | } |
| 591 | #if defined(OSCAP_FTS_DEBUG) |
| 592 | dD("bh.max_depth: %s => max_depth: %d", cstr_buff, max_depth); |
| 593 | #endif |
| 594 | SEXP_freecxx . . $ SEXP_free(c6b28547479798f4).(r0); |
| 595 | |
| 596 | /* recurse_direction */ |
| 597 | PROBE_ENT_AREFcxx . . $ `src/OVAL/probes/public/probe-api.h:479:9`!(behaviors, r0, "recurse_direction", return NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!;); |
| 598 | SEXP_string_cstr_rcxx . . $ SEXP_string_cstr_r(ca07af91a4fa826f).(r0, cstr_buff, sizeof cstr_buff - 1); |
| 599 | /* todo: use oscap_string_to_enum() */ |
| 600 | if (strcmpcxx . . $ strcmp(5ae29d726ae57f88).(cstr_buff, "none") == 0) { |
| 601 | direction = OVAL_RECURSE_DIRECTION_NONEcxx . . $ `src/OVAL/probes/oval_fts.h:99:9`!; |
| 602 | } else if (strcmpcxx . . $ strcmp(5ae29d726ae57f88).(cstr_buff, "down") == 0) { |
| 603 | direction = OVAL_RECURSE_DIRECTION_DOWNcxx . . $ `src/OVAL/probes/oval_fts.h:100:9`!; |
| 604 | } else if (strcmpcxx . . $ strcmp(5ae29d726ae57f88).(cstr_buff, "up") == 0) { |
| 605 | direction = OVAL_RECURSE_DIRECTION_UPcxx . . $ `src/OVAL/probes/oval_fts.h:101:9`!; |
| 606 | } else { |
| 607 | dEcxx . . $ `src/common/debug_priv.h:63:9`!("Invalid direction: %s", cstr_buff); |
| 608 | SEXP_freecxx . . $ SEXP_free(c6b28547479798f4).(r0); |
| 609 | return (NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!); |
| 610 | } |
| 611 | #if defined(OSCAP_FTS_DEBUG) |
| 612 | dD("bh.direction: %s => direction: %d", cstr_buff, direction); |
| 613 | #endif |
| 614 | SEXP_freecxx . . $ SEXP_free(c6b28547479798f4).(r0); |
| 615 | |
| 616 | /* recurse */ |
| 617 | PROBE_ENT_AREFcxx . . $ `src/OVAL/probes/public/probe-api.h:479:9`!(behaviors, r0, "recurse", /**/); |
| 618 | if (r0 != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) { |
| 619 | SEXP_string_cstr_rcxx . . $ SEXP_string_cstr_r(ca07af91a4fa826f).(r0, cstr_buff, sizeof cstr_buff - 1); |
| 620 | /* todo: use oscap_string_to_enum() */ |
| 621 | if (strcmpcxx . . $ strcmp(5ae29d726ae57f88).(cstr_buff, "symlinks and directories") == 0) { |
| 622 | recurse = OVAL_RECURSE_SYMLINKS_AND_DIRScxx . . $ `src/OVAL/probes/oval_fts.h:107:9`!; |
| 623 | } else if (strcmpcxx . . $ strcmp(5ae29d726ae57f88).(cstr_buff, "files and directories") == 0) { |
| 624 | recurse = OVAL_RECURSE_FILES_AND_DIRScxx . . $ `src/OVAL/probes/oval_fts.h:108:9`!; |
| 625 | } else if (strcmpcxx . . $ strcmp(5ae29d726ae57f88).(cstr_buff, "symlinks") == 0) { |
| 626 | recurse = OVAL_RECURSE_SYMLINKScxx . . $ `src/OVAL/probes/oval_fts.h:105:9`!; |
| 627 | } else if (strcmpcxx . . $ strcmp(5ae29d726ae57f88).(cstr_buff, "directories") == 0) { |
| 628 | recurse = OVAL_RECURSE_DIRScxx . . $ `src/OVAL/probes/oval_fts.h:104:9`!; |
| 629 | } else { |
| 630 | dEcxx . . $ `src/common/debug_priv.h:63:9`!("Invalid recurse: %s", cstr_buff); |
| 631 | SEXP_freecxx . . $ SEXP_free(c6b28547479798f4).(r0); |
| 632 | return (NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!); |
| 633 | } |
| 634 | } else { |
| 635 | recurse = OVAL_RECURSE_SYMLINKS_AND_DIRScxx . . $ `src/OVAL/probes/oval_fts.h:107:9`!; |
| 636 | } |
| 637 | #if defined(OSCAP_FTS_DEBUG) |
| 638 | dD("bh.recurse: %s => recurse: %d", cstr_buff, recurse); |
| 639 | #endif |
| 640 | SEXP_freecxx . . $ SEXP_free(c6b28547479798f4).(r0); |
| 641 | |
| 642 | /* recurse_file_system */ |
| 643 | PROBE_ENT_AREFcxx . . $ `src/OVAL/probes/public/probe-api.h:479:9`!(behaviors, r0, "recurse_file_system", /**/); |
| 644 | |
| 645 | if (r0 != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) { |
| 646 | SEXP_string_cstr_rcxx . . $ SEXP_string_cstr_r(ca07af91a4fa826f).(r0, cstr_buff, sizeof cstr_buff - 1); |
| 647 | /* todo: use oscap_string_to_enum() */ |
| 648 | if (strcmpcxx . . $ strcmp(5ae29d726ae57f88).(cstr_buff, "local") == 0) { |
| 649 | filesystem = OVAL_RECURSE_FS_LOCALcxx . . $ `src/OVAL/probes/oval_fts.h:110:9`!; |
| 650 | } else if (strcmpcxx . . $ strcmp(5ae29d726ae57f88).(cstr_buff, "all") == 0) { |
| 651 | filesystem = OVAL_RECURSE_FS_ALLcxx . . $ `src/OVAL/probes/oval_fts.h:112:9`!; |
| 652 | } else if (strcmpcxx . . $ strcmp(5ae29d726ae57f88).(cstr_buff, "defined") == 0) { |
| 653 | filesystem = OVAL_RECURSE_FS_DEFINEDcxx . . $ `src/OVAL/probes/oval_fts.h:111:9`!; |
| 654 | rec_fts_options |= FTS_XDEVcxx . . $ `<external>/345209348829246610/fts.h:74:9`!; |
| 655 | } else { |
| 656 | dEcxx . . $ `src/common/debug_priv.h:63:9`!("Invalid recurse filesystem: %s", cstr_buff); |
| 657 | SEXP_freecxx . . $ SEXP_free(c6b28547479798f4).(r0); |
| 658 | return (NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!); |
| 659 | } |
| 660 | } else { |
| 661 | filesystem = OVAL_RECURSE_FS_ALLcxx . . $ `src/OVAL/probes/oval_fts.h:112:9`!; |
| 662 | } |
| 663 | #if defined(OSCAP_FTS_DEBUG) |
| 664 | dD("bh.filesystem: %s => filesystem: %d", cstr_buff, filesystem); |
| 665 | #endif |
| 666 | SEXP_freecxx . . $ SEXP_free(c6b28547479798f4).(r0); |
| 667 | |
| 668 | /* todo: |
| 669 | Still missing is a propagation of the error to the |
| 670 | user. Currently, all the information is provided in the |
| 671 | debug log, but the oval_fts api has no way of passing this |
| 672 | information to the user. |
| 673 | */ |
| 674 | |
| 675 | if (path_op == OVAL_OPERATION_EQUALScxx . . $ OVAL_OPERATION_EQUALS.) { |
| 676 | paths[0] = strdupcxx . . $ strdup(a8b8e32347182212).(cstr_path); |
| 677 | } else if (path_op == OVAL_OPERATION_PATTERN_MATCHcxx . . $ OVAL_OPERATION_PATTERN_MATCH.) { |
| 678 | if (process_pattern_matchcxx . . $ process_pattern_match(c4e09908c59384c8).(cstr_path, ®ex) != 0) |
| 679 | return NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!; |
| 680 | paths[0] = extract_fixed_path_prefixcxx . . $ extract_fixed_path_prefix(7a9722d75b371431).(cstr_path); |
| 681 | dDcxx . . $ `src/common/debug_priv.h:64:9`!("Extracted fixed path: '%s'.", paths[0]); |
| 682 | } else { |
| 683 | paths[0] = strdupcxx . . $ strdup(a8b8e32347182212).("/"); |
| 684 | } |
| 685 | |
| 686 | if (prefix != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) { |
| 687 | char *path_with_prefix = oscap_path_joincxx . . $ oscap_path_join(a713fe7b9a57cf96).(prefix, paths[0]); |
| 688 | freecxx . . $ free(5d22bdacc48458e8).((void *) paths[0]); |
| 689 | paths[0] = path_with_prefix; |
| 690 | } |
| 691 | dIcxx . . $ `src/common/debug_priv.h:61:9`!("Opening file '%s'.", paths[0]); |
| 692 | /* Fail if the provided path doensn't actually exist. Symlinks |
| 693 | without targets are accepted. */ |
| 694 | if (lstatcxx . . $ lstat(a9cd1e23e96f423c).(paths[0], &st) == -1) { |
| 695 | if (errnocxx . . $ `<external>/17633486526465735210/errno.h:38:10`!) { |
| 696 | dDcxx . . $ `src/common/debug_priv.h:64:9`!("lstat() failed: errno: %d, '%s'.", |
| 697 | errnocxx . . $ `<external>/17633486526465735210/errno.h:38:10`!, strerror(errnocxx . . $ `<external>/17633486526465735210/errno.h:38:10`!)); |
| 698 | } |
| 699 | freecxx . . $ free(5d22bdacc48458e8).((void *) paths[0]); |
| 700 | oscap_pcre_freecxx . . $ oscap_pcre_free(804bb72472b0846e).(regex); |
| 701 | return NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!; |
| 702 | } |
| 703 | |
| 704 | ofts = OVAL_FTS_newcxx . . $ OVAL_FTS_new(18ecb4464872cead).(); |
| 705 | ofts->prefixcxx . . $ $anonymous_type_ebdee0feb58b991e_0#prefix. = prefix; |
| 706 | |
| 707 | /* reset errno as fts_open() doesn't do it itself. */ |
| 708 | errnocxx . . $ `<external>/17633486526465735210/errno.h:38:10`! = 0; |
| 709 | ofts->ofts_match_path_ftscxx . . $ $anonymous_type_ebdee0feb58b991e_0#ofts_match_path_fts. = fts_opencxx . . $ fts_open(9139013e252a7d42).((char * const *) paths, mtc_fts_options, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!); |
| 710 | freecxx . . $ free(5d22bdacc48458e8).((void *) paths[0]); |
| 711 | /* fts_open() doesn't return NULL for all errors (e.g. nonexistent paths), |
| 712 | so check errno to detect it. Far from being perfect. */ |
| 713 | if (ofts->ofts_match_path_ftscxx . . $ $anonymous_type_ebdee0feb58b991e_0#ofts_match_path_fts. == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`! || errnocxx . . $ `<external>/17633486526465735210/errno.h:38:10`! != 0) { |
| 714 | dEcxx . . $ `src/common/debug_priv.h:63:9`!("fts_open() failed, errno: %d \"%s\".", errnocxx . . $ `<external>/17633486526465735210/errno.h:38:10`!, strerror(errnocxx . . $ `<external>/17633486526465735210/errno.h:38:10`!)); |
| 715 | OVAL_FTS_freecxx . . $ OVAL_FTS_free(f2ac88db1829285e).(ofts); |
| 716 | oscap_pcre_freecxx . . $ oscap_pcre_free(804bb72472b0846e).(regex); |
| 717 | return (NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!); |
| 718 | } |
| 719 | |
| 720 | ofts->ofts_recurse_path_fts_optscxx . . $ $anonymous_type_ebdee0feb58b991e_0#ofts_recurse_path_fts_opts. = rec_fts_options; |
| 721 | ofts->ofts_path_opcxx . . $ $anonymous_type_ebdee0feb58b991e_0#ofts_path_op. = path_op; |
| 722 | if (regex != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) { |
| 723 | ofts->ofts_path_regexcxx . . $ $anonymous_type_ebdee0feb58b991e_0#ofts_path_regex. = regex; |
| 724 | } |
| 725 | |
| 726 | if (filesystem == OVAL_RECURSE_FS_LOCALcxx . . $ `src/OVAL/probes/oval_fts.h:110:9`!) { |
| 727 | #if defined(OS_SOLARIS) |
| 728 | ofts->localdevs = NULL; |
| 729 | #else |
| 730 | ofts->localdevscxx . . $ $anonymous_type_ebdee0feb58b991e_0#localdevs. = fsdev_initcxx . . $ fsdev_init(7d22408f4c7e197c).(); |
| 731 | if (ofts->localdevscxx . . $ $anonymous_type_ebdee0feb58b991e_0#localdevs. == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) { |
| 732 | dEcxx . . $ `src/common/debug_priv.h:63:9`!("fsdev_init() failed."); |
| 733 | /* One dummy read to get rid of an uninitialized |
| 734 | * value in the FTS data before calling |
| 735 | * fts_close() on it. */ |
| 736 | fts_readcxx . . $ fts_read(a5ee146c26ffa24d).(ofts->ofts_match_path_ftscxx . . $ $anonymous_type_ebdee0feb58b991e_0#ofts_match_path_fts.); |
| 737 | oval_fts_closecxx . . $ oval_fts_close(cd898f79c195c42c).(ofts); |
| 738 | return (NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!); |
| 739 | } |
| 740 | #endif |
| 741 | } else if (filesystem == OVAL_RECURSE_FS_DEFINEDcxx . . $ `src/OVAL/probes/oval_fts.h:111:9`!) { |
| 742 | /* store the device id for future comparison */ |
| 743 | FTSENTcxx . . $ FTSENT# *fts_ent; |
| 744 | |
| 745 | fts_ent = fts_readcxx . . $ fts_read(a5ee146c26ffa24d).(ofts->ofts_match_path_ftscxx . . $ $anonymous_type_ebdee0feb58b991e_0#ofts_match_path_fts.); |
| 746 | if (fts_ent != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) { |
| 747 | ofts->ofts_recurse_path_devidcxx . . $ $anonymous_type_ebdee0feb58b991e_0#ofts_recurse_path_devid. = fts_ent->fts_statpcxx . . $ _ftsent#fts_statp.->st_devcxx . . $ stat#st_dev.; |
| 748 | fts_setcxx . . $ fts_set(f293ebff43d3d282).(ofts->ofts_match_path_ftscxx . . $ $anonymous_type_ebdee0feb58b991e_0#ofts_match_path_fts., fts_ent, FTS_AGAINcxx . . $ `<external>/345209348829246610/fts.h:139:9`!); |
| 749 | } |
| 750 | } |
| 751 | |
| 752 | ofts->recursecxx . . $ $anonymous_type_ebdee0feb58b991e_0#recurse. = recurse; |
| 753 | ofts->filesystemcxx . . $ $anonymous_type_ebdee0feb58b991e_0#filesystem. = filesystem; |
| 754 | |
| 755 | if (path) { /* filepath == NULL */ |
| 756 | ofts->ofts_spathcxx . . $ $anonymous_type_ebdee0feb58b991e_0#ofts_spath. = SEXP_refcxx . . $ SEXP_ref(2f7f980afaaae0f0).(path); /* path entity */ |
| 757 | if (!nilfilename) |
| 758 | ofts->ofts_sfilenamecxx . . $ $anonymous_type_ebdee0feb58b991e_0#ofts_sfilename. = SEXP_refcxx . . $ SEXP_ref(2f7f980afaaae0f0).(filename); /* filename entity */ |
| 759 | |
| 760 | ofts->max_depthcxx . . $ $anonymous_type_ebdee0feb58b991e_0#max_depth. = max_depth; |
| 761 | ofts->directioncxx . . $ $anonymous_type_ebdee0feb58b991e_0#direction. = direction; |
| 762 | } else { /* filepath != NULL */ |
| 763 | ofts->ofts_sfilepathcxx . . $ $anonymous_type_ebdee0feb58b991e_0#ofts_sfilepath. = SEXP_refcxx . . $ SEXP_ref(2f7f980afaaae0f0).(filepath); |
| 764 | } |
| 765 | |
| 766 | #if defined(OS_SOLARIS) |
| 767 | if (load_zones_path_list() != 0) { |
| 768 | dE("Failed to load zones path info. Recursing non-global zones."); |
| 769 | free_zones_path_list(); |
| 770 | } |
| 771 | #endif |
| 772 | |
| 773 | ofts->resultcxx . . $ $anonymous_type_ebdee0feb58b991e_0#result. = result; |
| 774 | |
| 775 | return (ofts); |
| 776 | } |
| 777 | |
| 778 | static inline int _oval_fts_is_localcxx . . $ _oval_fts_is_local(773508e850f37605).(OVAL_FTScxx . . $ OVAL_FTS# *ofts, FTSENTcxx . . $ FTSENT# *fts_ent) { |
| 779 | # if defined(OS_SOLARIS) |
| 780 | /* pseudo filesystems will be skipped */ |
| 781 | /* don't recurse into remote fs if local is specified */ |
| 782 | return ((fts_ent->fts_info == FTS_D || fts_ent->fts_info == FTS_SL) |
| 783 | && (!OVAL_FTS_localp(ofts, fts_ent->fts_path, |
| 784 | (fts_ent->fts_statp != NULL) ? |
| 785 | &fts_ent->fts_statp->st_fstype : NULL))); |
| 786 | #else |
| 787 | /* don't recurse into non-local filesystems */ |
| 788 | return (ofts->filesystemcxx . . $ $anonymous_type_ebdee0feb58b991e_0#filesystem. == OVAL_RECURSE_FS_LOCALcxx . . $ `src/OVAL/probes/oval_fts.h:110:9`! |
| 789 | && (fts_ent->fts_infocxx . . $ _ftsent#fts_info. == FTS_Dcxx . . $ `<external>/345209348829246610/fts.h:119:9`! || fts_ent->fts_infocxx . . $ _ftsent#fts_info. == FTS_SLcxx . . $ `<external>/345209348829246610/fts.h:130:9`!) |
| 790 | && (!OVAL_FTS_localpcxx . . $ OVAL_FTS_localp(88198641f3bcbed).(ofts, fts_ent->fts_pathcxx . . $ _ftsent#fts_path., |
| 791 | (fts_ent->fts_statpcxx . . $ _ftsent#fts_statp. != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) ? |
| 792 | &fts_ent->fts_statpcxx . . $ _ftsent#fts_statp.->st_devcxx . . $ stat#st_dev. : NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!))); |
| 793 | #endif |
| 794 | } |
| 795 | |
| 796 | /* find the first matching path or filepath */ |
| 797 | static FTSENTcxx . . $ FTSENT# *oval_fts_read_match_pathcxx . . $ oval_fts_read_match_path(abab8876adc3df1a).(OVAL_FTScxx . . $ OVAL_FTS# *ofts) |
| 798 | { |
| 799 | FTSENTcxx . . $ FTSENT# *fts_ent = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!; |
| 800 | SEXP_tcxx . . $ SEXP_t# *stmp; |
| 801 | oval_result_tcxx . . $ oval_result_t# ores; |
| 802 | |
| 803 | /* iterate until a match is found or all elements have been traversed */ |
| 804 | for (;;) { |
| 805 | fts_ent = fts_readcxx . . $ fts_read(a5ee146c26ffa24d).(ofts->ofts_match_path_ftscxx . . $ $anonymous_type_ebdee0feb58b991e_0#ofts_match_path_fts.); |
| 806 | if (fts_ent == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) |
| 807 | return NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!; |
| 808 | switch (fts_ent->fts_infocxx . . $ _ftsent#fts_info.) { |
| 809 | case FTS_DPcxx . . $ `<external>/345209348829246610/fts.h:124:9`!: |
| 810 | continue; |
| 811 | case FTS_DCcxx . . $ `<external>/345209348829246610/fts.h:120:9`!: |
| 812 | dWcxx . . $ `src/common/debug_priv.h:62:9`!("Filesystem tree cycle detected at '%s'.", fts_ent->fts_path); |
| 813 | fts_setcxx . . $ fts_set(f293ebff43d3d282).(ofts->ofts_match_path_ftscxx . . $ $anonymous_type_ebdee0feb58b991e_0#ofts_match_path_fts., fts_ent, FTS_SKIPcxx . . $ `<external>/345209348829246610/fts.h:142:9`!); |
| 814 | continue; |
| 815 | } |
| 816 | |
| 817 | #if defined(OSCAP_FTS_DEBUG) |
| 818 | dD("fts_path: '%s' (l=%d)." |
| 819 | "fts_name: '%s' (l=%d).\n" |
| 820 | "fts_info: %u.\n", fts_ent->fts_path, fts_ent->fts_pathlen, |
| 821 | fts_ent->fts_name, fts_ent->fts_namelen, fts_ent->fts_info); |
| 822 | #endif |
| 823 | |
| 824 | if (fts_ent->fts_infocxx . . $ _ftsent#fts_info. == FTS_SLcxx . . $ `<external>/345209348829246610/fts.h:130:9`!) { |
| 825 | #if defined(OSCAP_FTS_DEBUG) |
| 826 | dD("Only the target of a symlink gets reported, skipping '%s'.", fts_ent->fts_path, fts_ent->fts_name); |
| 827 | #endif |
| 828 | fts_setcxx . . $ fts_set(f293ebff43d3d282).(ofts->ofts_match_path_ftscxx . . $ $anonymous_type_ebdee0feb58b991e_0#ofts_match_path_fts., fts_ent, FTS_FOLLOWcxx . . $ `<external>/345209348829246610/fts.h:140:9`!); |
| 829 | continue; |
| 830 | } |
| 831 | if (_oval_fts_is_localcxx . . $ _oval_fts_is_local(773508e850f37605).(ofts, fts_ent)) { |
| 832 | dIcxx . . $ `src/common/debug_priv.h:61:9`!("Don't recurse into non-local filesystems, skipping '%s'.", fts_ent->fts_path); |
| 833 | fts_setcxx . . $ fts_set(f293ebff43d3d282).(ofts->ofts_recurse_path_ftscxx . . $ $anonymous_type_ebdee0feb58b991e_0#ofts_recurse_path_fts., fts_ent, FTS_SKIPcxx . . $ `<external>/345209348829246610/fts.h:142:9`!); |
| 834 | continue; |
| 835 | } |
| 836 | /* don't recurse beyond the initial filesystem */ |
| 837 | if (ofts->filesystemcxx . . $ $anonymous_type_ebdee0feb58b991e_0#filesystem. == OVAL_RECURSE_FS_DEFINEDcxx . . $ `src/OVAL/probes/oval_fts.h:111:9`! |
| 838 | && (fts_ent->fts_infocxx . . $ _ftsent#fts_info. == FTS_Dcxx . . $ `<external>/345209348829246610/fts.h:119:9`! || fts_ent->fts_infocxx . . $ _ftsent#fts_info. == FTS_SLcxx . . $ `<external>/345209348829246610/fts.h:130:9`!) |
| 839 | && ofts->ofts_recurse_path_devidcxx . . $ $anonymous_type_ebdee0feb58b991e_0#ofts_recurse_path_devid. != fts_ent->fts_statpcxx . . $ _ftsent#fts_statp.->st_devcxx . . $ stat#st_dev.) { |
| 840 | fts_setcxx . . $ fts_set(f293ebff43d3d282).(ofts->ofts_recurse_path_ftscxx . . $ $anonymous_type_ebdee0feb58b991e_0#ofts_recurse_path_fts., fts_ent, FTS_SKIPcxx . . $ `<external>/345209348829246610/fts.h:142:9`!); |
| 841 | continue; |
| 842 | } |
| 843 | |
| 844 | const size_t shift = ofts->prefixcxx . . $ $anonymous_type_ebdee0feb58b991e_0#prefix. ? strlencxx . . $ strlen(751346f8406fd082).(ofts->prefixcxx . . $ $anonymous_type_ebdee0feb58b991e_0#prefix.) : 0; |
| 845 | /* partial match optimization for OVAL_OPERATION_PATTERN_MATCH operation on path and filepath */ |
| 846 | if (ofts->ofts_path_regexcxx . . $ $anonymous_type_ebdee0feb58b991e_0#ofts_path_regex. != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`! && fts_ent->fts_infocxx . . $ _ftsent#fts_info. == FTS_Dcxx . . $ `<external>/345209348829246610/fts.h:119:9`!) { |
| 847 | int ret, svec[3]; |
| 848 | |
| 849 | ret = oscap_pcre_execcxx . . $ oscap_pcre_exec(7630dfd25fd504ec).(ofts->ofts_path_regexcxx . . $ $anonymous_type_ebdee0feb58b991e_0#ofts_path_regex., |
| 850 | fts_ent->fts_pathcxx . . $ _ftsent#fts_path.+shift, fts_ent->fts_pathlencxx . . $ _ftsent#fts_pathlen.-shift, 0, OSCAP_PCRE_OPTS_PARTIALcxx . . $ OSCAP_PCRE_OPTS_PARTIAL., |
| 851 | svec, sizeof(svec) / sizeof(svec[0])); |
| 852 | if (ret < 0) { |
| 853 | switch (ret) { |
| 854 | case OSCAP_PCRE_ERR_NOMATCHcxx . . $ OSCAP_PCRE_ERR_NOMATCH.: |
| 855 | dDcxx . . $ `src/common/debug_priv.h:64:9`!("Partial match optimization: PCRE_ERROR_NOMATCH, skipping."); |
| 856 | fts_setcxx . . $ fts_set(f293ebff43d3d282).(ofts->ofts_match_path_ftscxx . . $ $anonymous_type_ebdee0feb58b991e_0#ofts_match_path_fts., fts_ent, FTS_SKIPcxx . . $ `<external>/345209348829246610/fts.h:142:9`!); |
| 857 | continue; |
| 858 | case OSCAP_PCRE_ERR_PARTIALcxx . . $ OSCAP_PCRE_ERR_PARTIAL.: |
| 859 | dDcxx . . $ `src/common/debug_priv.h:64:9`!("Partial match optimization: PCRE_ERROR_PARTIAL, continuing."); |
| 860 | continue; |
| 861 | default: |
| 862 | dEcxx . . $ `src/common/debug_priv.h:63:9`!("oscap_pcre_exec() error: %d.", ret); |
| 863 | return NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!; |
| 864 | } |
| 865 | } |
| 866 | } |
| 867 | |
| 868 | if ((ofts->ofts_sfilepathcxx . . $ $anonymous_type_ebdee0feb58b991e_0#ofts_sfilepath. && fts_ent->fts_infocxx . . $ _ftsent#fts_info. == FTS_Dcxx . . $ `<external>/345209348829246610/fts.h:119:9`!) |
| 869 | || (!ofts->ofts_sfilepathcxx . . $ $anonymous_type_ebdee0feb58b991e_0#ofts_sfilepath. && fts_ent->fts_infocxx . . $ _ftsent#fts_info. != FTS_Dcxx . . $ `<external>/345209348829246610/fts.h:119:9`!)) |
| 870 | continue; |
| 871 | |
| 872 | stmp = SEXP_string_newfcxx . . $ SEXP_string_newf(b2137ed863725962).("%s", fts_ent->fts_pathcxx . . $ _ftsent#fts_path. + shift); |
| 873 | |
| 874 | if (ofts->ofts_sfilepathcxx . . $ $anonymous_type_ebdee0feb58b991e_0#ofts_sfilepath.) |
| 875 | /* try to match filepath */ |
| 876 | ores = probe_entobj_cmpcxx . . $ probe_entobj_cmp(e245451a1311e799).(ofts->ofts_sfilepathcxx . . $ $anonymous_type_ebdee0feb58b991e_0#ofts_sfilepath., stmp); |
| 877 | else |
| 878 | /* try to match path */ |
| 879 | ores = probe_entobj_cmpcxx . . $ probe_entobj_cmp(e245451a1311e799).(ofts->ofts_spathcxx . . $ $anonymous_type_ebdee0feb58b991e_0#ofts_spath., stmp); |
| 880 | SEXP_freecxx . . $ SEXP_free(c6b28547479798f4).(stmp); |
| 881 | |
| 882 | if (ores == OVAL_RESULT_TRUEcxx . . $ OVAL_RESULT_TRUE.) |
| 883 | break; |
| 884 | if (ofts->ofts_path_opcxx . . $ $anonymous_type_ebdee0feb58b991e_0#ofts_path_op. == OVAL_OPERATION_EQUALScxx . . $ OVAL_OPERATION_EQUALS.) { |
| 885 | /* At this point the comparison result isn't OVAL_RESULT_TRUE. Since |
| 886 | we passed the exact path (from filepath or path elements) to |
| 887 | fts_open() we surely know that we can't find other items that would |
| 888 | be equal. Therefore we can terminate the matching. This can happen |
| 889 | if the filepath or path element references a variable that has |
| 890 | multiple different values. */ |
| 891 | return NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!; |
| 892 | } |
| 893 | } /* for (;;) */ |
| 894 | |
| 895 | /* |
| 896 | * If we know that we are not going to return anything |
| 897 | * else, then we can close the path FTS and return NULL |
| 898 | * the next time... |
| 899 | */ |
| 900 | if (ofts->ofts_path_opcxx . . $ $anonymous_type_ebdee0feb58b991e_0#ofts_path_op. == OVAL_OPERATION_EQUALScxx . . $ OVAL_OPERATION_EQUALS. && |
| 901 | ofts->directioncxx . . $ $anonymous_type_ebdee0feb58b991e_0#direction. == OVAL_RECURSE_DIRECTION_NONEcxx . . $ `src/OVAL/probes/oval_fts.h:99:9`! && |
| 902 | ofts->ofts_sfilenamecxx . . $ $anonymous_type_ebdee0feb58b991e_0#ofts_sfilename. == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`! && |
| 903 | ofts->ofts_sfilepathcxx . . $ $anonymous_type_ebdee0feb58b991e_0#ofts_sfilepath. == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) |
| 904 | { |
| 905 | fts_setcxx . . $ fts_set(f293ebff43d3d282).(ofts->ofts_match_path_ftscxx . . $ $anonymous_type_ebdee0feb58b991e_0#ofts_match_path_fts., fts_ent, FTS_SKIPcxx . . $ `<external>/345209348829246610/fts.h:142:9`!); |
| 906 | } |
| 907 | |
| 908 | return fts_ent; |
| 909 | } |
| 910 | |
| 911 | /* find the first matching file or directory */ |
| 912 | static FTSENTcxx . . $ FTSENT# *oval_fts_read_recurse_pathcxx . . $ oval_fts_read_recurse_path(abab8876adc3df1a).(OVAL_FTScxx . . $ OVAL_FTS# *ofts) |
| 913 | { |
| 914 | FTSENTcxx . . $ FTSENT# *out_fts_ent = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!; |
| 915 | /* the condition below is correct because ofts_sfilepath is NULL here */ |
| 916 | boolcxx . . $ `<external>/14268322491693841775/stdbool.h:36:9`! collect_dirs = (ofts->ofts_sfilenamecxx . . $ $anonymous_type_ebdee0feb58b991e_0#ofts_sfilename. == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!); |
| 917 | |
| 918 | switch (ofts->directioncxx . . $ $anonymous_type_ebdee0feb58b991e_0#direction.) { |
| 919 | |
| 920 | case OVAL_RECURSE_DIRECTION_DOWNcxx . . $ `src/OVAL/probes/oval_fts.h:100:9`!: |
| 921 | case OVAL_RECURSE_DIRECTION_NONEcxx . . $ `src/OVAL/probes/oval_fts.h:99:9`!: |
| 922 | if (ofts->directioncxx . . $ $anonymous_type_ebdee0feb58b991e_0#direction. == OVAL_RECURSE_DIRECTION_NONEcxx . . $ `src/OVAL/probes/oval_fts.h:99:9`! |
| 923 | && collect_dirs) { |
| 924 | /* the target is the directory itself */ |
| 925 | out_fts_ent = ofts->ofts_match_path_fts_entcxx . . $ $anonymous_type_ebdee0feb58b991e_0#ofts_match_path_fts_ent.; |
| 926 | ofts->ofts_match_path_fts_entcxx . . $ $anonymous_type_ebdee0feb58b991e_0#ofts_match_path_fts_ent. = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!; |
| 927 | break; |
| 928 | } |
| 929 | |
| 930 | /* initialize separate fts for recursion */ |
| 931 | if (ofts->ofts_recurse_path_ftscxx . . $ $anonymous_type_ebdee0feb58b991e_0#ofts_recurse_path_fts. == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) { |
| 932 | char * const paths[2] = { ofts->ofts_match_path_fts_entcxx . . $ $anonymous_type_ebdee0feb58b991e_0#ofts_match_path_fts_ent.->fts_pathcxx . . $ _ftsent#fts_path., NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`! }; |
| 933 | |
| 934 | #if defined(OSCAP_FTS_DEBUG) |
| 935 | dD("fts_open args: path: \"%s\", options: %d.", |
| 936 | paths[0], ofts->ofts_recurse_path_fts_opts); |
| 937 | #endif |
| 938 | /* reset errno as fts_open() doesn't do it itself. */ |
| 939 | errnocxx . . $ `<external>/17633486526465735210/errno.h:38:10`! = 0; |
| 940 | ofts->ofts_recurse_path_ftscxx . . $ $anonymous_type_ebdee0feb58b991e_0#ofts_recurse_path_fts. = fts_opencxx . . $ fts_open(9139013e252a7d42).(paths, |
| 941 | ofts->ofts_recurse_path_fts_optscxx . . $ $anonymous_type_ebdee0feb58b991e_0#ofts_recurse_path_fts_opts., NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!); |
| 942 | /* fts_open() doesn't return NULL for all errors |
| 943 | (e.g. nonexistent paths), so check errno to detect it. |
| 944 | Far from being perfect. */ |
| 945 | if (ofts->ofts_recurse_path_ftscxx . . $ $anonymous_type_ebdee0feb58b991e_0#ofts_recurse_path_fts. == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`! || errnocxx . . $ `<external>/17633486526465735210/errno.h:38:10`! != 0) { |
| 946 | dEcxx . . $ `src/common/debug_priv.h:63:9`!("fts_open() failed, errno: %d \"%s\".", |
| 947 | errnocxx . . $ `<external>/17633486526465735210/errno.h:38:10`!, strerror(errnocxx . . $ `<external>/17633486526465735210/errno.h:38:10`!)); |
| 948 | #if !defined(OSCAP_FTS_DEBUG) |
| 949 | dEcxx . . $ `src/common/debug_priv.h:63:9`!("fts_open args: path: \"%s\", options: %d.", |
| 950 | paths[0], ofts->ofts_recurse_path_fts_opts); |
| 951 | #endif |
| 952 | if (ofts->ofts_recurse_path_ftscxx . . $ $anonymous_type_ebdee0feb58b991e_0#ofts_recurse_path_fts. != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) { |
| 953 | fts_closecxx . . $ fts_close(465f0e4c9e45e83).(ofts->ofts_recurse_path_ftscxx . . $ $anonymous_type_ebdee0feb58b991e_0#ofts_recurse_path_fts.); |
| 954 | ofts->ofts_recurse_path_ftscxx . . $ $anonymous_type_ebdee0feb58b991e_0#ofts_recurse_path_fts. = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!; |
| 955 | } |
| 956 | return (NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!); |
| 957 | } |
| 958 | } |
| 959 | |
| 960 | /* iterate until a match is found or all elements have been traversed */ |
| 961 | while (out_fts_ent == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) { |
| 962 | FTSENTcxx . . $ FTSENT# *fts_ent; |
| 963 | |
| 964 | fts_ent = fts_readcxx . . $ fts_read(a5ee146c26ffa24d).(ofts->ofts_recurse_path_ftscxx . . $ $anonymous_type_ebdee0feb58b991e_0#ofts_recurse_path_fts.); |
| 965 | if (fts_ent == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) { |
| 966 | fts_closecxx . . $ fts_close(465f0e4c9e45e83).(ofts->ofts_recurse_path_ftscxx . . $ $anonymous_type_ebdee0feb58b991e_0#ofts_recurse_path_fts.); |
| 967 | ofts->ofts_recurse_path_ftscxx . . $ $anonymous_type_ebdee0feb58b991e_0#ofts_recurse_path_fts. = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!; |
| 968 | |
| 969 | return NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!; |
| 970 | } |
| 971 | |
| 972 | switch (fts_ent->fts_infocxx . . $ _ftsent#fts_info.) { |
| 973 | case FTS_DPcxx . . $ `<external>/345209348829246610/fts.h:124:9`!: |
| 974 | continue; |
| 975 | case FTS_DCcxx . . $ `<external>/345209348829246610/fts.h:120:9`!: |
| 976 | dWcxx . . $ `src/common/debug_priv.h:62:9`!("Filesystem tree cycle detected at '%s'.", fts_ent->fts_path); |
| 977 | fts_setcxx . . $ fts_set(f293ebff43d3d282).(ofts->ofts_recurse_path_ftscxx . . $ $anonymous_type_ebdee0feb58b991e_0#ofts_recurse_path_fts., fts_ent, FTS_SKIPcxx . . $ `<external>/345209348829246610/fts.h:142:9`!); |
| 978 | continue; |
| 979 | } |
| 980 | |
| 981 | #if defined(OSCAP_FTS_DEBUG) |
| 982 | dD("fts_path: '%s' (l=%d)." |
| 983 | "fts_name: '%s' (l=%d).\n" |
| 984 | "fts_info: %u.\n", fts_ent->fts_path, fts_ent->fts_pathlen, |
| 985 | fts_ent->fts_name, fts_ent->fts_namelen, fts_ent->fts_info); |
| 986 | #endif |
| 987 | |
| 988 | /* collect matching target */ |
| 989 | if (collect_dirs) { |
| 990 | if (fts_ent->fts_infocxx . . $ _ftsent#fts_info. == FTS_Dcxx . . $ `<external>/345209348829246610/fts.h:119:9`! |
| 991 | && (ofts->max_depthcxx . . $ $anonymous_type_ebdee0feb58b991e_0#max_depth. == -1 || fts_ent->fts_levelcxx . . $ _ftsent#fts_level. <= ofts->max_depthcxx . . $ $anonymous_type_ebdee0feb58b991e_0#max_depth.)) |
| 992 | out_fts_ent = fts_ent; |
| 993 | } else { |
| 994 | if (fts_ent->fts_infocxx . . $ _ftsent#fts_info. != FTS_Dcxx . . $ `<external>/345209348829246610/fts.h:119:9`!) { |
| 995 | SEXP_tcxx . . $ SEXP_t# *stmp; |
| 996 | |
| 997 | stmp = SEXP_string_newfcxx . . $ SEXP_string_newf(b2137ed863725962).("%s", fts_ent->fts_namecxx . . $ _ftsent#fts_name.); |
| 998 | oval_result_tcxx . . $ oval_result_t# result = probe_entobj_cmpcxx . . $ probe_entobj_cmp(e245451a1311e799).(ofts->ofts_sfilenamecxx . . $ $anonymous_type_ebdee0feb58b991e_0#ofts_sfilename., stmp); |
| 999 | switch (result){ |
| 1000 | case OVAL_RESULT_TRUEcxx . . $ OVAL_RESULT_TRUE.: |
| 1001 | out_fts_ent = fts_ent; |
| 1002 | break; |
| 1003 | |
| 1004 | case OVAL_RESULT_ERRORcxx . . $ OVAL_RESULT_ERROR.: |
| 1005 | probe_cobj_set_flagcxx . . $ probe_cobj_set_flag(644bab5dffe689c).(ofts->resultcxx . . $ $anonymous_type_ebdee0feb58b991e_0#result., SYSCHAR_FLAG_ERRORcxx . . $ SYSCHAR_FLAG_ERROR.); |
| 1006 | break; |
| 1007 | |
| 1008 | default: |
| 1009 | break; |
| 1010 | } |
| 1011 | |
| 1012 | SEXP_freecxx . . $ SEXP_free(c6b28547479798f4).(stmp); |
| 1013 | } |
| 1014 | } |
| 1015 | |
| 1016 | if (fts_ent->fts_levelcxx . . $ _ftsent#fts_level. > 0) { /* don't skip fts root */ |
| 1017 | /* limit recursion depth */ |
| 1018 | if (ofts->directioncxx . . $ $anonymous_type_ebdee0feb58b991e_0#direction. == OVAL_RECURSE_DIRECTION_NONEcxx . . $ `src/OVAL/probes/oval_fts.h:99:9`! |
| 1019 | || (ofts->max_depthcxx . . $ $anonymous_type_ebdee0feb58b991e_0#max_depth. != -1 && fts_ent->fts_levelcxx . . $ _ftsent#fts_level. > ofts->max_depthcxx . . $ $anonymous_type_ebdee0feb58b991e_0#max_depth.)) { |
| 1020 | fts_setcxx . . $ fts_set(f293ebff43d3d282).(ofts->ofts_recurse_path_ftscxx . . $ $anonymous_type_ebdee0feb58b991e_0#ofts_recurse_path_fts., fts_ent, FTS_SKIPcxx . . $ `<external>/345209348829246610/fts.h:142:9`!); |
| 1021 | continue; |
| 1022 | } |
| 1023 | |
| 1024 | /* limit recursion only to selected file types */ |
| 1025 | switch (fts_ent->fts_infocxx . . $ _ftsent#fts_info.) { |
| 1026 | case FTS_Dcxx . . $ `<external>/345209348829246610/fts.h:119:9`!: |
| 1027 | if (!(ofts->recursecxx . . $ $anonymous_type_ebdee0feb58b991e_0#recurse. & OVAL_RECURSE_DIRScxx . . $ `src/OVAL/probes/oval_fts.h:104:9`!) && !(ofts->recursecxx . . $ $anonymous_type_ebdee0feb58b991e_0#recurse. & OVAL_RECURSE_SYMLINKScxx . . $ `src/OVAL/probes/oval_fts.h:105:9`! && ofts->followingcxx . . $ $anonymous_type_ebdee0feb58b991e_0#following.)) { |
| 1028 | fts_setcxx . . $ fts_set(f293ebff43d3d282).(ofts->ofts_recurse_path_ftscxx . . $ $anonymous_type_ebdee0feb58b991e_0#ofts_recurse_path_fts., fts_ent, FTS_SKIPcxx . . $ `<external>/345209348829246610/fts.h:142:9`!); |
| 1029 | continue; |
| 1030 | } |
| 1031 | ofts->followingcxx . . $ $anonymous_type_ebdee0feb58b991e_0#following. = 0; |
| 1032 | break; |
| 1033 | case FTS_SLcxx . . $ `<external>/345209348829246610/fts.h:130:9`!: |
| 1034 | if (!(ofts->recursecxx . . $ $anonymous_type_ebdee0feb58b991e_0#recurse. & OVAL_RECURSE_SYMLINKScxx . . $ `src/OVAL/probes/oval_fts.h:105:9`!)) { |
| 1035 | fts_setcxx . . $ fts_set(f293ebff43d3d282).(ofts->ofts_recurse_path_ftscxx . . $ $anonymous_type_ebdee0feb58b991e_0#ofts_recurse_path_fts., fts_ent, FTS_SKIPcxx . . $ `<external>/345209348829246610/fts.h:142:9`!); |
| 1036 | continue; |
| 1037 | } |
| 1038 | fts_setcxx . . $ fts_set(f293ebff43d3d282).(ofts->ofts_recurse_path_ftscxx . . $ $anonymous_type_ebdee0feb58b991e_0#ofts_recurse_path_fts., fts_ent, FTS_FOLLOWcxx . . $ `<external>/345209348829246610/fts.h:140:9`!); |
| 1039 | ofts->followingcxx . . $ $anonymous_type_ebdee0feb58b991e_0#following. = 1; |
| 1040 | break; |
| 1041 | default: |
| 1042 | continue; |
| 1043 | } |
| 1044 | } |
| 1045 | if (_oval_fts_is_localcxx . . $ _oval_fts_is_local(773508e850f37605).(ofts, fts_ent)) { |
| 1046 | fts_setcxx . . $ fts_set(f293ebff43d3d282).(ofts->ofts_recurse_path_ftscxx . . $ $anonymous_type_ebdee0feb58b991e_0#ofts_recurse_path_fts., fts_ent, FTS_SKIPcxx . . $ `<external>/345209348829246610/fts.h:142:9`!); |
| 1047 | continue; |
| 1048 | } |
| 1049 | /* don't recurse beyond the initial filesystem */ |
| 1050 | if (ofts->filesystemcxx . . $ $anonymous_type_ebdee0feb58b991e_0#filesystem. == OVAL_RECURSE_FS_DEFINEDcxx . . $ `src/OVAL/probes/oval_fts.h:111:9`! |
| 1051 | && (fts_ent->fts_infocxx . . $ _ftsent#fts_info. == FTS_Dcxx . . $ `<external>/345209348829246610/fts.h:119:9`! || fts_ent->fts_infocxx . . $ _ftsent#fts_info. == FTS_SLcxx . . $ `<external>/345209348829246610/fts.h:130:9`!) |
| 1052 | && ofts->ofts_recurse_path_devidcxx . . $ $anonymous_type_ebdee0feb58b991e_0#ofts_recurse_path_devid. != fts_ent->fts_statpcxx . . $ _ftsent#fts_statp.->st_devcxx . . $ stat#st_dev.) { |
| 1053 | fts_setcxx . . $ fts_set(f293ebff43d3d282).(ofts->ofts_recurse_path_ftscxx . . $ $anonymous_type_ebdee0feb58b991e_0#ofts_recurse_path_fts., fts_ent, FTS_SKIPcxx . . $ `<external>/345209348829246610/fts.h:142:9`!); |
| 1054 | continue; |
| 1055 | } |
| 1056 | } |
| 1057 | |
| 1058 | break; |
| 1059 | case OVAL_RECURSE_DIRECTION_UPcxx . . $ `src/OVAL/probes/oval_fts.h:101:9`!: |
| 1060 | if (ofts->ofts_recurse_path_pthcpycxx . . $ $anonymous_type_ebdee0feb58b991e_0#ofts_recurse_path_pthcpy. == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) { |
| 1061 | ofts->ofts_recurse_path_pthcpycxx . . $ $anonymous_type_ebdee0feb58b991e_0#ofts_recurse_path_pthcpy. = \ |
| 1062 | ofts->ofts_recurse_path_curpthcxx . . $ $anonymous_type_ebdee0feb58b991e_0#ofts_recurse_path_curpth. = strdupcxx . . $ strdup(a8b8e32347182212).(ofts->ofts_match_path_fts_entcxx . . $ $anonymous_type_ebdee0feb58b991e_0#ofts_match_path_fts_ent.->fts_pathcxx . . $ _ftsent#fts_path.); |
| 1063 | ofts->ofts_recurse_path_curdepthcxx . . $ $anonymous_type_ebdee0feb58b991e_0#ofts_recurse_path_curdepth. = 0; |
| 1064 | } |
| 1065 | |
| 1066 | while (ofts->max_depthcxx . . $ $anonymous_type_ebdee0feb58b991e_0#max_depth. == -1 || ofts->ofts_recurse_path_curdepthcxx . . $ $anonymous_type_ebdee0feb58b991e_0#ofts_recurse_path_curdepth. <= ofts->max_depthcxx . . $ $anonymous_type_ebdee0feb58b991e_0#max_depth.) { |
| 1067 | /* initialize separate fts for recursion */ |
| 1068 | if (ofts->ofts_recurse_path_ftscxx . . $ $anonymous_type_ebdee0feb58b991e_0#ofts_recurse_path_fts. == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) { |
| 1069 | char * const paths[2] = { ofts->ofts_recurse_path_curpthcxx . . $ $anonymous_type_ebdee0feb58b991e_0#ofts_recurse_path_curpth., NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`! }; |
| 1070 | |
| 1071 | #if defined(OSCAP_FTS_DEBUG) |
| 1072 | dD("fts_open args: path: \"%s\", options: %d.", |
| 1073 | paths[0], ofts->ofts_recurse_path_fts_opts); |
| 1074 | #endif |
| 1075 | /* reset errno as fts_open() doesn't do it itself. */ |
| 1076 | errnocxx . . $ `<external>/17633486526465735210/errno.h:38:10`! = 0; |
| 1077 | /* fts_open() doesn't return NULL for all errors |
| 1078 | (e.g. nonexistent paths), so check errno to |
| 1079 | detect it. Far from being perfect. */ |
| 1080 | ofts->ofts_recurse_path_ftscxx . . $ $anonymous_type_ebdee0feb58b991e_0#ofts_recurse_path_fts. = fts_opencxx . . $ fts_open(9139013e252a7d42).(paths, |
| 1081 | ofts->ofts_recurse_path_fts_optscxx . . $ $anonymous_type_ebdee0feb58b991e_0#ofts_recurse_path_fts_opts., NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!); |
| 1082 | if (ofts->ofts_recurse_path_ftscxx . . $ $anonymous_type_ebdee0feb58b991e_0#ofts_recurse_path_fts. == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`! || errnocxx . . $ `<external>/17633486526465735210/errno.h:38:10`! != 0) { |
| 1083 | dEcxx . . $ `src/common/debug_priv.h:63:9`!("fts_open() failed, errno: %d \"%s\".", |
| 1084 | errnocxx . . $ `<external>/17633486526465735210/errno.h:38:10`!, strerror(errnocxx . . $ `<external>/17633486526465735210/errno.h:38:10`!)); |
| 1085 | #if !defined(OSCAP_FTS_DEBUG) |
| 1086 | dEcxx . . $ `src/common/debug_priv.h:63:9`!("fts_open args: path: \"%s\", options: %d.", |
| 1087 | paths[0], ofts->ofts_recurse_path_fts_opts); |
| 1088 | #endif |
| 1089 | if (ofts->ofts_recurse_path_ftscxx . . $ $anonymous_type_ebdee0feb58b991e_0#ofts_recurse_path_fts. != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) { |
| 1090 | fts_closecxx . . $ fts_close(465f0e4c9e45e83).(ofts->ofts_recurse_path_ftscxx . . $ $anonymous_type_ebdee0feb58b991e_0#ofts_recurse_path_fts.); |
| 1091 | ofts->ofts_recurse_path_ftscxx . . $ $anonymous_type_ebdee0feb58b991e_0#ofts_recurse_path_fts. = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!; |
| 1092 | } |
| 1093 | return (NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!); |
| 1094 | } |
| 1095 | } |
| 1096 | |
| 1097 | /* iterate until a match is found or all elements have been traversed */ |
| 1098 | while (out_fts_ent == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) { |
| 1099 | FTSENTcxx . . $ FTSENT# *fts_ent; |
| 1100 | |
| 1101 | fts_ent = fts_readcxx . . $ fts_read(a5ee146c26ffa24d).(ofts->ofts_recurse_path_ftscxx . . $ $anonymous_type_ebdee0feb58b991e_0#ofts_recurse_path_fts.); |
| 1102 | if (fts_ent == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) |
| 1103 | break; |
| 1104 | |
| 1105 | /* |
| 1106 | it would be more accurate to obtain the device |
| 1107 | id here, but for the sake of supporting the |
| 1108 | comparison also in oval_fts_read_match_path(), |
| 1109 | the device id is obtained in oval_fts_open_prefixed() |
| 1110 | |
| 1111 | if (ofts->ofts_recurse_path_curdepth == 0) |
| 1112 | ofts->ofts_recurse_path_devid = fts_ent->fts_statp->st_dev; |
| 1113 | */ |
| 1114 | #if defined(OS_SOLARIS) |
| 1115 | if ((!OVAL_FTS_localp(ofts, fts_ent->fts_path, |
| 1116 | (fts_ent->fts_statp != NULL) ? |
| 1117 | &fts_ent->fts_statp->st_fstype : NULL))) |
| 1118 | break; |
| 1119 | #else |
| 1120 | if (ofts->filesystemcxx . . $ $anonymous_type_ebdee0feb58b991e_0#filesystem. == OVAL_RECURSE_FS_LOCALcxx . . $ `src/OVAL/probes/oval_fts.h:110:9`! |
| 1121 | && (!OVAL_FTS_localpcxx . . $ OVAL_FTS_localp(88198641f3bcbed).(ofts, fts_ent->fts_pathcxx . . $ _ftsent#fts_path., |
| 1122 | (fts_ent->fts_statpcxx . . $ _ftsent#fts_statp. != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) ? |
| 1123 | &fts_ent->fts_statpcxx . . $ _ftsent#fts_statp.->st_devcxx . . $ stat#st_dev. : NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!))) |
| 1124 | break; |
| 1125 | #endif |
| 1126 | if (ofts->filesystemcxx . . $ $anonymous_type_ebdee0feb58b991e_0#filesystem. == OVAL_RECURSE_FS_DEFINEDcxx . . $ `src/OVAL/probes/oval_fts.h:111:9`! |
| 1127 | && ofts->ofts_recurse_path_devidcxx . . $ $anonymous_type_ebdee0feb58b991e_0#ofts_recurse_path_devid. != fts_ent->fts_statpcxx . . $ _ftsent#fts_statp.->st_devcxx . . $ stat#st_dev.) |
| 1128 | break; |
| 1129 | |
| 1130 | /* collect matching target */ |
| 1131 | if (collect_dirs) { |
| 1132 | /* only fts root is collected */ |
| 1133 | if (fts_ent->fts_levelcxx . . $ _ftsent#fts_level. == 0 && fts_ent->fts_infocxx . . $ _ftsent#fts_info. == FTS_Dcxx . . $ `<external>/345209348829246610/fts.h:119:9`!) { |
| 1134 | out_fts_ent = fts_ent; |
| 1135 | fts_setcxx . . $ fts_set(f293ebff43d3d282).(ofts->ofts_recurse_path_ftscxx . . $ $anonymous_type_ebdee0feb58b991e_0#ofts_recurse_path_fts., fts_ent, FTS_SKIPcxx . . $ `<external>/345209348829246610/fts.h:142:9`!); |
| 1136 | break; |
| 1137 | } |
| 1138 | } else { |
| 1139 | if (fts_ent->fts_infocxx . . $ _ftsent#fts_info. != FTS_Dcxx . . $ `<external>/345209348829246610/fts.h:119:9`! && fts_ent->fts_infocxx . . $ _ftsent#fts_info. != FTS_DPcxx . . $ `<external>/345209348829246610/fts.h:124:9`! && fts_ent->fts_infocxx . . $ _ftsent#fts_info. != FTS_DCcxx . . $ `<external>/345209348829246610/fts.h:120:9`!) { |
| 1140 | SEXP_tcxx . . $ SEXP_t# *stmp; |
| 1141 | |
| 1142 | stmp = SEXP_string_newfcxx . . $ SEXP_string_newf(b2137ed863725962).("%s", fts_ent->fts_namecxx . . $ _ftsent#fts_name.); |
| 1143 | if (probe_entobj_cmpcxx . . $ probe_entobj_cmp(e245451a1311e799).(ofts->ofts_sfilenamecxx . . $ $anonymous_type_ebdee0feb58b991e_0#ofts_sfilename., stmp) == OVAL_RESULT_TRUEcxx . . $ OVAL_RESULT_TRUE.) |
| 1144 | out_fts_ent = fts_ent; |
| 1145 | SEXP_freecxx . . $ SEXP_free(c6b28547479798f4).(stmp); |
| 1146 | } |
| 1147 | } |
| 1148 | |
| 1149 | if (fts_ent->fts_infocxx . . $ _ftsent#fts_info. == FTS_SLcxx . . $ `<external>/345209348829246610/fts.h:130:9`!) |
| 1150 | fts_setcxx . . $ fts_set(f293ebff43d3d282).(ofts->ofts_recurse_path_ftscxx . . $ $anonymous_type_ebdee0feb58b991e_0#ofts_recurse_path_fts., fts_ent, FTS_FOLLOWcxx . . $ `<external>/345209348829246610/fts.h:140:9`!); |
| 1151 | /* limit recursion only to fts root */ |
| 1152 | else if (fts_ent->fts_levelcxx . . $ _ftsent#fts_level. > 0) |
| 1153 | fts_setcxx . . $ fts_set(f293ebff43d3d282).(ofts->ofts_recurse_path_ftscxx . . $ $anonymous_type_ebdee0feb58b991e_0#ofts_recurse_path_fts., fts_ent, FTS_SKIPcxx . . $ `<external>/345209348829246610/fts.h:142:9`!); |
| 1154 | } |
| 1155 | |
| 1156 | if (out_fts_ent != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) |
| 1157 | break; |
| 1158 | |
| 1159 | fts_closecxx . . $ fts_close(465f0e4c9e45e83).(ofts->ofts_recurse_path_ftscxx . . $ $anonymous_type_ebdee0feb58b991e_0#ofts_recurse_path_fts.); |
| 1160 | ofts->ofts_recurse_path_ftscxx . . $ $anonymous_type_ebdee0feb58b991e_0#ofts_recurse_path_fts. = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!; |
| 1161 | |
| 1162 | if (!strcmpcxx . . $ strcmp(5ae29d726ae57f88).(ofts->ofts_recurse_path_curpthcxx . . $ $anonymous_type_ebdee0feb58b991e_0#ofts_recurse_path_curpth., "/")) |
| 1163 | break; |
| 1164 | |
| 1165 | ofts->ofts_recurse_path_curpthcxx . . $ $anonymous_type_ebdee0feb58b991e_0#ofts_recurse_path_curpth. = oscap_dirnamecxx . . $ oscap_dirname(7a9722d75b371431).(ofts->ofts_recurse_path_curpthcxx . . $ $anonymous_type_ebdee0feb58b991e_0#ofts_recurse_path_curpth.); |
| 1166 | ofts->ofts_recurse_path_curdepthcxx . . $ $anonymous_type_ebdee0feb58b991e_0#ofts_recurse_path_curdepth.++; |
| 1167 | } |
| 1168 | |
| 1169 | if (out_fts_ent == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) { |
| 1170 | freecxx . . $ free(5d22bdacc48458e8).(ofts->ofts_recurse_path_pthcpycxx . . $ $anonymous_type_ebdee0feb58b991e_0#ofts_recurse_path_pthcpy.); |
| 1171 | ofts->ofts_recurse_path_pthcpycxx . . $ $anonymous_type_ebdee0feb58b991e_0#ofts_recurse_path_pthcpy. = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!; |
| 1172 | } |
| 1173 | |
| 1174 | break; |
| 1175 | } |
| 1176 | |
| 1177 | return out_fts_ent; |
| 1178 | } |
| 1179 | |
| 1180 | OVAL_FTSENTcxx . . $ OVAL_FTSENT# *oval_fts_readcxx . . $ oval_fts_read(592d87f37bbdbe51).(OVAL_FTScxx . . $ OVAL_FTS# *ofts) |
| 1181 | { |
| 1182 | FTSENTcxx . . $ FTSENT# *fts_ent; |
| 1183 | |
| 1184 | #if defined(OSCAP_FTS_DEBUG) |
| 1185 | dD("ofts: %p.", ofts); |
| 1186 | #endif |
| 1187 | |
| 1188 | if (ofts == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) |
| 1189 | return NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!; |
| 1190 | |
| 1191 | for (;;) { |
| 1192 | if (ofts->ofts_match_path_fts_entcxx . . $ $anonymous_type_ebdee0feb58b991e_0#ofts_match_path_fts_ent. == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) { |
| 1193 | ofts->ofts_match_path_fts_entcxx . . $ $anonymous_type_ebdee0feb58b991e_0#ofts_match_path_fts_ent. = oval_fts_read_match_pathcxx . . $ oval_fts_read_match_path(abab8876adc3df1a).(ofts); |
| 1194 | if (ofts->ofts_match_path_fts_entcxx . . $ $anonymous_type_ebdee0feb58b991e_0#ofts_match_path_fts_ent. == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) |
| 1195 | return NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!; |
| 1196 | } |
| 1197 | |
| 1198 | if (ofts->ofts_sfilepathcxx . . $ $anonymous_type_ebdee0feb58b991e_0#ofts_sfilepath.) { |
| 1199 | fts_ent = ofts->ofts_match_path_fts_entcxx . . $ $anonymous_type_ebdee0feb58b991e_0#ofts_match_path_fts_ent.; |
| 1200 | ofts->ofts_match_path_fts_entcxx . . $ $anonymous_type_ebdee0feb58b991e_0#ofts_match_path_fts_ent. = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!; |
| 1201 | if (ofts->filesystemcxx . . $ $anonymous_type_ebdee0feb58b991e_0#filesystem. == OVAL_RECURSE_FS_LOCALcxx . . $ `src/OVAL/probes/oval_fts.h:110:9`! |
| 1202 | && (!OVAL_FTS_localpcxx . . $ OVAL_FTS_localp(88198641f3bcbed).(ofts, fts_ent->fts_pathcxx . . $ _ftsent#fts_path., |
| 1203 | (fts_ent->fts_statpcxx . . $ _ftsent#fts_statp. != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) ? |
| 1204 | &fts_ent->fts_statpcxx . . $ _ftsent#fts_statp.->st_devcxx . . $ stat#st_dev. : NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!))) { |
| 1205 | continue; |
| 1206 | } |
| 1207 | break; |
| 1208 | } else { |
| 1209 | fts_ent = oval_fts_read_recurse_pathcxx . . $ oval_fts_read_recurse_path(abab8876adc3df1a).(ofts); |
| 1210 | if (fts_ent != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) |
| 1211 | break; |
| 1212 | |
| 1213 | ofts->ofts_match_path_fts_entcxx . . $ $anonymous_type_ebdee0feb58b991e_0#ofts_match_path_fts_ent. = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!; |
| 1214 | |
| 1215 | // todo: is this true when variables are used? |
| 1216 | /* with 'equals', there's only one potential target */ |
| 1217 | if (ofts->ofts_path_opcxx . . $ $anonymous_type_ebdee0feb58b991e_0#ofts_path_op. == OVAL_OPERATION_EQUALScxx . . $ OVAL_OPERATION_EQUALS.) |
| 1218 | return (NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!); |
| 1219 | } |
| 1220 | } |
| 1221 | |
| 1222 | return OVAL_FTSENT_newcxx . . $ OVAL_FTSENT_new(468998e9444d7313).(ofts, fts_ent); |
| 1223 | } |
| 1224 | |
| 1225 | void oval_ftsent_freecxx . . $ oval_ftsent_free(7e09326da17d8ab0).(OVAL_FTSENTcxx . . $ OVAL_FTSENT# *ofts_ent) |
| 1226 | { |
| 1227 | OVAL_FTSENT_freecxx . . $ OVAL_FTSENT_free(7e09326da17d8ab0).(ofts_ent); |
| 1228 | } |
| 1229 | |
| 1230 | int oval_fts_closecxx . . $ oval_fts_close(cd898f79c195c42c).(OVAL_FTScxx . . $ OVAL_FTS# *ofts) |
| 1231 | { |
| 1232 | if (ofts->ofts_recurse_path_pthcpycxx . . $ $anonymous_type_ebdee0feb58b991e_0#ofts_recurse_path_pthcpy. != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) |
| 1233 | freecxx . . $ free(5d22bdacc48458e8).(ofts->ofts_recurse_path_pthcpycxx . . $ $anonymous_type_ebdee0feb58b991e_0#ofts_recurse_path_pthcpy.); |
| 1234 | |
| 1235 | if (ofts->ofts_path_regexcxx . . $ $anonymous_type_ebdee0feb58b991e_0#ofts_path_regex.) |
| 1236 | oscap_pcre_freecxx . . $ oscap_pcre_free(804bb72472b0846e).(ofts->ofts_path_regexcxx . . $ $anonymous_type_ebdee0feb58b991e_0#ofts_path_regex.); |
| 1237 | |
| 1238 | if (ofts->ofts_spathcxx . . $ $anonymous_type_ebdee0feb58b991e_0#ofts_spath. != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) |
| 1239 | SEXP_freecxx . . $ SEXP_free(c6b28547479798f4).(ofts->ofts_spathcxx . . $ $anonymous_type_ebdee0feb58b991e_0#ofts_spath.); |
| 1240 | if (ofts->ofts_sfilenamecxx . . $ $anonymous_type_ebdee0feb58b991e_0#ofts_sfilename. != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) |
| 1241 | SEXP_freecxx . . $ SEXP_free(c6b28547479798f4).(ofts->ofts_sfilenamecxx . . $ $anonymous_type_ebdee0feb58b991e_0#ofts_sfilename.); |
| 1242 | if (ofts->ofts_sfilepathcxx . . $ $anonymous_type_ebdee0feb58b991e_0#ofts_sfilepath. != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) |
| 1243 | SEXP_freecxx . . $ SEXP_free(c6b28547479798f4).(ofts->ofts_sfilepathcxx . . $ $anonymous_type_ebdee0feb58b991e_0#ofts_sfilepath.); |
| 1244 | |
| 1245 | fsdev_freecxx . . $ fsdev_free(27e1c92ef469a2f9).(ofts->localdevscxx . . $ $anonymous_type_ebdee0feb58b991e_0#localdevs.); |
| 1246 | |
| 1247 | OVAL_FTS_freecxx . . $ OVAL_FTS_free(f2ac88db1829285e).(ofts); |
| 1248 | #if defined(OS_SOLARIS) |
| 1249 | free_zones_path_list(); |
| 1250 | #endif |
| 1251 | |
| 1252 | return (0); |
| 1253 | } |