static inline oval_result_t _evaluate_sysent(struct oval_syschar_model *syschar_model, struct oval_sysent *item_entity, struct oval_entity *state_entity, oval_operation_t state_entity_operation, struct oval_state_content *content) { if (oval_sysent_get_status(item_entity) == SYSCHAR_STATUS_DOES_NOT_EXIST) { return OVAL_RESULT_FALSE; } else if (oval_entity_get_varref_type(state_entity) == OVAL_ENTITY_VARREF_ATTRIBUTE) { return _evaluate_sysent_with_variable(syschar_model, state_entity, item_entity, state_entity_operation, content); } else { struct oval_value *state_entity_val; char *state_entity_val_text; oval_datatype_t state_entity_val_datatype; if ((state_entity_val = oval_entity_get_value(state_entity)) == NULL) { oscap_seterr(OSCAP_EFAMILY_OVAL, "OVAL internal error: found NULL entity value"); return -1; } if ((state_entity_val_text = oval_value_get_text(state_entity_val)) == NULL) { oscap_seterr(OSCAP_EFAMILY_OVAL, "OVAL internal error: found NULL entity value text"); return -1; } state_entity_val_datatype = oval_value_get_datatype(state_entity_val); return oval_ent_cmp_str(state_entity_val_text, state_entity_val_datatype, item_entity, state_entity_operation); } }
static struct oval_value *oval_object_getentval(struct oval_object *obj, const char *name) { struct oval_value *val; struct oval_entity *ent; struct oval_object_content *con; struct oval_object_content_iterator *cit; char *ent_name; cit = oval_object_get_object_contents(obj); val = NULL; while (oval_object_content_iterator_has_more(cit)) { con = oval_object_content_iterator_next(cit); if (oval_object_content_get_type(con) != OVAL_OBJECTCONTENT_ENTITY) continue; ent = oval_object_content_get_entity(con); ent_name = oval_entity_get_name(ent); if (strcmp(ent_name, name) != 0) continue; val = oval_entity_get_value(ent); break; } oval_object_content_iterator_free(cit); return(val); }
struct oval_entity *oval_entity_clone(struct oval_definition_model *new_model, struct oval_entity *old_entity) { struct oval_entity *new_entity = oval_entity_new(new_model); oval_datatype_t datatype = oval_entity_get_datatype(old_entity); oval_entity_set_datatype(new_entity, datatype); int mask = oval_entity_get_mask(old_entity); oval_entity_set_mask(new_entity, mask); bool xsi_nil = oval_entity_get_xsi_nil(old_entity); oval_entity_set_xsi_nil(new_entity, xsi_nil); char *name = oval_entity_get_name(old_entity); oval_entity_set_name(new_entity, name); oval_operation_t operation = oval_entity_get_operation(old_entity); oval_entity_set_operation(new_entity, operation); oval_entity_type_t type = oval_entity_get_type(old_entity); oval_entity_set_type(new_entity, type); struct oval_value *value = oval_entity_get_value(old_entity); if (value) { oval_entity_set_value(new_entity, oval_value_clone(value)); } struct oval_variable *old_variable = oval_entity_get_variable(old_entity); if (old_variable) { oval_entity_set_variable(new_entity, oval_variable_clone(new_model, old_variable)); } oval_entity_varref_type_t reftype = oval_entity_get_varref_type(old_entity); oval_entity_set_varref_type(new_entity, reftype); return new_entity; }
static SEXP_t *oval_entity_to_sexp(struct oval_entity *ent) { SEXP_t *elm, *elm_name; SEXP_t *r0, *r1, *r2; oval_datatype_t datatype; oval_entity_varref_type_t vr_type; elm_name = SEXP_list_new(r0 = SEXP_string_newf("%s", oval_entity_get_name(ent)), /* operation */ r1 = SEXP_string_new(":operation", 10), r2 = SEXP_number_newu_32(oval_entity_get_operation(ent)), NULL); SEXP_vfree(r0, r1, r2, NULL); if (oval_entity_get_mask(ent)) { SEXP_list_add(elm_name, r0 = SEXP_string_new("mask", 4)); SEXP_free(r0); } elm = SEXP_list_new(NULL); datatype = oval_entity_get_datatype(ent); probe_ent_setdatatype(elm, datatype); vr_type = oval_entity_get_varref_type(ent); if (vr_type == OVAL_ENTITY_VARREF_ATTRIBUTE || vr_type == OVAL_ENTITY_VARREF_ELEMENT) { /* var_ref */ struct oval_variable *var; var = oval_entity_get_variable(ent); SEXP_list_add(elm_name, r0 = SEXP_string_new(":var_ref", 8)); SEXP_list_add(elm_name, r1 = SEXP_string_newf("%s", oval_variable_get_id(var))); SEXP_list_add(elm, elm_name); SEXP_vfree(r0, r1, elm_name, NULL); } else { /* value */ struct oval_value *val; SEXP_list_add(elm, elm_name); SEXP_free(elm_name); val = oval_entity_get_value(ent); if (datatype != OVAL_DATATYPE_RECORD && val != NULL) { SEXP_t *val_sexp; val_sexp = oval_value_to_sexp(val, datatype); if (val_sexp != NULL) { SEXP_list_add(elm, val_sexp); SEXP_free(val_sexp); } } } return (elm); }