selabel_lookup_best_match_raw (3) - Linux Man Pages
selabel_lookup_best_match_raw: obtain a best match SELinux security
selabel_lookup_best_match - obtain a best match SELinux security context - Only supported on file backend.
int selabel_lookup_best_match(struct selabel_handle *hnd,
const char *key,
const char **links,
DESCRIPTIONselabel_lookup_best_match() performs a best match lookup operation on the handle hnd, returning the result in the memory pointed to by context, which must be freed by the caller using freecon(3). The key parameter is a file path to check for best match using zero or more link (aliases) parameters. The order of precedence for best match is:
- An exact match for the real path (key) or
- An exact match for any of the links (aliases), or
- The longest fixed prefix match.
The type parameter is an optional file mode argument that should be set to the mode bits of the file, as determined by lstat(2). mode may be zero, however full matching may not occur.
RETURN VALUEOn success, zero is returned. On error, -1 is returned and errno is set appropriately.
- No context corresponding to the input key and type was found.
- The key and/or type inputs are invalid, or the context being returned failed validation.
An attempt to allocate memory failed.