| 1 | /** |
| 2 | * @file fileextendedattribute_probe.c |
| 3 | * @brief fileextendedattribute 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 "_seap.h"cxx . . $ `<file>/src/OVAL/probes/SEAP/_seap.h`/ |
| 35 | #include <probe-api.h>cxx . . $ `<file>/src/OVAL/probes/public/probe-api.h`/ |
| 36 | #include <stdlib.h> |
| 37 | #include <string.h> |
| 38 | #include <sys/stat.h> |
| 39 | #include <pthread.h> |
| 40 | #include <errno.h> |
| 41 | #include <limits.h> |
| 42 | |
| 43 | #include <sys/types.h> |
| 44 | #if defined(HAVE_SYS_XATTR_Hcxx . . $ `build/config.h:82:9`!) |
| 45 | # include <sys/xattr.h> |
| 46 | #elif defined(HAVE_ATTR_XATTR_H) |
| 47 | # include <attr/xattr.h> |
| 48 | #elif defined(HAVE_SYS_EXTATTR_H) |
| 49 | #include <sys/extattr.h> |
| 50 | #else |
| 51 | # error "This probe requires sys/xattr.h, attr/xattr.h, or sys/extattr.h, and none were found!" |
| 52 | #endif |
| 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 "probe/entcmp.h"cxx . . $ `<file>/src/OVAL/probes/probe/entcmp.h`/ |
| 57 | #include "oval_fts.h"cxx . . $ `<file>/src/OVAL/probes/oval_fts.h`/ |
| 58 | #include "common/debug_priv.h"cxx . . $ `<file>/src/common/debug_priv.h`/ |
| 59 | #include "fileextendedattribute_probe.h"cxx . . $ `<file>/src/OVAL/probes/unix/fileextendedattribute_probe.h`/ |
| 60 | |
| 61 | #ifndef PATH_MAXcxx . . $ `<external>/6347054901304145714/limits.h:13:9`! |
| 62 | #define PATH_MAX 4096 |
| 63 | #endif |
| 64 | |
| 65 | #ifdef OS_APPLE |
| 66 | #define llistxattr(path, buf, size) listxattr((path), (buf), (size), XATTR_NOFOLLOW) |
| 67 | #define lgetxattr(path, name, value, size) getxattr((path), (name), (value), (size), 0, XATTR_NOFOLLOW) |
| 68 | #define lsetxattr(path, name, value, size, flags) setxattr((path), (name), (value), (size), 0, (flags) | XATTR_NOFOLLOW) |
| 69 | #endif |
| 70 | |
| 71 | #define FILE_SEPARATORcxx . . $ `src/OVAL/probes/unix/fileextendedattribute_probe.c:71:9`! '/' |
| 72 | |
| 73 | struct cbargscxx . . $ cbargs# { |
| 74 | probe_ctxcxx . . $ probe_ctx# *ctxcxx . . $ cbargs#ctx.; |
| 75 | int errorcxx . . $ cbargs#error.; |
| 76 | SEXP_tcxx . . $ SEXP_t# *attr_entcxx . . $ cbargs#attr_ent.; |
| 77 | }; |
| 78 | |
| 79 | #if defined(OS_FREEBSD) |
| 80 | static int file_cb(const char *prefix, const char *p, const char *f, void *ptr, SEXP_t *gr_lastpath, struct oscap_list *blocked_paths) |
| 81 | { |
| 82 | char path_buffer[PATH_MAX]; |
| 83 | SEXP_t *item; |
| 84 | struct cbargs *args = (struct cbargs *) ptr; |
| 85 | const char *st_path; |
| 86 | |
| 87 | ssize_t byte_count = 0; |
| 88 | ssize_t index; |
| 89 | ssize_t value_len; |
| 90 | ssize_t name_len; |
| 91 | |
| 92 | char *xattr_list = malloc(LINE_MAX); |
| 93 | |
| 94 | if (!xattr_list) |
| 95 | return PROBE_ENOMEM; |
| 96 | |
| 97 | char *name_buf = NULL; |
| 98 | char *value_buf = NULL; |
| 99 | |
| 100 | if (f == NULL) { |
| 101 | st_path = p; |
| 102 | } else { |
| 103 | const size_t p_len = strlen(p); |
| 104 | /* Avoid 2 slashes */ |
| 105 | if (p_len >= 1 && p[p_len - 1] == FILE_SEPARATOR) { |
| 106 | snprintf(path_buffer, sizeof path_buffer, "%s%s", p, f); |
| 107 | } else { |
| 108 | snprintf(path_buffer, sizeof path_buffer, "%s%c%s", p, FILE_SEPARATOR, f); |
| 109 | } |
| 110 | st_path = path_buffer; |
| 111 | } |
| 112 | |
| 113 | if (probe_path_is_blocked(st_path, blocked_paths)) { |
| 114 | return 0; |
| 115 | } |
| 116 | |
| 117 | char *st_path_with_prefix = oscap_path_join(prefix, st_path); |
| 118 | |
| 119 | /* update lastpath if needed */ |
| 120 | if (!SEXP_emptyp(gr_lastpath)) { |
| 121 | if (SEXP_strcmp(gr_lastpath, p) != 0) { |
| 122 | SEXP_free_r(gr_lastpath); |
| 123 | SEXP_string_new_r(gr_lastpath, p, strlen(p)); |
| 124 | } |
| 125 | } else { |
| 126 | SEXP_string_new_r(gr_lastpath, p, strlen(p)); |
| 127 | } |
| 128 | |
| 129 | byte_count = extattr_list_file(st_path_with_prefix, EXTATTR_NAMESPACE_USER, xattr_list, LINE_MAX); |
| 130 | |
| 131 | if (byte_count < 0) { |
| 132 | dD("FAIL: extattr_list_file(%s, EXTATTR_NAMESPACE_USER, %p, %d), errno=%u, %s", st_path_with_prefix, xattr_list, LINE_MAX, errno, strerror(errno)); |
| 133 | free(st_path_with_prefix); |
| 134 | free(xattr_list); |
| 135 | return PROBE_EFATAL; |
| 136 | } |
| 137 | |
| 138 | index = 0; |
| 139 | |
| 140 | while (index < byte_count) { |
| 141 | name_len = xattr_list[index] + 1; |
| 142 | |
| 143 | /* We should be able to trust the output of extattr_list_file(), however |
| 144 | * let's be safe and ensure it doesn't try to read past the end of the array. |
| 145 | */ |
| 146 | if ((name_len < 1) || (name_len > byte_count - index - 1)) { |
| 147 | dD("FAIL: out of bounds name_len value: %d, at index: %d, in array of size: %d", name_len, index, byte_count); |
| 148 | free(st_path_with_prefix); |
| 149 | free(xattr_list); |
| 150 | return PROBE_EFAULT; |
| 151 | } |
| 152 | |
| 153 | name_buf = malloc(name_len); |
| 154 | value_buf = malloc(LINE_MAX); |
| 155 | |
| 156 | if ((name_buf == NULL) || (value_buf == NULL)) { |
| 157 | dD("FAIL: Could not allocate memory for xattr name and value buffers.\n"); |
| 158 | free(name_buf); |
| 159 | free(value_buf); |
| 160 | free(st_path_with_prefix); |
| 161 | free(xattr_list); |
| 162 | return PROBE_ENOMEM; |
| 163 | } |
| 164 | |
| 165 | snprintf(name_buf, name_len, "%s", xattr_list + index + 1); |
| 166 | |
| 167 | value_len = extattr_get_file(st_path_with_prefix, EXTATTR_NAMESPACE_USER, name_buf, value_buf, LINE_MAX); |
| 168 | |
| 169 | if (value_len < 0) { |
| 170 | free(name_buf); |
| 171 | free(value_buf); |
| 172 | free(st_path_with_prefix); |
| 173 | free(xattr_list); |
| 174 | return PROBE_EFATAL; |
| 175 | } |
| 176 | |
| 177 | value_buf[value_len] = '\0'; |
| 178 | |
| 179 | item = probe_item_create(OVAL_UNIX_FILEEXTENDEDATTRIBUTE, NULL, |
| 180 | "filepath", OVAL_DATATYPE_STRING, f == NULL ? NULL : st_path, |
| 181 | "path", OVAL_DATATYPE_SEXP, gr_lastpath, |
| 182 | "filename", OVAL_DATATYPE_STRING, f == NULL ? "" : f, |
| 183 | "attribute_name", OVAL_DATATYPE_STRING, name_buf, |
| 184 | "value", OVAL_DATATYPE_STRING, value_buf, |
| 185 | NULL); |
| 186 | |
| 187 | if (!item) { |
| 188 | dD("FAIL: Could not create new probe item.\n"); |
| 189 | free(name_buf); |
| 190 | free(value_buf); |
| 191 | free(st_path_with_prefix); |
| 192 | free(xattr_list); |
| 193 | return PROBE_EFATAL; |
| 194 | } |
| 195 | |
| 196 | probe_item_collect(args->ctx, item); |
| 197 | |
| 198 | free(name_buf); |
| 199 | free(value_buf); |
| 200 | name_buf = NULL; |
| 201 | value_buf = NULL; |
| 202 | |
| 203 | index += name_len; |
| 204 | } |
| 205 | |
| 206 | free(xattr_list); |
| 207 | free(st_path_with_prefix); |
| 208 | return 0; |
| 209 | } |
| 210 | |
| 211 | #else |
| 212 | static int file_cbcxx . . $ file_cb(382ee9f6a53310ee).(const char *prefix, const char *p, const char *f, void *ptr, SEXP_tcxx . . $ SEXP_t# *gr_lastpath, struct oscap_listcxx . . $ oscap_list# *blocked_paths) |
| 213 | { |
| 214 | char path_buffer[PATH_MAXcxx . . $ `<external>/6347054901304145714/limits.h:13:9`!]; |
| 215 | SEXP_tcxx . . $ SEXP_t# *item, xattr_name; |
| 216 | struct cbargscxx . . $ cbargs# *args = (struct cbargscxx . . $ cbargs# *) ptr; |
| 217 | const char *st_path; |
| 218 | |
| 219 | ssize_tcxx . . $ ssize_t# xattr_count = -1; |
| 220 | char *xattr_buf = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!; |
| 221 | size_t xattr_buflen = 0, i; |
| 222 | |
| 223 | if (f == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) { |
| 224 | st_path = p; |
| 225 | } else { |
| 226 | const size_t p_len = strlencxx . . $ strlen(751346f8406fd082).(p); |
| 227 | /* Avoid 2 slashes */ |
| 228 | if (p_len >= 1 && p[p_len - 1] == FILE_SEPARATORcxx . . $ `src/OVAL/probes/unix/fileextendedattribute_probe.c:71:9`!) { |
| 229 | snprintfcxx . . $ snprintf(ea502d73e74c754c).(path_buffer, sizeof path_buffer, "%s%s", p, f); |
| 230 | } else { |
| 231 | snprintfcxx . . $ snprintf(ea502d73e74c754c).(path_buffer, sizeof path_buffer, "%s%c%s", p, FILE_SEPARATORcxx . . $ `src/OVAL/probes/unix/fileextendedattribute_probe.c:71:9`!, f); |
| 232 | } |
| 233 | st_path = path_buffer; |
| 234 | } |
| 235 | |
| 236 | SEXP_initcxx . . $ SEXP_init(478b347fcbbad3c5).(&xattr_name); |
| 237 | |
| 238 | if (probe_path_is_blockedcxx . . $ probe_path_is_blocked(6f786adec44f4a13).(st_path, blocked_paths)) { |
| 239 | return 0; |
| 240 | } |
| 241 | |
| 242 | char *st_path_with_prefix = oscap_path_joincxx . . $ oscap_path_join(a713fe7b9a57cf96).(prefix, st_path); |
| 243 | do { |
| 244 | /* estimate the size of the buffer */ |
| 245 | xattr_count = llistxattrcxx . . $ llistxattr(373c9bd46766ee5).(st_path_with_prefix, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!, 0); |
| 246 | |
| 247 | if (xattr_count == 0) { |
| 248 | goto exit; |
| 249 | } |
| 250 | |
| 251 | if (xattr_count < 0) { |
| 252 | dDcxx . . $ `src/common/debug_priv.h:64:9`!("FAIL: llistxattr(%s, %p, %zu): errno=%u, %s", st_path_with_prefix, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!, (size_t)0, errnocxx . . $ `<external>/17633486526465735210/errno.h:38:10`!, strerror(errnocxx . . $ `<external>/17633486526465735210/errno.h:38:10`!)); |
| 253 | goto exit; |
| 254 | } |
| 255 | |
| 256 | /* allocate space for xattr names */ |
| 257 | xattr_buflen = xattr_count; |
| 258 | void *new_xattr_buf = realloccxx . . $ realloc(417ab160f6baadc6).(xattr_buf, sizeof(char) * xattr_buflen); |
| 259 | if (new_xattr_buf == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) { |
| 260 | dEcxx . . $ `src/common/debug_priv.h:63:9`!("Failed to re-allocate memory for xattr_buf"); |
| 261 | goto exit; |
| 262 | } |
| 263 | xattr_buf = new_xattr_buf; |
| 264 | |
| 265 | /* fill the buffer */ |
| 266 | xattr_count = llistxattrcxx . . $ llistxattr(373c9bd46766ee5).(st_path_with_prefix, xattr_buf, xattr_buflen); |
| 267 | |
| 268 | /* check & retry if needed */ |
| 269 | } while (errnocxx . . $ `<external>/17633486526465735210/errno.h:38:10`! == ERANGEcxx . . $ `<external>/8987895939074593727/errno-base.h:38:9`!); |
| 270 | |
| 271 | if (xattr_count < 0) { |
| 272 | dDcxx . . $ `src/common/debug_priv.h:64:9`!("FAIL: llistxattr(%s, %p, %zu): errno=%u, %s", st_path_with_prefix, xattr_buf, xattr_buflen, errnocxx . . $ `<external>/17633486526465735210/errno.h:38:10`!, strerror(errnocxx . . $ `<external>/17633486526465735210/errno.h:38:10`!)); |
| 273 | freecxx . . $ free(5d22bdacc48458e8).(st_path_with_prefix); |
| 274 | freecxx . . $ free(5d22bdacc48458e8).(xattr_buf); |
| 275 | return 0; |
| 276 | } |
| 277 | |
| 278 | /* update lastpath if needed */ |
| 279 | if (!SEXP_emptypcxx . . $ SEXP_emptyp(48c7cf01dfc2748d).(gr_lastpath)) { |
| 280 | if (SEXP_strcmpcxx . . $ SEXP_strcmp(3ef1a37bcb3c2a).(gr_lastpath, p) != 0) { |
| 281 | SEXP_free_rcxx . . $ SEXP_free_r(c6b28547479798f4).(gr_lastpath); |
| 282 | SEXP_string_new_rcxx . . $ SEXP_string_new_r(26dc94eb5d76b6d1).(gr_lastpath, p, strlencxx . . $ strlen(751346f8406fd082).(p)); |
| 283 | } |
| 284 | } else { |
| 285 | SEXP_string_new_rcxx . . $ SEXP_string_new_r(26dc94eb5d76b6d1).(gr_lastpath, p, strlencxx . . $ strlen(751346f8406fd082).(p)); |
| 286 | } |
| 287 | |
| 288 | i = 0; |
| 289 | /* collect */ |
| 290 | do { |
| 291 | SEXP_string_new_rcxx . . $ SEXP_string_new_r(26dc94eb5d76b6d1).(&xattr_name, xattr_buf + i, strlencxx . . $ strlen(751346f8406fd082).(xattr_buf +i)); |
| 292 | |
| 293 | if (probe_entobj_cmpcxx . . $ probe_entobj_cmp(e245451a1311e799).(args->attr_entcxx . . $ cbargs#attr_ent., &xattr_name) == OVAL_RESULT_TRUEcxx . . $ OVAL_RESULT_TRUE.) { |
| 294 | ssize_tcxx . . $ ssize_t# xattr_vallen = -1; |
| 295 | char *xattr_val = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!; |
| 296 | |
| 297 | xattr_vallen = lgetxattrcxx . . $ lgetxattr(5c9b75d0c348a03).(st_path_with_prefix, xattr_buf + i, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!, 0); |
| 298 | retry_value: |
| 299 | if (xattr_vallen >= 0) { |
| 300 | // Check possible buffer overflow |
| 301 | if (sizeof(char) * (xattr_vallen + 1) <= sizeof(char) * xattr_vallen) { |
| 302 | dEcxx . . $ `src/common/debug_priv.h:63:9`!("Attribute is too long."); |
| 303 | freecxx . . $ free(5d22bdacc48458e8).(xattr_val); |
| 304 | goto exit; |
| 305 | } |
| 306 | |
| 307 | // Allocate buffer, '+1' is for trailing '\0' |
| 308 | void *new_xattr_val = realloccxx . . $ realloc(417ab160f6baadc6).(xattr_val, sizeof(char) * (xattr_vallen + 1)); |
| 309 | if (new_xattr_val == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) { |
| 310 | dEcxx . . $ `src/common/debug_priv.h:63:9`!("Failed to allocate memory for xattr_val"); |
| 311 | freecxx . . $ free(5d22bdacc48458e8).(xattr_val); |
| 312 | goto exit; |
| 313 | } |
| 314 | xattr_val = new_xattr_val; |
| 315 | |
| 316 | // we don't want to override space for '\0' by call of 'lgetxattr' |
| 317 | // we pass only 'xattr_vallen' instead of 'xattr_vallen + 1' |
| 318 | xattr_vallen = lgetxattrcxx . . $ lgetxattr(5c9b75d0c348a03).(st_path_with_prefix, xattr_buf + i, xattr_val, xattr_vallen); |
| 319 | |
| 320 | if (xattr_vallen < 0 || errnocxx . . $ `<external>/17633486526465735210/errno.h:38:10`! == ERANGEcxx . . $ `<external>/8987895939074593727/errno-base.h:38:9`!) |
| 321 | goto retry_value; |
| 322 | |
| 323 | xattr_val[xattr_vallen] = '\0'; |
| 324 | |
| 325 | item = probe_item_createcxx . . $ probe_item_create(36b16a6622050a9c).(OVAL_UNIX_FILEEXTENDEDATTRIBUTEcxx . . $ OVAL_UNIX_FILEEXTENDEDATTRIBUTE., NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!, |
| 326 | "filepath", OVAL_DATATYPE_STRINGcxx . . $ OVAL_DATATYPE_STRING., f == 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`! : st_path, |
| 327 | "path", OVAL_DATATYPE_SEXPcxx . . $ OVAL_DATATYPE_SEXP., gr_lastpath, |
| 328 | "filename", OVAL_DATATYPE_STRINGcxx . . $ OVAL_DATATYPE_STRING., f == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`! ? "" : f, |
| 329 | "attribute_name", OVAL_DATATYPE_SEXPcxx . . $ OVAL_DATATYPE_SEXP., &xattr_name, |
| 330 | "value", OVAL_DATATYPE_STRINGcxx . . $ OVAL_DATATYPE_STRING., xattr_val, |
| 331 | NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!); |
| 332 | |
| 333 | freecxx . . $ free(5d22bdacc48458e8).(xattr_val); |
| 334 | } else { |
| 335 | dDcxx . . $ `src/common/debug_priv.h:64:9`!("FAIL: lgetxattr(%s, %s, NULL, 0): errno=%u, %s", st_path_with_prefix, xattr_buf + i, errnocxx . . $ `<external>/17633486526465735210/errno.h:38:10`!, strerror(errnocxx . . $ `<external>/17633486526465735210/errno.h:38:10`!)); |
| 336 | |
| 337 | item = probe_item_createcxx . . $ probe_item_create(36b16a6622050a9c).(OVAL_UNIX_FILEEXTENDEDATTRIBUTEcxx . . $ OVAL_UNIX_FILEEXTENDEDATTRIBUTE., 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`!); |
| 338 | probe_item_setstatuscxx . . $ probe_item_setstatus(112b785eb420e6c0).(item, SYSCHAR_STATUS_ERRORcxx . . $ SYSCHAR_STATUS_ERROR.); |
| 339 | |
| 340 | if (xattr_val != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) |
| 341 | freecxx . . $ free(5d22bdacc48458e8).(xattr_val); |
| 342 | } |
| 343 | |
| 344 | probe_item_collectcxx . . $ probe_item_collect(11bb80e0c30650d7).(args->ctxcxx . . $ cbargs#ctx., item); /* XXX: handle ENOMEM */ |
| 345 | } |
| 346 | |
| 347 | SEXP_free_rcxx . . $ SEXP_free_r(c6b28547479798f4).(&xattr_name); |
| 348 | |
| 349 | /* skip to next name */ |
| 350 | while (i < xattr_buflen && xattr_buf[i] != '\0') |
| 351 | ++i; |
| 352 | ++i; |
| 353 | } while (xattr_buf + i < xattr_buf + xattr_buflen - 1); |
| 354 | |
| 355 | exit: |
| 356 | freecxx . . $ free(5d22bdacc48458e8).(xattr_buf); |
| 357 | freecxx . . $ free(5d22bdacc48458e8).(st_path_with_prefix); |
| 358 | return 0; |
| 359 | } |
| 360 | #endif |
| 361 | |
| 362 | int fileextendedattribute_probe_offline_mode_supportedcxx . . $ fileextendedattribute_probe_offline_mode_supported(b126dc7c1de90089).() |
| 363 | { |
| 364 | return PROBE_OFFLINE_OWNcxx . . $ PROBE_OFFLINE_OWN.; |
| 365 | } |
| 366 | |
| 367 | void *fileextendedattribute_probe_initcxx . . $ fileextendedattribute_probe_init(50c7df7de5344ebb).(void) |
| 368 | { |
| 369 | /* |
| 370 | * Initialize mutex. |
| 371 | */ |
| 372 | pthread_mutex_tcxx . . $ pthread_mutex_t# *mutex = malloccxx . . $ malloc(bfcfa4d6b7f7ef64).(sizeof(pthread_mutex_tcxx . . $ pthread_mutex_t#)); |
| 373 | switch (pthread_mutex_initcxx . . $ pthread_mutex_init(db9d29dab44ea1aa).(mutex, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!)) { |
| 374 | case 0: |
| 375 | return (void *)mutex; |
| 376 | default: |
| 377 | dDcxx . . $ `src/common/debug_priv.h:64:9`!("Can't initialize mutex: errno=%u, %s.", errnocxx . . $ `<external>/17633486526465735210/errno.h:38:10`!, strerror(errnocxx . . $ `<external>/17633486526465735210/errno.h:38:10`!)); |
| 378 | freecxx . . $ free(5d22bdacc48458e8).(mutex); |
| 379 | } |
| 380 | #if 0 |
| 381 | probe_setoption(PROBEOPT_VARREF_HANDLING, false, "path"); |
| 382 | probe_setoption(PROBEOPT_VARREF_HANDLING, false, "filename"); |
| 383 | #endif |
| 384 | return NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!; |
| 385 | } |
| 386 | |
| 387 | void fileextendedattribute_probe_finicxx . . $ fileextendedattribute_probe_fini(5d22bdacc48458e8).(void *arg) |
| 388 | { |
| 389 | /* |
| 390 | * Destroy mutex. |
| 391 | */ |
| 392 | (void) pthread_mutex_destroycxx . . $ pthread_mutex_destroy(d89ae235521888f9).((pthread_mutex_tcxx . . $ pthread_mutex_t# *)arg); |
| 393 | freecxx . . $ free(5d22bdacc48458e8).(arg); |
| 394 | } |
| 395 | |
| 396 | int fileextendedattribute_probe_maincxx . . $ fileextendedattribute_probe_main(470536d3ffacaf10).(probe_ctxcxx . . $ probe_ctx# *ctx, void *mutex) |
| 397 | { |
| 398 | SEXP_tcxx . . $ SEXP_t# *path, *filename, *behaviors; |
| 399 | SEXP_tcxx . . $ SEXP_t# *filepath, *attribute_, *probe_in; |
| 400 | int err; |
| 401 | struct cbargscxx . . $ cbargs# cbargs; |
| 402 | OVAL_FTScxx . . $ OVAL_FTS# *ofts; |
| 403 | OVAL_FTSENTcxx . . $ OVAL_FTSENT# *ofts_ent; |
| 404 | SEXP_tcxx . . $ SEXP_t# gr_lastpath; |
| 405 | |
| 406 | if (mutex == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) |
| 407 | return PROBE_EINITcxx . . $ `src/OVAL/probes/public/probe-common.h:12:9`!; |
| 408 | |
| 409 | probe_in = probe_ctx_getobjectcxx . . $ probe_ctx_getobject(4299b6b53fa804a5).(ctx); |
| 410 | |
| 411 | path = probe_obj_getentcxx . . $ probe_obj_getent(7907a01f2ff841f3).(probe_in, "path", 1); |
| 412 | filename = probe_obj_getentcxx . . $ probe_obj_getent(7907a01f2ff841f3).(probe_in, "filename", 1); |
| 413 | behaviors = probe_obj_getentcxx . . $ probe_obj_getent(7907a01f2ff841f3).(probe_in, "behaviors", 1); |
| 414 | filepath = probe_obj_getentcxx . . $ probe_obj_getent(7907a01f2ff841f3).(probe_in, "filepath", 1); |
| 415 | attribute_ = probe_obj_getentcxx . . $ probe_obj_getent(7907a01f2ff841f3). (probe_in, "attribute_name", 1); |
| 416 | |
| 417 | /* we want either path+filename or filepath */ |
| 418 | 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`!) || attribute_ == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) |
| 419 | { |
| 420 | SEXP_freecxx . . $ SEXP_free(c6b28547479798f4).(behaviors); |
| 421 | SEXP_freecxx . . $ SEXP_free(c6b28547479798f4).(path); |
| 422 | SEXP_freecxx . . $ SEXP_free(c6b28547479798f4).(filename); |
| 423 | SEXP_freecxx . . $ SEXP_free(c6b28547479798f4).(filepath); |
| 424 | SEXP_freecxx . . $ SEXP_free(c6b28547479798f4).(attribute_); |
| 425 | return PROBE_ENOELMcxx . . $ `src/OVAL/probes/public/probe-common.h:9:9`!; |
| 426 | } |
| 427 | |
| 428 | probe_filebehaviors_canonicalizecxx . . $ probe_filebehaviors_canonicalize(e661f441b24a5de6).(&behaviors); |
| 429 | |
| 430 | switch (pthread_mutex_lockcxx . . $ pthread_mutex_lock(d89ae235521888f9).(mutex)) { |
| 431 | case 0: |
| 432 | break; |
| 433 | default: |
| 434 | dDcxx . . $ `src/common/debug_priv.h:64:9`!("Can't lock mutex(%p): %u, %s.", mutex, errnocxx . . $ `<external>/17633486526465735210/errno.h:38:10`!, strerror(errnocxx . . $ `<external>/17633486526465735210/errno.h:38:10`!)); |
| 435 | SEXP_freecxx . . $ SEXP_free(c6b28547479798f4).(path); |
| 436 | SEXP_freecxx . . $ SEXP_free(c6b28547479798f4).(filename); |
| 437 | SEXP_freecxx . . $ SEXP_free(c6b28547479798f4).(filepath); |
| 438 | SEXP_freecxx . . $ SEXP_free(c6b28547479798f4).(behaviors); |
| 439 | SEXP_freecxx . . $ SEXP_free(c6b28547479798f4).(attribute_); |
| 440 | return PROBE_EFATALcxx . . $ `src/OVAL/probes/public/probe-common.h:23:9`!; |
| 441 | } |
| 442 | |
| 443 | cbargs.ctxcxx . . $ cbargs#ctx. = ctx; |
| 444 | cbargs.errorcxx . . $ cbargs#error. = 0; |
| 445 | cbargs.attr_entcxx . . $ cbargs#attr_ent. = attribute_; |
| 446 | |
| 447 | const char *prefix = getenvcxx . . $ getenv(a8b8e32347182212).("OSCAP_PROBE_ROOT"); |
| 448 | SEXP_initcxx . . $ SEXP_init(478b347fcbbad3c5).(&gr_lastpath); |
| 449 | |
| 450 | if ((ofts = oval_fts_open_prefixedcxx . . $ oval_fts_open_prefixed(d2d91f0fe545c5d7).(prefix, path, filename, filepath, behaviors, probe_ctx_getresultcxx . . $ probe_ctx_getresult(4299b6b53fa804a5).(ctx))) != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) { |
| 451 | while ((ofts_ent = oval_fts_readcxx . . $ oval_fts_read(592d87f37bbdbe51).(ofts)) != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) { |
| 452 | file_cbcxx . . $ file_cb(382ee9f6a53310ee).(prefix, ofts_ent->pathcxx . . $ $anonymous_type_ebdee0feb58b991e_1#path., ofts_ent->filecxx . . $ $anonymous_type_ebdee0feb58b991e_1#file., &cbargs, &gr_lastpath, ctx->blocked_pathscxx . . $ probe_ctx#blocked_paths.); |
| 453 | oval_ftsent_freecxx . . $ oval_ftsent_free(7e09326da17d8ab0).(ofts_ent); |
| 454 | } |
| 455 | oval_fts_closecxx . . $ oval_fts_close(cd898f79c195c42c).(ofts); |
| 456 | } |
| 457 | |
| 458 | if (!SEXP_emptypcxx . . $ SEXP_emptyp(48c7cf01dfc2748d).(&gr_lastpath)) |
| 459 | SEXP_free_rcxx . . $ SEXP_free_r(c6b28547479798f4).(&gr_lastpath); |
| 460 | |
| 461 | err = 0; |
| 462 | |
| 463 | SEXP_freecxx . . $ SEXP_free(c6b28547479798f4).(path); |
| 464 | SEXP_freecxx . . $ SEXP_free(c6b28547479798f4).(filename); |
| 465 | SEXP_freecxx . . $ SEXP_free(c6b28547479798f4).(filepath); |
| 466 | SEXP_freecxx . . $ SEXP_free(c6b28547479798f4).(behaviors); |
| 467 | SEXP_freecxx . . $ SEXP_free(c6b28547479798f4).(attribute_); |
| 468 | |
| 469 | switch (pthread_mutex_unlockcxx . . $ pthread_mutex_unlock(d89ae235521888f9).(mutex)) { |
| 470 | case 0: |
| 471 | break; |
| 472 | default: |
| 473 | dDcxx . . $ `src/common/debug_priv.h:64:9`!("Can't unlock mutex(%p): %u, %s.", mutex, errnocxx . . $ `<external>/17633486526465735210/errno.h:38:10`!, strerror(errnocxx . . $ `<external>/17633486526465735210/errno.h:38:10`!)); |
| 474 | return PROBE_EFATALcxx . . $ `src/OVAL/probes/public/probe-common.h:23:9`!; |
| 475 | } |
| 476 | |
| 477 | return err; |
| 478 | } |