| 1 | /** |
| 2 | * @file environmentvariable_probe.c |
| 3 | * @brief environmentvariable probe |
| 4 | * @author "Petr Lautrbach" <[email protected]> |
| 5 | * |
| 6 | * This probe is able to process a environmentvariable_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 | * environmentvariable probe: |
| 34 | * |
| 35 | * name |
| 36 | * value |
| 37 | */ |
| 38 | |
| 39 | #ifdef HAVE_CONFIG_Hcxx . . $ `<built-in>:409:9`! |
| 40 | #include <config.h>cxx . . $ `<file>/build/config.h`/ |
| 41 | #endif |
| 42 | |
| 43 | #include <stdlib.h> |
| 44 | #include <string.h> |
| 45 | #include <stdio.h> |
| 46 | #include <errno.h> |
| 47 | |
| 48 | #include "_seap.h"cxx . . $ `<file>/src/OVAL/probes/SEAP/_seap.h`/ |
| 49 | #include "probe-api.h"cxx . . $ `<file>/src/OVAL/probes/public/probe-api.h`/ |
| 50 | #include "probe/entcmp.h"cxx . . $ `<file>/src/OVAL/probes/probe/entcmp.h`/ |
| 51 | #include "environmentvariable_probe.h"cxx . . $ `<file>/src/OVAL/probes/independent/environmentvariable_probe.h`/ |
| 52 | |
| 53 | extern char **environcxx . . $ environ.; |
| 54 | |
| 55 | static int read_environmentcxx . . $ read_environment(241d6c535218441).(SEXP_tcxx . . $ SEXP_t# *un_ent, probe_ctxcxx . . $ probe_ctx# *ctx) |
| 56 | { |
| 57 | int err = 1; |
| 58 | char **env; |
| 59 | size_t env_name_size; |
| 60 | SEXP_tcxx . . $ SEXP_t# *env_name, *env_value, *item; |
| 61 | |
| 62 | for (env = environcxx . . $ environ.; *env != 0; env++) { |
| 63 | env_name_size = strchrcxx . . $ strchr(2050848944e00d54).(*env, '=') - *env; |
| 64 | env_name = SEXP_string_newcxx . . $ SEXP_string_new(a588a58d7514eee2).(*env, env_name_size); |
| 65 | env_value = SEXP_string_newfcxx . . $ SEXP_string_newf(b2137ed863725962).("%s", *env + env_name_size + 1); |
| 66 | if (probe_entobj_cmpcxx . . $ probe_entobj_cmp(e245451a1311e799).(un_ent, env_name) == OVAL_RESULT_TRUEcxx . . $ OVAL_RESULT_TRUE.) { |
| 67 | item = probe_item_createcxx . . $ probe_item_create(36b16a6622050a9c).( |
| 68 | OVAL_INDEPENDENT_ENVIRONMENT_VARIABLEcxx . . $ OVAL_INDEPENDENT_ENVIRONMENT_VARIABLE., NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!, |
| 69 | "name", OVAL_DATATYPE_SEXPcxx . . $ OVAL_DATATYPE_SEXP., env_name, |
| 70 | "value", OVAL_DATATYPE_SEXPcxx . . $ OVAL_DATATYPE_SEXP., env_value, |
| 71 | NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!); |
| 72 | probe_item_collectcxx . . $ probe_item_collect(11bb80e0c30650d7).(ctx, item); |
| 73 | err = 0; |
| 74 | } |
| 75 | SEXP_freecxx . . $ SEXP_free(c6b28547479798f4).(env_name); |
| 76 | SEXP_freecxx . . $ SEXP_free(c6b28547479798f4).(env_value); |
| 77 | } |
| 78 | return err; |
| 79 | } |
| 80 | |
| 81 | int environmentvariable_probe_maincxx . . $ environmentvariable_probe_main(470536d3ffacaf10).(probe_ctxcxx . . $ probe_ctx# *ctx, void *arg) |
| 82 | { |
| 83 | SEXP_tcxx . . $ SEXP_t# *probe_in, *ent; |
| 84 | |
| 85 | probe_in = probe_ctx_getobjectcxx . . $ probe_ctx_getobject(4299b6b53fa804a5).(ctx); |
| 86 | ent = probe_obj_getentcxx . . $ probe_obj_getent(7907a01f2ff841f3).(probe_in, "name", 1); |
| 87 | |
| 88 | if (ent == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) { |
| 89 | return PROBE_ENOVALcxx . . $ `src/OVAL/probes/public/probe-api.h:423:9`!; |
| 90 | } |
| 91 | |
| 92 | read_environmentcxx . . $ read_environment(241d6c535218441).(ent, ctx); |
| 93 | SEXP_freecxx . . $ SEXP_free(c6b28547479798f4).(ent); |
| 94 | |
| 95 | return 0; |
| 96 | } |