int matchpathcon_init(const char *path);
int matchpathcon(const char *path, mode_t mode, security_context_t *con);
void set_matchpathcon_printf(void (*f)(const char *fmt, ...));
void set_matchpathcon_invalidcon(int (*f)(const char *path, unsigned lineno, char * context));
void set_matchpathcon_flags(unsigned int flags);
frees the memory allocated by a prior call to
This function can be used to free and reset the internal state between multiple
calls, or to free memory when finished using
matchpathcon matches the specified pathname and mode against the file contexts configuration and sets the security context con to refer to the resulting context. The caller must free the returned security context con using freecon when finished using it. mode can be 0 to disable mode matching, but should be provided whenever possible, as it may affect the matching. Only the file format bits (i.e. the file type) of the mode are used. If matchpathcon_init has not already been called, then this function will call it upon its first invocation with a NULL path, defaulting to the active file contexts configuration.
set_matchpathcon_printf sets the function used by matchpathcon_init when displaying errors about the file contexts configuration. If not set, then this defaults to fprintf(stderr, fmt, ...). This can be set to redirect error reporting to a different destination.
sets the function used by
when checking the validity of a context in the file contexts
configuration. If not set, then this defaults to a test based
which checks validity against the active policy on a SELinux system.
This can be set to instead perform checking based on a binary policy file,
as is done by
The function is also responsible for reporting any such error, and
may include the
in such error messages.
sets flags controlling the operation of
flag is set, then only the base file contexts configuration file
will be processed, not any dynamically generated entries or local customizations.