| 1 | /** |
| 2 | * @file environmentvariable58_probe.c |
| 3 | * @brief environmentvariable58 probe |
| 4 | * @author "Petr Lautrbach" <[email protected]> |
| 5 | * |
| 6 | * This probe is able to process a environmentvariable58_object as defined in OVAL 5.8. |
| 7 | * |
| 8 | */ |
| 9 | |
| 10 | /* |
| 11 | * Copyright 2009-2011 Red Hat Inc., Durham, North Carolina. |
| 12 | * All Rights Reserved. |
| 13 | * |
| 14 | * This library is free software; you can redistribute it and/or |
| 15 | * modify it under the terms of the GNU Lesser General Public |
| 16 | * License as published by the Free Software Foundation; either |
| 17 | * version 2.1 of the License, or (at your option) any later version. |
| 18 | * |
| 19 | * This library is distributed in the hope that it will be useful, |
| 20 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 21 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 22 | * Lesser General Public License for more details. |
| 23 | * |
| 24 | * You should have received a copy of the GNU Lesser General Public |
| 25 | * License along with this library; if not, write to the Free Software |
| 26 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA |
| 27 | * |
| 28 | * Authors: |
| 29 | * Petr Lautrbach <[email protected]> |
| 30 | */ |
| 31 | |
| 32 | /* |
| 33 | * environmentvariable58 probe: |
| 34 | * |
| 35 | * pid |
| 36 | * name |
| 37 | * value |
| 38 | */ |
| 39 | |
| 40 | #ifdef HAVE_CONFIG_Hcxx . . $ `<built-in>:409:9`! |
| 41 | #include <config.h>cxx . . $ `<file>/build/config.h`/ |
| 42 | #endif |
| 43 | |
| 44 | #include <stdlib.h> |
| 45 | #include <unistd.h> |
| 46 | #include <limits.h> |
| 47 | #include <string.h> |
| 48 | #include <stdio.h> |
| 49 | #include <errno.h> |
| 50 | #include <sys/stat.h> |
| 51 | #include <fcntl.h> |
| 52 | #include <sys/types.h> |
| 53 | #include <dirent.h> |
| 54 | |
| 55 | #if defined(OS_FREEBSD) |
| 56 | #include <limits.h> |
| 57 | #include <sys/user.h> |
| 58 | #include <kvm.h> |
| 59 | #include <sys/param.h> |
| 60 | #include <paths.h> |
| 61 | #include <libprocstat.h> |
| 62 | #include <sys/sysctl.h> |
| 63 | #endif |
| 64 | |
| 65 | #include <probe/probe.h>cxx . . $ `<file>/src/OVAL/probes/probe/probe.h`/ |
| 66 | #include "_seap.h"cxx . . $ `<file>/src/OVAL/probes/SEAP/_seap.h`/ |
| 67 | #include "probe-api.h"cxx . . $ `<file>/src/OVAL/probes/public/probe-api.h`/ |
| 68 | #include "probe/entcmp.h"cxx . . $ `<file>/src/OVAL/probes/probe/entcmp.h`/ |
| 69 | #include "common/debug_priv.h"cxx . . $ `<file>/src/common/debug_priv.h`/ |
| 70 | #include "environmentvariable58_probe.h"cxx . . $ `<file>/src/OVAL/probes/independent/environmentvariable58_probe.h`/ |
| 71 | |
| 72 | #if defined(OS_FREEBSD) |
| 73 | static int read_environment(SEXP_t *pid_ent, SEXP_t *name_ent, probe_ctx *ctx) |
| 74 | { |
| 75 | struct kinfo_proc *proclist, *proc; |
| 76 | int i, j, count, pid; |
| 77 | char *name, *value; |
| 78 | const char *SEP = "="; |
| 79 | struct procstat *stat = NULL; |
| 80 | char buf[LINE_MAX]; |
| 81 | SEXP_t *pid_sexp; |
| 82 | char **env = NULL; |
| 83 | kvm_t *kd; |
| 84 | |
| 85 | const char *extra_vars = getenv("OSCAP_CONTAINER_VARS"); |
| 86 | if (extra_vars && *extra_vars) { |
| 87 | char *vars = strdup(extra_vars); |
| 88 | char *tok, *eq_chr, *str, *strp; |
| 89 | |
| 90 | for (str = vars; ; str = NULL) { |
| 91 | tok = strtok_r(str, "\n", &strp); |
| 92 | if (tok == NULL) |
| 93 | break; |
| 94 | eq_chr = strchr(tok, '='); |
| 95 | if (eq_chr == NULL) |
| 96 | continue; |
| 97 | PROBE_ENT_I32VAL(pid_ent, pid, pid = -1;, pid = 0;); |
| 98 | |
| 99 | size_t extra_env_name_size = eq_chr - tok; |
| 100 | SEXP_t *extra_env_name = SEXP_string_new(tok, extra_env_name_size); |
| 101 | SEXP_t *extra_env_value = SEXP_string_newf("%s", tok + extra_env_name_size + 1); |
| 102 | |
| 103 | if (probe_entobj_cmp(name_ent, extra_env_name) == OVAL_RESULT_TRUE) { |
| 104 | SEXP_t *extra_item = probe_item_create( |
| 105 | OVAL_INDEPENDENT_ENVIRONMENT_VARIABLE58, NULL, |
| 106 | "pid", OVAL_DATATYPE_INTEGER, (int64_t)pid, |
| 107 | "name", OVAL_DATATYPE_SEXP, extra_env_name, |
| 108 | "value", OVAL_DATATYPE_SEXP, extra_env_value, |
| 109 | NULL); |
| 110 | |
| 111 | if (!extra_item) { |
| 112 | dE("Failed to create new probem item"); |
| 113 | SEXP_free(extra_env_name); |
| 114 | SEXP_free(extra_env_value); |
| 115 | free(vars); |
| 116 | return (PROBE_EFAULT); |
| 117 | } |
| 118 | |
| 119 | probe_item_collect(ctx, extra_item); |
| 120 | } else { |
| 121 | SEXP_free(extra_env_name); |
| 122 | SEXP_free(extra_env_value); |
| 123 | } |
| 124 | } |
| 125 | |
| 126 | free(vars); |
| 127 | return 0; |
| 128 | } |
| 129 | |
| 130 | kd = kvm_openfiles(NULL, _PATH_DEVNULL, NULL, O_RDONLY, buf); |
| 131 | |
| 132 | if (!kd) |
| 133 | return (PROBE_EFAULT); |
| 134 | |
| 135 | proclist = kvm_getprocs(kd, KERN_PROC_PROC, 0, &count); |
| 136 | |
| 137 | if (!proclist) { |
| 138 | dE("Failed to obtain process list handle"); |
| 139 | kvm_close(kd); |
| 140 | return (PROBE_EFAULT); |
| 141 | } |
| 142 | |
| 143 | proc = proclist; |
| 144 | |
| 145 | /* Loop until we find a matching PID */ |
| 146 | for (i = 0; i < count; i++, proc++) { |
| 147 | pid = proc->ki_pid; |
| 148 | pid_sexp = SEXP_number_newi_32(pid); |
| 149 | |
| 150 | if (!pid_sexp) { |
| 151 | dE("Failed to allocate pid_sexp"); |
| 152 | kvm_close(kd); |
| 153 | return (PROBE_EFATAL); |
| 154 | } |
| 155 | |
| 156 | /* PID doesn't match */ |
| 157 | if (probe_entobj_cmp(pid_ent, pid_sexp) != OVAL_RESULT_TRUE) { |
| 158 | SEXP_free(pid_sexp); |
| 159 | continue; |
| 160 | } |
| 161 | |
| 162 | /* PID matches */ |
| 163 | stat = procstat_open_sysctl(); |
| 164 | |
| 165 | if (!stat) { |
| 166 | dE("NULL procstat handle returned"); |
| 167 | SEXP_free(pid_sexp); |
| 168 | kvm_close(kd); |
| 169 | return (PROBE_EFAULT); |
| 170 | } |
| 171 | |
| 172 | env = procstat_getenvv(stat, proc, ARG_MAX); |
| 173 | |
| 174 | /* Found matching process, so stop searching */ |
| 175 | SEXP_free(pid_sexp); |
| 176 | break; |
| 177 | } |
| 178 | |
| 179 | if (!env) { |
| 180 | dE("NULL env returned"); |
| 181 | procstat_freeenvv(stat); |
| 182 | kvm_close(kd); |
| 183 | return (PROBE_EFATAL); |
| 184 | } |
| 185 | |
| 186 | for (j = 0; env[j] != NULL; j++) { |
| 187 | char *strp; |
| 188 | name = strtok_r(env[j], SEP, &strp); |
| 189 | |
| 190 | if (!name) { |
| 191 | dE("Error parsing environment string"); |
| 192 | procstat_freeenvv(stat); |
| 193 | kvm_close(kd); |
| 194 | return (PROBE_EFAULT); |
| 195 | } |
| 196 | |
| 197 | value = strtok_r(NULL, SEP, &strp); |
| 198 | |
| 199 | if (value != NULL) { |
| 200 | SEXP_t *env_name = SEXP_string_new(name, strlen(name) + 1); |
| 201 | SEXP_t *env_value = SEXP_string_new(value, strlen(value) + 1); |
| 202 | |
| 203 | if (probe_entobj_cmp(name_ent, env_name) == OVAL_RESULT_TRUE) { |
| 204 | |
| 205 | SEXP_t *item = probe_item_create( |
| 206 | OVAL_INDEPENDENT_ENVIRONMENT_VARIABLE58, NULL, |
| 207 | "pid", OVAL_DATATYPE_INTEGER, (int64_t)pid, |
| 208 | "name", OVAL_DATATYPE_SEXP, env_name, |
| 209 | "value", OVAL_DATATYPE_SEXP, env_value, |
| 210 | NULL); |
| 211 | |
| 212 | if (!item) { |
| 213 | dE("Failed to create new probe item"); |
| 214 | SEXP_free(env_name); |
| 215 | SEXP_free(env_value); |
| 216 | procstat_freeenvv(stat); |
| 217 | kvm_close(kd); |
| 218 | return (PROBE_EFAULT); |
| 219 | } |
| 220 | |
| 221 | probe_item_collect(ctx, item); |
| 222 | } else { |
| 223 | SEXP_free(env_name); |
| 224 | SEXP_free(env_value); |
| 225 | } |
| 226 | } |
| 227 | } |
| 228 | |
| 229 | procstat_freeenvv(stat); |
| 230 | kvm_close(kd); |
| 231 | return 0; |
| 232 | } |
| 233 | |
| 234 | #else |
| 235 | #define BUFFER_SIZEcxx . . $ `src/OVAL/probes/independent/environmentvariable58_probe.c:235:9`! 256 |
| 236 | |
| 237 | extern char **environcxx . . $ environ.; |
| 238 | |
| 239 | static int collect_variablecxx . . $ collect_variable(ccc4dd54a775b26).(char *buffer, size_t env_name_size, int pid, SEXP_tcxx . . $ SEXP_t# *name_ent, probe_ctxcxx . . $ probe_ctx# *ctx) |
| 240 | { |
| 241 | int res = 1; |
| 242 | |
| 243 | SEXP_tcxx . . $ SEXP_t# *env_name = SEXP_string_newcxx . . $ SEXP_string_new(a588a58d7514eee2).(buffer, env_name_size); |
| 244 | SEXP_tcxx . . $ SEXP_t# *env_value = SEXP_string_newfcxx . . $ SEXP_string_newf(b2137ed863725962).("%s", buffer + env_name_size + 1); |
| 245 | |
| 246 | if (probe_entobj_cmpcxx . . $ probe_entobj_cmp(e245451a1311e799).(name_ent, env_name) == OVAL_RESULT_TRUEcxx . . $ OVAL_RESULT_TRUE.) { |
| 247 | SEXP_tcxx . . $ SEXP_t# *item = probe_item_createcxx . . $ probe_item_create(36b16a6622050a9c).( |
| 248 | OVAL_INDEPENDENT_ENVIRONMENT_VARIABLE58cxx . . $ OVAL_INDEPENDENT_ENVIRONMENT_VARIABLE58., NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!, |
| 249 | "pid", OVAL_DATATYPE_INTEGERcxx . . $ OVAL_DATATYPE_INTEGER., (int64_tcxx . . $ int64_t#)pid, |
| 250 | "name", OVAL_DATATYPE_SEXPcxx . . $ OVAL_DATATYPE_SEXP., env_name, |
| 251 | "value", OVAL_DATATYPE_SEXPcxx . . $ OVAL_DATATYPE_SEXP., env_value, |
| 252 | NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!); |
| 253 | probe_item_collectcxx . . $ probe_item_collect(11bb80e0c30650d7).(ctx, item); |
| 254 | res = 0; |
| 255 | } |
| 256 | SEXP_freecxx . . $ SEXP_free(c6b28547479798f4).(env_name); |
| 257 | SEXP_freecxx . . $ SEXP_free(c6b28547479798f4).(env_value); |
| 258 | |
| 259 | return res; |
| 260 | } |
| 261 | |
| 262 | static int read_environmentcxx . . $ read_environment(8cb7114d8bc47ec5).(SEXP_tcxx . . $ SEXP_t# *pid_ent, SEXP_tcxx . . $ SEXP_t# *name_ent, probe_ctxcxx . . $ probe_ctx# *ctx) |
| 263 | { |
| 264 | int err = 1, pid, fd; |
| 265 | boolcxx . . $ `<external>/14268322491693841775/stdbool.h:36:9`! empty; |
| 266 | SEXP_tcxx . . $ SEXP_t# *item, *pid_sexp; |
| 267 | DIRcxx . . $ DIR# *d; |
| 268 | struct direntcxx . . $ dirent# *d_entry; |
| 269 | char *buffer, *null_char, path[PATH_MAXcxx . . $ `<external>/6347054901304145714/limits.h:13:9`!] = {0}; |
| 270 | ssize_tcxx . . $ ssize_t# buffer_used; |
| 271 | size_t buffer_size; |
| 272 | |
| 273 | const char *extra_vars = getenvcxx . . $ getenv(a8b8e32347182212).("OSCAP_CONTAINER_VARS"); |
| 274 | if (extra_vars && *extra_vars) { |
| 275 | char *vars = strdupcxx . . $ strdup(a8b8e32347182212).(extra_vars); |
| 276 | char *tok, *eq_chr, *str, *strp; |
| 277 | |
| 278 | for (str = vars; ; str = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) { |
| 279 | tok = strtok_rcxx . . $ strtok_r(a42394c85d6397dd).(str, "\n", &strp); |
| 280 | if (tok == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) |
| 281 | break; |
| 282 | eq_chr = strchrcxx . . $ strchr(2050848944e00d54).(tok, '='); |
| 283 | if (eq_chr == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) |
| 284 | continue; |
| 285 | PROBE_ENT_I32VALcxx . . $ `src/OVAL/probes/public/probe-api.h:508:9`!(pid_ent, pid, pid = -1;, pid = 0;); |
| 286 | collect_variablecxx . . $ collect_variable(ccc4dd54a775b26).(tok, eq_chr - tok, pid, name_ent, ctx); |
| 287 | } |
| 288 | |
| 289 | freecxx . . $ free(5d22bdacc48458e8).(vars); |
| 290 | return 0; |
| 291 | } |
| 292 | |
| 293 | const char *prefix = getenvcxx . . $ getenv(a8b8e32347182212).("OSCAP_PROBE_ROOT"); |
| 294 | snprintfcxx . . $ snprintf(ea502d73e74c754c).(path, PATH_MAXcxx . . $ `<external>/6347054901304145714/limits.h:13:9`!, "%s/proc", prefix ? prefix : ""); |
| 295 | d = opendircxx . . $ opendir(f465d4b65cec8dd2).(path); |
| 296 | if (d == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) { |
| 297 | dEcxx . . $ `src/common/debug_priv.h:63:9`!("Can't read %s/proc: errno=%d, %s.", prefix ? prefix : "", errnocxx . . $ `<external>/17633486526465735210/errno.h:38:10`!, strerror(errnocxx . . $ `<external>/17633486526465735210/errno.h:38:10`!)); |
| 298 | return PROBE_EACCESScxx . . $ `src/OVAL/probes/public/probe-api.h:431:9`!; |
| 299 | } |
| 300 | |
| 301 | if ((buffer = realloccxx . . $ realloc(417ab160f6baadc6).(NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!, BUFFER_SIZEcxx . . $ `src/OVAL/probes/independent/environmentvariable58_probe.c:235:9`!)) == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) { |
| 302 | dEcxx . . $ `src/common/debug_priv.h:63:9`!("Can't re-allocate memory"); |
| 303 | closedircxx . . $ closedir(ac30a447bc7c2f80).(d); |
| 304 | return PROBE_EFAULTcxx . . $ `src/OVAL/probes/public/probe-api.h:430:9`!; |
| 305 | } |
| 306 | buffer_size = BUFFER_SIZEcxx . . $ `src/OVAL/probes/independent/environmentvariable58_probe.c:235:9`!; |
| 307 | |
| 308 | while ((d_entry = readdircxx . . $ readdir(ffbaae344e1a615a).(d))) { |
| 309 | if (strspncxx . . $ strspn(335c1dc86f5c867f).(d_entry->d_namecxx . . $ dirent#d_name., "0123456789") != strlencxx . . $ strlen(751346f8406fd082).(d_entry->d_namecxx . . $ dirent#d_name.)) |
| 310 | continue; |
| 311 | |
| 312 | pid = atoicxx . . $ atoi(5c4306d8553b3696).(d_entry->d_namecxx . . $ dirent#d_name.); |
| 313 | pid_sexp = SEXP_number_newi_32cxx . . $ SEXP_number_newi_32(ac44525e09ce977a).(pid); |
| 314 | |
| 315 | if (probe_entobj_cmpcxx . . $ probe_entobj_cmp(e245451a1311e799).(pid_ent, pid_sexp) != OVAL_RESULT_TRUEcxx . . $ OVAL_RESULT_TRUE.) { |
| 316 | SEXP_freecxx . . $ SEXP_free(c6b28547479798f4).(pid_sexp); |
| 317 | continue; |
| 318 | } |
| 319 | SEXP_freecxx . . $ SEXP_free(c6b28547479798f4).(pid_sexp); |
| 320 | |
| 321 | snprintfcxx . . $ snprintf(ea502d73e74c754c).(path, PATH_MAXcxx . . $ `<external>/6347054901304145714/limits.h:13:9`!, "%s/proc/%d/environ", prefix ? prefix : "", pid); |
| 322 | if ((fd = opencxx . . $ open(e156e3aa1e5c4ad1).(path, O_RDONLYcxx . . $ `<external>/14578502075116107718/fcntl-linux.h:43:9`!)) == -1) { |
| 323 | dEcxx . . $ `src/common/debug_priv.h:63:9`!("Can't open \"%s\": errno=%d, %s.", path, errnocxx . . $ `<external>/17633486526465735210/errno.h:38:10`!, strerror (errnocxx . . $ `<external>/17633486526465735210/errno.h:38:10`!)); |
| 324 | item = probe_item_createcxx . . $ probe_item_create(36b16a6622050a9c).( |
| 325 | OVAL_INDEPENDENT_ENVIRONMENT_VARIABLE58cxx . . $ OVAL_INDEPENDENT_ENVIRONMENT_VARIABLE58., NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!, |
| 326 | "pid", OVAL_DATATYPE_INTEGERcxx . . $ OVAL_DATATYPE_INTEGER., (int64_tcxx . . $ int64_t#)pid, |
| 327 | NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`! |
| 328 | ); |
| 329 | |
| 330 | probe_item_setstatuscxx . . $ probe_item_setstatus(112b785eb420e6c0).(item, SYSCHAR_STATUS_ERRORcxx . . $ SYSCHAR_STATUS_ERROR.); |
| 331 | probe_item_add_msgcxx . . $ probe_item_add_msg(c5b7a86259de5bd8).(item, OVAL_MESSAGE_LEVEL_ERRORcxx . . $ OVAL_MESSAGE_LEVEL_ERROR., |
| 332 | "Can't open \"%s\": errno=%d, %s.", path, errnocxx . . $ `<external>/17633486526465735210/errno.h:38:10`!, strerrorcxx . . $ strerror(ff224f080444ee45). (errnocxx . . $ `<external>/17633486526465735210/errno.h:38:10`!)); |
| 333 | probe_item_collectcxx . . $ probe_item_collect(11bb80e0c30650d7).(ctx, item); |
| 334 | continue; |
| 335 | } |
| 336 | |
| 337 | empty = truecxx . . $ `<external>/14268322491693841775/stdbool.h:37:9`!; |
| 338 | |
| 339 | if ((buffer_used = readcxx . . $ read(7e34d0a36f355389).(fd, buffer, buffer_size - 1)) > 0) { |
| 340 | empty = falsecxx . . $ `<external>/14268322491693841775/stdbool.h:38:9`!; |
| 341 | } |
| 342 | |
| 343 | while (! empty) { |
| 344 | while (! (null_char = memchrcxx . . $ memchr(3976b00ca259a364).(buffer, 0, buffer_used))) { |
| 345 | ssize_tcxx . . $ ssize_t# s; |
| 346 | if ((size_t)buffer_used >= buffer_size) { |
| 347 | buffer_size += BUFFER_SIZEcxx . . $ `src/OVAL/probes/independent/environmentvariable58_probe.c:235:9`!; |
| 348 | void *new_buffer = realloccxx . . $ realloc(417ab160f6baadc6).(buffer, buffer_size); |
| 349 | if (new_buffer == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) { |
| 350 | dEcxx . . $ `src/common/debug_priv.h:63:9`!("Can't re-allocate memory"); |
| 351 | freecxx . . $ free(5d22bdacc48458e8).(buffer); |
| 352 | closedircxx . . $ closedir(ac30a447bc7c2f80).(d); |
| 353 | closecxx . . $ close(7864480464b09eea).(fd); |
| 354 | return PROBE_ENOMEMcxx . . $ `src/OVAL/probes/public/probe-api.h:426:9`!; |
| 355 | } |
| 356 | buffer = new_buffer; |
| 357 | } |
| 358 | s = readcxx . . $ read(7e34d0a36f355389).(fd, buffer + buffer_used, buffer_size - buffer_used); |
| 359 | if (s <= 0) { |
| 360 | empty = truecxx . . $ `<external>/14268322491693841775/stdbool.h:37:9`!; |
| 361 | buffer[buffer_used++] = 0; |
| 362 | } |
| 363 | else { |
| 364 | buffer_used += s; |
| 365 | } |
| 366 | } |
| 367 | |
| 368 | do { |
| 369 | char *eq_char = strchrcxx . . $ strchr(2050848944e00d54).(buffer, '='); |
| 370 | if (eq_char == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) { |
| 371 | /* strange but possible: |
| 372 | * $ strings /proc/1218/environ |
| 373 | /dev/input/event0 /dev/input/event1 /dev/input/event4 /dev/input/event3 |
| 374 | */ |
| 375 | buffer_used -= null_char + 1 - buffer; |
| 376 | memmovecxx . . $ memmove(cc817cb175f282d).(buffer, null_char + 1, buffer_used); |
| 377 | continue; |
| 378 | } |
| 379 | |
| 380 | collect_variablecxx . . $ collect_variable(ccc4dd54a775b26).(buffer, eq_char - buffer, pid, name_ent, ctx); |
| 381 | |
| 382 | buffer_used -= null_char + 1 - buffer; |
| 383 | memmovecxx . . $ memmove(cc817cb175f282d).(buffer, null_char + 1, buffer_used); |
| 384 | } while ((null_char = memchrcxx . . $ memchr(3976b00ca259a364).(buffer, 0, buffer_used))); |
| 385 | } |
| 386 | |
| 387 | closecxx . . $ close(7864480464b09eea).(fd); |
| 388 | } |
| 389 | closedircxx . . $ closedir(ac30a447bc7c2f80).(d); |
| 390 | freecxx . . $ free(5d22bdacc48458e8).(buffer); |
| 391 | if (err) { |
| 392 | SEXP_tcxx . . $ SEXP_t# *msg = probe_msg_creatfcxx . . $ probe_msg_creatf(2da488f08a70551b).(OVAL_MESSAGE_LEVEL_ERRORcxx . . $ OVAL_MESSAGE_LEVEL_ERROR., |
| 393 | "Can't find process with requested PID."); |
| 394 | probe_cobj_add_msgcxx . . $ probe_cobj_add_msg(ef7ee42b5817e0be).(probe_ctx_getresultcxx . . $ probe_ctx_getresult(4299b6b53fa804a5).(ctx), msg); |
| 395 | SEXP_freecxx . . $ SEXP_free(c6b28547479798f4).(msg); |
| 396 | err = 0; |
| 397 | } |
| 398 | |
| 399 | return err; |
| 400 | } |
| 401 | #endif |
| 402 | |
| 403 | int environmentvariable58_probe_offline_mode_supportedcxx . . $ environmentvariable58_probe_offline_mode_supported(b126dc7c1de90089).(void) |
| 404 | { |
| 405 | return PROBE_OFFLINE_OWNcxx . . $ PROBE_OFFLINE_OWN.; |
| 406 | } |
| 407 | |
| 408 | int environmentvariable58_probe_maincxx . . $ environmentvariable58_probe_main(470536d3ffacaf10).(probe_ctxcxx . . $ probe_ctx# *ctx, void *arg) |
| 409 | { |
| 410 | SEXP_tcxx . . $ SEXP_t# *probe_in, *name_ent, *pid_ent; |
| 411 | int pid, err; |
| 412 | |
| 413 | probe_in = probe_ctx_getobjectcxx . . $ probe_ctx_getobject(4299b6b53fa804a5).(ctx); |
| 414 | name_ent = probe_obj_getentcxx . . $ probe_obj_getent(7907a01f2ff841f3).(probe_in, "name", 1); |
| 415 | |
| 416 | if (name_ent == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) { |
| 417 | return PROBE_ENOENTcxx . . $ `src/OVAL/probes/public/probe-api.h:433:9`!; |
| 418 | } |
| 419 | |
| 420 | pid_ent = probe_obj_getentcxx . . $ probe_obj_getent(7907a01f2ff841f3).(probe_in, "pid", 1); |
| 421 | if (pid_ent == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) { |
| 422 | SEXP_freecxx . . $ SEXP_free(c6b28547479798f4).(name_ent); |
| 423 | return PROBE_ENOENTcxx . . $ `src/OVAL/probes/public/probe-api.h:433:9`!; |
| 424 | } |
| 425 | |
| 426 | PROBE_ENT_I32VALcxx . . $ `src/OVAL/probes/public/probe-api.h:508:9`!(pid_ent, pid, pid = -1;, pid = 0;); |
| 427 | |
| 428 | if (pid == -1) { |
| 429 | SEXP_freecxx . . $ SEXP_free(c6b28547479798f4).(name_ent); |
| 430 | SEXP_freecxx . . $ SEXP_free(c6b28547479798f4).(pid_ent); |
| 431 | return PROBE_ERANGEcxx . . $ `src/OVAL/probes/public/probe-api.h:428:9`!; |
| 432 | } |
| 433 | |
| 434 | if (pid == 0) { |
| 435 | /* overwrite pid value with actual pid */ |
| 436 | SEXP_tcxx . . $ SEXP_t# *nref, *nval, *new_pid_ent; |
| 437 | |
| 438 | nref = SEXP_list_firstcxx . . $ SEXP_list_first(2f7f980afaaae0f0).(probe_in); |
| 439 | nval = SEXP_number_newu_32cxx . . $ SEXP_number_newu_32(8a1232211d6fd92a).(getpidcxx . . $ getpid(b126dc7c1de90089).()); |
| 440 | new_pid_ent = SEXP_list_newcxx . . $ SEXP_list_new(902e4f76566c8810).(nref, nval, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!); |
| 441 | SEXP_freecxx . . $ SEXP_free(c6b28547479798f4).(pid_ent); |
| 442 | SEXP_freecxx . . $ SEXP_free(c6b28547479798f4).(nref); |
| 443 | SEXP_freecxx . . $ SEXP_free(c6b28547479798f4).(nval); |
| 444 | pid_ent = new_pid_ent; |
| 445 | } |
| 446 | |
| 447 | err = read_environmentcxx . . $ read_environment(8cb7114d8bc47ec5).(pid_ent, name_ent, ctx); |
| 448 | |
| 449 | SEXP_freecxx . . $ SEXP_free(c6b28547479798f4).(name_ent); |
| 450 | SEXP_freecxx . . $ SEXP_free(c6b28547479798f4).(pid_ent); |
| 451 | |
| 452 | return err; |
| 453 | } |