| 1 | /* |
| 2 | * Copyright 2013 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 | * Šimon Lukašík |
| 21 | */ |
| 22 | |
| 23 | #ifdef HAVE_CONFIG_Hcxx . . $ `<built-in>:409:9`! |
| 24 | #include <config.h>cxx . . $ `<file>/build/config.h`/ |
| 25 | #endif |
| 26 | |
| 27 | #include "public/oval_definitions.h"cxx . . $ `<file>/src/OVAL/public/oval_definitions.h`/ |
| 28 | #include "public/oval_system_characteristics.h"cxx . . $ `<file>/src/OVAL/public/oval_system_characteristics.h`/ |
| 29 | #include "oval_system_characteristics_impl.h"cxx . . $ `<file>/src/OVAL/oval_system_characteristics_impl.h`/ |
| 30 | #include "oval_probe_impl.h"cxx . . $ `<file>/src/OVAL/oval_probe_impl.h`/ |
| 31 | #include "_oval_probe_session.h"cxx . . $ `<file>/src/OVAL/_oval_probe_session.h`/ |
| 32 | |
| 33 | static int _oval_probe_hint_criteriacxx . . $ _oval_probe_hint_criteria(a9d577ca8fbcc336).(oval_probe_session_tcxx . . $ oval_probe_session_t# *sess, struct oval_criteria_nodecxx . . $ oval_criteria_node# *cnode, int variable_instance_hint); |
| 34 | static int _oval_probe_hint_objectcxx . . $ _oval_probe_hint_object(3a2062b6777ae323).(oval_probe_session_tcxx . . $ oval_probe_session_t# *psess, struct oval_objectcxx . . $ oval_object# *object, int variable_instance_hint); |
| 35 | |
| 36 | /** |
| 37 | * Finds all the oval_syschars (collected objects) assigned with a given definition |
| 38 | * and sets the variable_instance_hint attribute thereof. That is to mark these |
| 39 | * collected objects with the hint that a new round of collection might be needed |
| 40 | * when these objects are again probed by @ref oval_probe_query_object. That is |
| 41 | * usefull when a new variable instance is injected into the oval_agent_session. |
| 42 | * @param variable_instance_hint new hint to set |
| 43 | * @returns 0 on success; -1 on error; 1 on warning |
| 44 | */ |
| 45 | int oval_probe_hint_definitioncxx . . $ oval_probe_hint_definition(5d78fc105d549255).(oval_probe_session_tcxx . . $ oval_probe_session_t# *sess, struct oval_definitioncxx . . $ oval_definition# *definition, int variable_instance_hint) |
| 46 | { |
| 47 | if (definition == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) |
| 48 | return -1; |
| 49 | struct oval_criteria_nodecxx . . $ oval_criteria_node# *cnode = oval_definition_get_criteriacxx . . $ oval_definition_get_criteria(65398e133db0196).(definition); |
| 50 | if (cnode == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) |
| 51 | return -1; |
| 52 | |
| 53 | return _oval_probe_hint_criteriacxx . . $ _oval_probe_hint_criteria(a9d577ca8fbcc336).(sess, cnode, variable_instance_hint); |
| 54 | } |
| 55 | |
| 56 | int _oval_probe_hint_criteriacxx . . $ _oval_probe_hint_criteria(a9d577ca8fbcc336).(oval_probe_session_tcxx . . $ oval_probe_session_t# *sess, struct oval_criteria_nodecxx . . $ oval_criteria_node# *cnode, int variable_instance_hint) |
| 57 | { |
| 58 | switch (oval_criteria_node_get_typecxx . . $ oval_criteria_node_get_type(ef81df196a9c20f6).(cnode)) { |
| 59 | case OVAL_NODETYPE_CRITERIONcxx . . $ OVAL_NODETYPE_CRITERION.:{ |
| 60 | struct oval_testcxx . . $ oval_test# *test = oval_criteria_node_get_testcxx . . $ oval_criteria_node_get_test(a0ab3911a55a3308).(cnode); |
| 61 | if (test == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) |
| 62 | return 0; |
| 63 | struct oval_objectcxx . . $ oval_object# *object = oval_test_get_objectcxx . . $ oval_test_get_object(7733aadd35446dd9).(test); |
| 64 | if (object == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) |
| 65 | return 0; |
| 66 | // TODO: Do we need to similarly hint all the object refereced like: test->state->variable->object? |
| 67 | return _oval_probe_hint_objectcxx . . $ _oval_probe_hint_object(3a2062b6777ae323).(sess, object, variable_instance_hint); |
| 68 | } |
| 69 | case OVAL_NODETYPE_CRITERIAcxx . . $ OVAL_NODETYPE_CRITERIA.:{ |
| 70 | struct oval_criteria_node_iteratorcxx . . $ oval_criteria_node_iterator# *cnode_it = oval_criteria_node_get_subnodescxx . . $ oval_criteria_node_get_subnodes(664e31975832357a).(cnode); |
| 71 | if (cnode_it == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) |
| 72 | return 0; |
| 73 | int ret = 0; |
| 74 | while (ret == 0 && oval_criteria_node_iterator_has_morecxx . . $ oval_criteria_node_iterator_has_more(1d7c354b15b37d35).(cnode_it)) { |
| 75 | struct oval_criteria_nodecxx . . $ oval_criteria_node# *node = oval_criteria_node_iterator_nextcxx . . $ oval_criteria_node_iterator_next(6cad1f2abc1761f6).(cnode_it); |
| 76 | ret = _oval_probe_hint_criteriacxx . . $ _oval_probe_hint_criteria(a9d577ca8fbcc336).(sess, node, variable_instance_hint); |
| 77 | } |
| 78 | oval_criteria_node_iterator_freecxx . . $ oval_criteria_node_iterator_free(dc39dde275a510d9).(cnode_it); |
| 79 | return ret; |
| 80 | } |
| 81 | case OVAL_NODETYPE_EXTENDDEFcxx . . $ OVAL_NODETYPE_EXTENDDEF.:{ |
| 82 | struct oval_definitioncxx . . $ oval_definition# *oval_def = oval_criteria_node_get_definitioncxx . . $ oval_criteria_node_get_definition(c20eec0d71e88e87).(cnode); |
| 83 | return oval_probe_hint_definitioncxx . . $ oval_probe_hint_definition(5d78fc105d549255).(sess, oval_def, variable_instance_hint); |
| 84 | } |
| 85 | case OVAL_NODETYPE_UNKNOWNcxx . . $ OVAL_NODETYPE_UNKNOWN.:{ |
| 86 | assertcxx . . $ `<external>/4398592474888995393/assert.h:50:10`!(false); |
| 87 | return -1; |
| 88 | } |
| 89 | } |
| 90 | return -1; |
| 91 | } |
| 92 | |
| 93 | int _oval_probe_hint_objectcxx . . $ _oval_probe_hint_object(3a2062b6777ae323).(oval_probe_session_tcxx . . $ oval_probe_session_t# *psess, struct oval_objectcxx . . $ oval_object# *object, int variable_instance_hint) |
| 94 | { |
| 95 | const char *oid = oval_object_get_idcxx . . $ oval_object_get_id(c789946d38fecc83).(object); |
| 96 | struct oval_syscharcxx . . $ oval_syschar# *syschar = oval_syschar_model_get_syscharcxx . . $ oval_syschar_model_get_syschar(5e0330551a5ec218).(psess->sys_modelcxx . . $ oval_probe_session#sys_model., oid); |
| 97 | if (syschar != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) { |
| 98 | oval_syschar_set_variable_instance_hintcxx . . $ oval_syschar_set_variable_instance_hint(aae0a0c13cad9911).(syschar, variable_instance_hint); |
| 99 | } |
| 100 | return 0; |
| 101 | } |