| 1 | /** |
| 2 | * @file selinuxsecuritycontext_probe.c |
| 3 | * @brief selinuxsecuritycontext probe |
| 4 | * @author "Petr Lautrbach" <[email protected]> |
| 5 | * |
| 6 | * 2011/07/01 [email protected] |
| 7 | * This probe is able to process a selinuxsecuritycontext_object as defined in OVAL 5.9 |
| 8 | * |
| 9 | */ |
| 10 | |
| 11 | /* |
| 12 | * Copyright 2011 Red Hat Inc., Durham, North Carolina. |
| 13 | * All Rights Reserved. |
| 14 | * |
| 15 | * This library is free software; you can redistribute it and/or |
| 16 | * modify it under the terms of the GNU Lesser General Public |
| 17 | * License as published by the Free Software Foundation; either |
| 18 | * version 2.1 of the License, or (at your option) any later version. |
| 19 | * |
| 20 | * This library is distributed in the hope that it will be useful, |
| 21 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 22 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 23 | * Lesser General Public License for more details. |
| 24 | * |
| 25 | * You should have received a copy of the GNU Lesser General Public |
| 26 | * License along with this library; if not, write to the Free Software |
| 27 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA |
| 28 | * |
| 29 | * Authors: |
| 30 | * "Petr Lautrbach" <[email protected]> |
| 31 | */ |
| 32 | |
| 33 | #ifdef HAVE_CONFIG_Hcxx . . $ `<built-in>:409:9`! |
| 34 | #include <config.h>cxx . . $ `<file>/build/config.h`/ |
| 35 | #endif |
| 36 | |
| 37 | #include "_seap.h"cxx . . $ `<file>/src/OVAL/probes/SEAP/_seap.h`/ |
| 38 | #include <probe-api.h>cxx . . $ `<file>/src/OVAL/probes/public/probe-api.h`/ |
| 39 | #include <probe/entcmp.h>cxx . . $ `<file>/src/OVAL/probes/probe/entcmp.h`/ |
| 40 | #include <stdlib.h> |
| 41 | #include <string.h> |
| 42 | #include <sys/types.h> |
| 43 | #include <sys/stat.h> |
| 44 | #include <fcntl.h> |
| 45 | #include <limits.h> |
| 46 | #include <pthread.h> |
| 47 | #include <dirent.h> |
| 48 | #include <errno.h> |
| 49 | |
| 50 | #include <selinux/selinux.h> |
| 51 | #include <selinux/context.h> |
| 52 | |
| 53 | #include "oval_fts.h"cxx . . $ `<file>/src/OVAL/probes/oval_fts.h`/ |
| 54 | #include "util.h"cxx . . $ `<file>/src/common/util.h`/ |
| 55 | #include "common/debug_priv.h"cxx . . $ `<file>/src/common/debug_priv.h`/ |
| 56 | #include "probe/probe.h"cxx . . $ `<file>/src/OVAL/probes/probe/probe.h`/ |
| 57 | #include "selinuxsecuritycontext_probe.h"cxx . . $ `<file>/src/OVAL/probes/unix/linux/selinuxsecuritycontext_probe.h`/ |
| 58 | |
| 59 | #define FILE_SEPARATORcxx . . $ `src/OVAL/probes/unix/linux/selinuxsecuritycontext_probe.c:59:9`! '/' |
| 60 | |
| 61 | static void split_levelcxx . . $ split_level(8de4e710b16159e6).(const char *level, char **sensitivity, char **category) { |
| 62 | char *level_split; |
| 63 | |
| 64 | level_split = strchrcxx . . $ strchr(2050848944e00d54).(level, ':'); |
| 65 | if (level_split == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) { |
| 66 | *sensitivity = strdupcxx . . $ strdup(a8b8e32347182212).(level); |
| 67 | *category = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!; |
| 68 | } |
| 69 | else { |
| 70 | *sensitivity = strndupcxx . . $ strndup(eabdfdef77619b3d).(level, level_split - level); |
| 71 | *category = strdupcxx . . $ strdup(a8b8e32347182212).(level_split + 1); |
| 72 | } |
| 73 | } |
| 74 | |
| 75 | /* parse range according to |
| 76 | * http://selinuxproject.org/page/NB_MLS#MLS_.2F_MCS_Range_Format |
| 77 | */ |
| 78 | static void split_rangecxx . . $ split_range(846b4948bf2883d2).(const char *range, char **l_s, char **l_c, char **h_s, char **h_c) { |
| 79 | char *level; |
| 80 | const char *range_split; |
| 81 | |
| 82 | if (range == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) { |
| 83 | dWcxx . . $ `src/common/debug_priv.h:62:9`!("%s: range is NULL", __func__); |
| 84 | *l_s = *l_c = *h_s = *h_c = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!; |
| 85 | return; |
| 86 | } |
| 87 | range_split = strchrcxx . . $ strchr(2050848944e00d54).(range, '-'); |
| 88 | if (range_split == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) { |
| 89 | /* there is only 1 level */ |
| 90 | split_levelcxx . . $ split_level(8de4e710b16159e6).(range, l_s, l_c); |
| 91 | *h_s = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!; |
| 92 | *h_c = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!; |
| 93 | } |
| 94 | else { |
| 95 | /* low level */ |
| 96 | level = strndupcxx . . $ strndup(eabdfdef77619b3d).(range, range_split - range); |
| 97 | split_levelcxx . . $ split_level(8de4e710b16159e6).(level, l_s, l_c); |
| 98 | freecxx . . $ free(5d22bdacc48458e8).(level); |
| 99 | |
| 100 | /* high level */ |
| 101 | level = strdupcxx . . $ strdup(a8b8e32347182212).(range_split + 1); |
| 102 | split_levelcxx . . $ split_level(8de4e710b16159e6).(level, h_s, h_c); |
| 103 | freecxx . . $ free(5d22bdacc48458e8).(level); |
| 104 | } |
| 105 | } |
| 106 | |
| 107 | static SEXP_tcxx . . $ SEXP_t# *create_process_probe_item_with_rangecxx . . $ create_process_probe_item_with_range(1094ad8316b00d6d).( |
| 108 | const char *range, const char *user, const char *role, const char *type, |
| 109 | int pid_number) { |
| 110 | char *l_sensitivity, *l_category, *h_sensitivity, *h_category; |
| 111 | SEXP_tcxx . . $ SEXP_t# *item; |
| 112 | |
| 113 | split_rangecxx . . $ split_range(846b4948bf2883d2).(range, &l_sensitivity, &l_category, &h_sensitivity, &h_category); |
| 114 | item = probe_item_createcxx . . $ probe_item_create(36b16a6622050a9c).(OVAL_LINUX_SELINUXSECURITYCONTEXTcxx . . $ OVAL_LINUX_SELINUXSECURITYCONTEXT., NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!, |
| 115 | "pid", OVAL_DATATYPE_INTEGERcxx . . $ OVAL_DATATYPE_INTEGER., (int64_tcxx . . $ int64_t#)pid_number, |
| 116 | |
| 117 | "user", OVAL_DATATYPE_STRINGcxx . . $ OVAL_DATATYPE_STRING., user, |
| 118 | "role", OVAL_DATATYPE_STRINGcxx . . $ OVAL_DATATYPE_STRING., role, |
| 119 | "type", OVAL_DATATYPE_STRINGcxx . . $ OVAL_DATATYPE_STRING., type, |
| 120 | "low_sensitivity", OVAL_DATATYPE_STRINGcxx . . $ OVAL_DATATYPE_STRING., l_sensitivity, |
| 121 | "low_category", OVAL_DATATYPE_STRINGcxx . . $ OVAL_DATATYPE_STRING., l_category, |
| 122 | "high_sensitivity", OVAL_DATATYPE_STRINGcxx . . $ OVAL_DATATYPE_STRING., h_sensitivity, |
| 123 | "high_category", OVAL_DATATYPE_STRINGcxx . . $ OVAL_DATATYPE_STRING., h_category, |
| 124 | NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!); |
| 125 | freecxx . . $ free(5d22bdacc48458e8).(l_sensitivity); |
| 126 | freecxx . . $ free(5d22bdacc48458e8).(l_category); |
| 127 | freecxx . . $ free(5d22bdacc48458e8).(h_sensitivity); |
| 128 | freecxx . . $ free(5d22bdacc48458e8).(h_category); |
| 129 | |
| 130 | return item; |
| 131 | } |
| 132 | |
| 133 | |
| 134 | static SEXP_tcxx . . $ SEXP_t# *create_file_probe_item_with_rangecxx . . $ create_file_probe_item_with_range(9826c2cb3f32c9d7).( |
| 135 | const char *range, const char *user, const char *role, const char *type, |
| 136 | const char *pbuf, const char *p, const char *f) { |
| 137 | char *l_sensitivity, *l_category, *h_sensitivity, *h_category; |
| 138 | SEXP_tcxx . . $ SEXP_t# *item; |
| 139 | |
| 140 | split_rangecxx . . $ split_range(846b4948bf2883d2).(range, &l_sensitivity, &l_category, &h_sensitivity, &h_category); |
| 141 | item = probe_item_createcxx . . $ probe_item_create(36b16a6622050a9c).(OVAL_LINUX_SELINUXSECURITYCONTEXTcxx . . $ OVAL_LINUX_SELINUXSECURITYCONTEXT., NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!, |
| 142 | "filepath", OVAL_DATATYPE_STRINGcxx . . $ OVAL_DATATYPE_STRING., pbuf, |
| 143 | "path", OVAL_DATATYPE_STRINGcxx . . $ OVAL_DATATYPE_STRING., p, |
| 144 | "filename", OVAL_DATATYPE_STRINGcxx . . $ OVAL_DATATYPE_STRING., f, |
| 145 | |
| 146 | "user", OVAL_DATATYPE_STRINGcxx . . $ OVAL_DATATYPE_STRING., user, |
| 147 | "role", OVAL_DATATYPE_STRINGcxx . . $ OVAL_DATATYPE_STRING., role, |
| 148 | "type", OVAL_DATATYPE_STRINGcxx . . $ OVAL_DATATYPE_STRING., type, |
| 149 | "low_sensitivity", OVAL_DATATYPE_STRINGcxx . . $ OVAL_DATATYPE_STRING., l_sensitivity, |
| 150 | "low_category", OVAL_DATATYPE_STRINGcxx . . $ OVAL_DATATYPE_STRING., l_category, |
| 151 | "high_sensitivity", OVAL_DATATYPE_STRINGcxx . . $ OVAL_DATATYPE_STRING., h_sensitivity, |
| 152 | "high_category", OVAL_DATATYPE_STRINGcxx . . $ OVAL_DATATYPE_STRING., h_category, |
| 153 | |
| 154 | "rawlow_sensitivity", OVAL_DATATYPE_STRINGcxx . . $ OVAL_DATATYPE_STRING., l_sensitivity, |
| 155 | "rawlow_category", OVAL_DATATYPE_STRINGcxx . . $ OVAL_DATATYPE_STRING., l_category, |
| 156 | "rawhigh_sensitivity", OVAL_DATATYPE_STRINGcxx . . $ OVAL_DATATYPE_STRING., h_sensitivity, |
| 157 | "rawhigh_category", OVAL_DATATYPE_STRINGcxx . . $ OVAL_DATATYPE_STRING., h_category, |
| 158 | NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!); |
| 159 | freecxx . . $ free(5d22bdacc48458e8).(l_sensitivity); |
| 160 | freecxx . . $ free(5d22bdacc48458e8).(l_category); |
| 161 | freecxx . . $ free(5d22bdacc48458e8).(h_sensitivity); |
| 162 | freecxx . . $ free(5d22bdacc48458e8).(h_category); |
| 163 | |
| 164 | return item; |
| 165 | } |
| 166 | |
| 167 | static int selinuxsecuritycontext_process_cbcxx . . $ selinuxsecuritycontext_process_cb(241d6c535218441). (SEXP_tcxx . . $ SEXP_t# *pid_ent, probe_ctxcxx . . $ probe_ctx# *ctx) { |
| 168 | char path[PATH_MAXcxx . . $ `<external>/6347054901304145714/limits.h:13:9`!]; |
| 169 | SEXP_tcxx . . $ SEXP_t# *pid_sexp, *item; |
| 170 | char *pid_context; |
| 171 | context_tcxx . . $ context_t# context; |
| 172 | int pid_number; |
| 173 | DIRcxx . . $ DIR# *proc; |
| 174 | struct direntcxx . . $ dirent# *dir_entry; |
| 175 | const char *user, *role, *type, *range; |
| 176 | |
| 177 | const char *prefix = getenvcxx . . $ getenv(a8b8e32347182212).("OSCAP_PROBE_ROOT"); |
| 178 | snprintfcxx . . $ snprintf(ea502d73e74c754c). (path, PATH_MAXcxx . . $ `<external>/6347054901304145714/limits.h:13:9`!, "%s/proc", prefix ? prefix : ""); |
| 179 | if ((proc = opendircxx . . $ opendir(f465d4b65cec8dd2).(path)) == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) { |
| 180 | dEcxx . . $ `src/common/debug_priv.h:63:9`!("Can't open '%s' dir: %s", path, strerror(errnocxx . . $ `<external>/17633486526465735210/errno.h:38:10`!)); |
| 181 | |
| 182 | probe_cobj_set_flagcxx . . $ probe_cobj_set_flag(644bab5dffe689c).(probe_ctx_getresultcxx . . $ probe_ctx_getresult(4299b6b53fa804a5).(ctx), SYSCHAR_FLAG_ERRORcxx . . $ SYSCHAR_FLAG_ERROR.); |
| 183 | return errnocxx . . $ `<external>/17633486526465735210/errno.h:38:10`!; |
| 184 | } |
| 185 | |
| 186 | while ((dir_entry = readdircxx . . $ readdir(ffbaae344e1a615a).(proc))) { |
| 187 | if (strspncxx . . $ strspn(335c1dc86f5c867f).(dir_entry->d_namecxx . . $ dirent#d_name., "0123456789") != strlencxx . . $ strlen(751346f8406fd082).(dir_entry->d_namecxx . . $ dirent#d_name.)) |
| 188 | continue; |
| 189 | |
| 190 | pid_number = atoicxx . . $ atoi(5c4306d8553b3696).(dir_entry->d_namecxx . . $ dirent#d_name.); |
| 191 | pid_sexp = SEXP_number_newi_32cxx . . $ SEXP_number_newi_32(ac44525e09ce977a).(pid_number); |
| 192 | if (probe_entobj_cmpcxx . . $ probe_entobj_cmp(e245451a1311e799).(pid_ent, pid_sexp) == OVAL_RESULT_TRUEcxx . . $ OVAL_RESULT_TRUE.) { |
| 193 | |
| 194 | if (getpidconcxx . . $ getpidcon(afcd3168fc1188a4).(pid_number, &pid_context) == -1) { |
| 195 | /* error getting pid selinux context */ |
| 196 | dWcxx . . $ `src/common/debug_priv.h:62:9`!("Can't get selinux context for process %d", pid_number); |
| 197 | SEXP_freecxx . . $ SEXP_free(c6b28547479798f4).(pid_sexp); |
| 198 | continue; |
| 199 | } |
| 200 | |
| 201 | context = context_newcxx . . $ context_new(48298312e2d58ff4).(pid_context); |
| 202 | |
| 203 | user = context_user_getcxx . . $ context_user_get(937a50f5ac5c103a).(context); |
| 204 | role = context_role_getcxx . . $ context_role_get(937a50f5ac5c103a).(context); |
| 205 | type = context_type_getcxx . . $ context_type_get(937a50f5ac5c103a).(context); |
| 206 | range = context_range_getcxx . . $ context_range_get(937a50f5ac5c103a).(context); |
| 207 | if (range != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) { |
| 208 | item = create_process_probe_item_with_rangecxx . . $ create_process_probe_item_with_range(1094ad8316b00d6d).(range, user, role, type, pid_number); |
| 209 | } |
| 210 | else { |
| 211 | item = probe_item_createcxx . . $ probe_item_create(36b16a6622050a9c).(OVAL_LINUX_SELINUXSECURITYCONTEXTcxx . . $ OVAL_LINUX_SELINUXSECURITYCONTEXT., NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!, |
| 212 | "pid", OVAL_DATATYPE_INTEGERcxx . . $ OVAL_DATATYPE_INTEGER., (int64_tcxx . . $ int64_t#)pid_number, |
| 213 | "user", OVAL_DATATYPE_STRINGcxx . . $ OVAL_DATATYPE_STRING., user, |
| 214 | "role", OVAL_DATATYPE_STRINGcxx . . $ OVAL_DATATYPE_STRING., role, |
| 215 | "type", OVAL_DATATYPE_STRINGcxx . . $ OVAL_DATATYPE_STRING., type, |
| 216 | NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!); |
| 217 | } |
| 218 | |
| 219 | probe_item_collectcxx . . $ probe_item_collect(11bb80e0c30650d7).(ctx, item); |
| 220 | |
| 221 | context_freecxx . . $ context_free(7fa3f91f37ede77).(context); |
| 222 | freeconcxx . . $ freecon(fda57c8427c60377).(pid_context); |
| 223 | } |
| 224 | SEXP_freecxx . . $ SEXP_free(c6b28547479798f4).(pid_sexp); |
| 225 | } |
| 226 | closedircxx . . $ closedir(ac30a447bc7c2f80).(proc); |
| 227 | |
| 228 | return 0; |
| 229 | } |
| 230 | |
| 231 | |
| 232 | static int selinuxsecuritycontext_file_cbcxx . . $ selinuxsecuritycontext_file_cb(fef121c2dc0f8de6).(const char *prefix, const char *p, const char *f, probe_ctxcxx . . $ probe_ctx# *ctx) |
| 233 | { |
| 234 | SEXP_tcxx . . $ SEXP_t# *item; |
| 235 | |
| 236 | char pbuf[PATH_MAXcxx . . $ `<external>/6347054901304145714/limits.h:13:9`!+1]; |
| 237 | size_t plen, flen; |
| 238 | |
| 239 | char *file_context; |
| 240 | int file_context_size; |
| 241 | context_tcxx . . $ context_t# context; |
| 242 | const char *user, *role, *type, *range; |
| 243 | int err = 0; |
| 244 | |
| 245 | /* directory */ |
| 246 | if (f == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) |
| 247 | flen = 0; |
| 248 | else |
| 249 | flen = strlencxx . . $ strlen(751346f8406fd082). (f); |
| 250 | |
| 251 | /* |
| 252 | * Prepare path |
| 253 | */ |
| 254 | plen = strlencxx . . $ strlen(751346f8406fd082). (p); |
| 255 | |
| 256 | if (plen + flen + 1 > PATH_MAXcxx . . $ `<external>/6347054901304145714/limits.h:13:9`!) |
| 257 | return (-1); |
| 258 | |
| 259 | memcpycxx . . $ memcpy(cc817cb175f282d). (pbuf, p, sizeof (char) * plen); |
| 260 | |
| 261 | if (p[plen - 1] != FILE_SEPARATORcxx . . $ `src/OVAL/probes/unix/linux/selinuxsecuritycontext_probe.c:59:9`!) { |
| 262 | pbuf[plen] = FILE_SEPARATORcxx . . $ `src/OVAL/probes/unix/linux/selinuxsecuritycontext_probe.c:59:9`!; |
| 263 | ++plen; |
| 264 | } |
| 265 | |
| 266 | if (f != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) |
| 267 | memcpycxx . . $ memcpy(cc817cb175f282d). (pbuf + plen, f, sizeof (char) * flen); |
| 268 | |
| 269 | pbuf[plen+flen] = '\0'; |
| 270 | |
| 271 | char *path_with_prefix = oscap_path_joincxx . . $ oscap_path_join(a713fe7b9a57cf96).(prefix, pbuf); |
| 272 | if (accesscxx . . $ access(cb7559238bb26814).(path_with_prefix, F_OKcxx . . $ `<external>/12628407106812493757/unistd.h:284:9`!) == -1 ) { |
| 273 | dDcxx . . $ `src/common/debug_priv.h:64:9`!("File does not exists anymore (could happen to /dev/fd/X)"); |
| 274 | freecxx . . $ free(5d22bdacc48458e8).(path_with_prefix); |
| 275 | return 0; |
| 276 | } |
| 277 | file_context_size = getfileconcxx . . $ getfilecon(c4dada3283861623).(path_with_prefix, &file_context); |
| 278 | freecxx . . $ free(5d22bdacc48458e8).(path_with_prefix); |
| 279 | if (file_context_size == -1) { |
| 280 | dDcxx . . $ `src/common/debug_priv.h:64:9`!("Can't get context for %s: %s", pbuf, strerror(errnocxx . . $ `<external>/17633486526465735210/errno.h:38:10`!)); |
| 281 | |
| 282 | item = probe_item_createcxx . . $ probe_item_create(36b16a6622050a9c).(OVAL_LINUX_SELINUXSECURITYCONTEXTcxx . . $ OVAL_LINUX_SELINUXSECURITYCONTEXT., NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!, |
| 283 | "filepath", OVAL_DATATYPE_STRINGcxx . . $ OVAL_DATATYPE_STRING., pbuf, |
| 284 | "path", OVAL_DATATYPE_STRINGcxx . . $ OVAL_DATATYPE_STRING., p, |
| 285 | "filename", OVAL_DATATYPE_STRINGcxx . . $ OVAL_DATATYPE_STRING., f, |
| 286 | NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!); |
| 287 | |
| 288 | probe_item_add_msgcxx . . $ probe_item_add_msg(c5b7a86259de5bd8).(item, OVAL_MESSAGE_LEVEL_ERRORcxx . . $ OVAL_MESSAGE_LEVEL_ERROR., |
| 289 | "Can't get context for %s: %s\n", pbuf, strerrorcxx . . $ strerror(ff224f080444ee45).(errnocxx . . $ `<external>/17633486526465735210/errno.h:38:10`!)); |
| 290 | probe_item_setstatuscxx . . $ probe_item_setstatus(112b785eb420e6c0).(item, SYSCHAR_STATUS_ERRORcxx . . $ SYSCHAR_STATUS_ERROR.); |
| 291 | err = errnocxx . . $ `<external>/17633486526465735210/errno.h:38:10`!; |
| 292 | |
| 293 | } |
| 294 | else { |
| 295 | context = context_newcxx . . $ context_new(48298312e2d58ff4).(file_context); |
| 296 | |
| 297 | user = context_user_getcxx . . $ context_user_get(937a50f5ac5c103a).(context); |
| 298 | role = context_role_getcxx . . $ context_role_get(937a50f5ac5c103a).(context); |
| 299 | type = context_type_getcxx . . $ context_type_get(937a50f5ac5c103a).(context); |
| 300 | range = context_range_getcxx . . $ context_range_get(937a50f5ac5c103a).(context); |
| 301 | |
| 302 | if (range != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) { |
| 303 | item = create_file_probe_item_with_rangecxx . . $ create_file_probe_item_with_range(9826c2cb3f32c9d7).(range, user, role, type, pbuf, p, f); |
| 304 | } |
| 305 | else { |
| 306 | item = probe_item_createcxx . . $ probe_item_create(36b16a6622050a9c).(OVAL_LINUX_SELINUXSECURITYCONTEXTcxx . . $ OVAL_LINUX_SELINUXSECURITYCONTEXT., NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!, |
| 307 | "filepath", OVAL_DATATYPE_STRINGcxx . . $ OVAL_DATATYPE_STRING., pbuf, |
| 308 | "path", OVAL_DATATYPE_STRINGcxx . . $ OVAL_DATATYPE_STRING., p, |
| 309 | "filename", OVAL_DATATYPE_STRINGcxx . . $ OVAL_DATATYPE_STRING., f, |
| 310 | "user", OVAL_DATATYPE_STRINGcxx . . $ OVAL_DATATYPE_STRING., user, |
| 311 | "role", OVAL_DATATYPE_STRINGcxx . . $ OVAL_DATATYPE_STRING., role, |
| 312 | "type", OVAL_DATATYPE_STRINGcxx . . $ OVAL_DATATYPE_STRING., type, |
| 313 | NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!); |
| 314 | } |
| 315 | |
| 316 | context_freecxx . . $ context_free(7fa3f91f37ede77).(context); |
| 317 | } |
| 318 | probe_item_collectcxx . . $ probe_item_collect(11bb80e0c30650d7).(ctx, item); |
| 319 | |
| 320 | if (file_context != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) |
| 321 | freeconcxx . . $ freecon(fda57c8427c60377).(file_context); |
| 322 | |
| 323 | return (err); |
| 324 | } |
| 325 | |
| 326 | int selinuxsecuritycontext_probe_offline_mode_supportedcxx . . $ selinuxsecuritycontext_probe_offline_mode_supported(b126dc7c1de90089).(void) |
| 327 | { |
| 328 | return PROBE_OFFLINE_OWNcxx . . $ PROBE_OFFLINE_OWN.; |
| 329 | } |
| 330 | |
| 331 | int selinuxsecuritycontext_probe_maincxx . . $ selinuxsecuritycontext_probe_main(470536d3ffacaf10).(probe_ctxcxx . . $ probe_ctx# *ctx, void *arg) |
| 332 | { |
| 333 | SEXP_tcxx . . $ SEXP_t# *probe_in; |
| 334 | SEXP_tcxx . . $ SEXP_t# *path, *filename, *filepath, *pid, *behaviors = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!; |
| 335 | int process_pid, err = 0; |
| 336 | |
| 337 | OVAL_FTScxx . . $ OVAL_FTS# *ofts; |
| 338 | OVAL_FTSENTcxx . . $ OVAL_FTSENT# *ofts_ent; |
| 339 | |
| 340 | probe_in = probe_ctx_getobjectcxx . . $ probe_ctx_getobject(4299b6b53fa804a5).(ctx); |
| 341 | |
| 342 | behaviors = probe_obj_getentcxx . . $ probe_obj_getent(7907a01f2ff841f3).(probe_in, "behaviors", 1); |
| 343 | path = probe_obj_getentcxx . . $ probe_obj_getent(7907a01f2ff841f3).(probe_in, "path", 1); |
| 344 | filename = probe_obj_getentcxx . . $ probe_obj_getent(7907a01f2ff841f3).(probe_in, "filename", 1); |
| 345 | filepath = probe_obj_getentcxx . . $ probe_obj_getent(7907a01f2ff841f3).(probe_in, "filepath", 1); |
| 346 | pid = probe_obj_getentcxx . . $ probe_obj_getent(7907a01f2ff841f3).(probe_in, "pid", 1); |
| 347 | |
| 348 | 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`! ) && pid == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) { |
| 349 | err = PROBE_ENOENTcxx . . $ `src/OVAL/probes/public/probe-common.h:20:9`!; |
| 350 | goto cleanup; |
| 351 | } |
| 352 | |
| 353 | if (filepath || (path && filename)) { |
| 354 | probe_filebehaviors_canonicalizecxx . . $ probe_filebehaviors_canonicalize(e661f441b24a5de6).(&behaviors); |
| 355 | |
| 356 | const char *prefix = getenvcxx . . $ getenv(a8b8e32347182212).("OSCAP_PROBE_ROOT"); |
| 357 | 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`!) { |
| 358 | 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`!) { |
| 359 | selinuxsecuritycontext_file_cbcxx . . $ selinuxsecuritycontext_file_cb(fef121c2dc0f8de6).(prefix, ofts_ent->pathcxx . . $ $anonymous_type_ebdee0feb58b991e_1#path., ofts_ent->filecxx . . $ $anonymous_type_ebdee0feb58b991e_1#file., ctx); |
| 360 | oval_ftsent_freecxx . . $ oval_ftsent_free(7e09326da17d8ab0).(ofts_ent); |
| 361 | } |
| 362 | |
| 363 | oval_fts_closecxx . . $ oval_fts_close(cd898f79c195c42c).(ofts); |
| 364 | } |
| 365 | SEXP_freecxx . . $ SEXP_free(c6b28547479798f4).(behaviors); |
| 366 | } |
| 367 | |
| 368 | if (pid != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) { |
| 369 | PROBE_ENT_I32VALcxx . . $ `src/OVAL/probes/public/probe-api.h:508:9`!(pid, process_pid, err = PROBE_ENOVALcxx . . $ `src/OVAL/probes/public/probe-common.h:10:9`!;, process_pid = 0;); |
| 370 | if (err != 0) |
| 371 | goto cleanup; |
| 372 | |
| 373 | if (process_pid == 0) { |
| 374 | if (ctx->offline_modecxx . . $ probe_ctx#offline_mode. == PROBE_OFFLINE_NONEcxx . . $ PROBE_OFFLINE_NONE.) { |
| 375 | SEXP_tcxx . . $ SEXP_t# *nref, *nval, *pid2; |
| 376 | |
| 377 | nref = SEXP_list_firstcxx . . $ SEXP_list_first(2f7f980afaaae0f0).(probe_in); |
| 378 | nval = SEXP_number_newu_32cxx . . $ SEXP_number_newu_32(8a1232211d6fd92a).(getpidcxx . . $ getpid(b126dc7c1de90089).()); |
| 379 | pid2 = SEXP_list_newcxx . . $ SEXP_list_new(902e4f76566c8810).(nref, nval, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!); |
| 380 | SEXP_freecxx . . $ SEXP_free(c6b28547479798f4).(pid); |
| 381 | SEXP_freecxx . . $ SEXP_free(c6b28547479798f4).(nref); |
| 382 | SEXP_freecxx . . $ SEXP_free(c6b28547479798f4).(nval); |
| 383 | pid = pid2; |
| 384 | } else { |
| 385 | err = PROBE_EINVALcxx . . $ `src/OVAL/probes/public/probe-common.h:8:9`!; |
| 386 | goto cleanup; |
| 387 | } |
| 388 | } |
| 389 | |
| 390 | selinuxsecuritycontext_process_cbcxx . . $ selinuxsecuritycontext_process_cb(241d6c535218441).(pid, ctx); |
| 391 | } |
| 392 | |
| 393 | cleanup: |
| 394 | SEXP_freecxx . . $ SEXP_free(c6b28547479798f4). (path); |
| 395 | SEXP_freecxx . . $ SEXP_free(c6b28547479798f4). (filename); |
| 396 | SEXP_freecxx . . $ SEXP_free(c6b28547479798f4). (filepath); |
| 397 | SEXP_freecxx . . $ SEXP_free(c6b28547479798f4). (pid); |
| 398 | |
| 399 | return err; |
| 400 | } |