Contains the functions to return resource traits that will be used to compare with a user's defined policy and evaluate the access request.
#include "am_policy.h" typedef struct am_resource_traits { am_resource_match_t (*cmp_func_ptr)(const struct am_resource_traits *rsrc_traits, const char *policy_res_name, const char *resource_name, boolean_t use_patterns); boolean_t (*has_patterns)(const char *resource_name); boolean_t (*get_resource_root)(const char *resource_name, char *root_resource_name, size_t buflength); boolean_t ignore_case; char separator; void (*canonicalize)(const char *resource, char **c_resource); void (*str_free)(void *resource_str); } am_resource_traits_t;
Pointer to a function that compares policy_res_name and resource_name to return one of the following values of the am_resource_match_t enumeration (defined in the <am_policy.h> header file):
typedef enum am_resource_match { AM_SUB_RESOURCE_MATCH, AM_EXACT_MATCH, AM_SUPER_RESOURCE_MATCH, AM_NO_MATCH, AM_EXACT_PATTERN_MATCH } am_resource_match_t;
cmp_func_ptr can point to am_policy_compare_urls() to evaluate URL resources.
Pointer to the resource traits structure containing data regarding a policy.
Pointer to the name of the resource being protected.
Pointer to the name of the resource being requested.
Based on the boolean_t defined in the <am_types.h> header file, B_TRUE indicates that the function will use or recognize patterns when comparing resources.
Pointer to a function that determines whether a resource has patterns and returns one of the following values of the boolean_t enumeration defined in the <am_types.h> header file:
If resource_name has patterns.
Otherwise.
has_patterns can point to am_policy_resource_has_patterns() for URL resources.
Pointer to the name of the resource being requested.
Pointer to a function that extracts the root of the specified resource and returns one of the following values of the boolean_t enumeration defined in the <am_types.h> header file:
If the resource root was successfully inserted into the specified root_resource_name buffer.
Otherwise.
get_resource_root can point to am_policy_get_url_resource_root() for URL resources.
Pointer to the name of the resource being requested.
Buffer to hold the resource root.
Value based on the size_t defined in the standard <stddef.h> header file that reflects the length of the root_resource_name buffer.
Value that takes one of the following values of the boolean_t enumeration defined in the <am_types.h> header file:
Ignore case for all functions in this structure.
Otherwise.
Defines the resource separator. For URLs / should be used.
Pointer to a function that converts the specified resource name into a standard representation for comparative purposes.
Pointer to a resource name. This could be the resource being requested or the resource defined in the policy.
Output of the canonical resource name.
Memory for the canonical name must be allocated by the caller. A function to free the allocated memory must be set in str_free.
Pointer to a function to free a c_resource string after the results have been evaluated by am_policy_evaluate(). This field cannot be set to NULL.
free() should be used if canonicalize is set to the am_policy_resource_canonicalize() function.
Pointer to the string returned in the canonicalize function.