|
Chris PeBenito |
473ea7 |
.TH "matchpathcon" "3" "16 March 2005" "sds@tycho.nsa.gov" "SE Linux API documentation"
|
|
Chris PeBenito |
473ea7 |
.SH "NAME"
|
|
Chris PeBenito |
473ea7 |
matchpathcon \- get the default security context for the specified path from the file contexts configuration.
|
|
Chris PeBenito |
473ea7 |
|
|
Chris PeBenito |
473ea7 |
.SH "SYNOPSIS"
|
|
Chris PeBenito |
473ea7 |
.B #include <selinux/selinux.h>
|
|
Chris PeBenito |
473ea7 |
.sp
|
|
Chris PeBenito |
473ea7 |
.BI "int matchpathcon_init(const char *" path ");"
|
|
Chris PeBenito |
473ea7 |
.br
|
|
Chris PeBenito |
473ea7 |
.BI "int matchpathcon(const char *" path ", mode_t " mode ", security_context_t *" con);
|
|
Chris PeBenito |
473ea7 |
.sp
|
|
Chris PeBenito |
473ea7 |
.br
|
|
Chris PeBenito |
473ea7 |
.BI "void set_matchpathcon_printf(void (*" f ")(const char *" fmt ", ...));"
|
|
Chris PeBenito |
473ea7 |
.br
|
|
Chris PeBenito |
473ea7 |
.BI "void set_matchpathcon_invalidcon(int (*" f ")(const char *"path ", unsigned " lineno ", char * " context "));"
|
|
Chris PeBenito |
473ea7 |
.br
|
|
Chris PeBenito |
473ea7 |
.BI "void set_matchpathcon_flags(unsigned int " flags ");"
|
|
Chris PeBenito |
473ea7 |
.br
|
|
Chris PeBenito |
473ea7 |
.SH "DESCRIPTION"
|
|
Chris PeBenito |
473ea7 |
.B matchpathcon_init
|
|
Chris PeBenito |
473ea7 |
loads the file contexts configuration specified by
|
|
Chris PeBenito |
473ea7 |
.I path
|
|
Chris PeBenito |
473ea7 |
into memory for use by subsequent
|
|
Chris PeBenito |
473ea7 |
.B matchpathcon
|
|
Chris PeBenito |
473ea7 |
calls. If
|
|
Chris PeBenito |
473ea7 |
.I path
|
|
Chris PeBenito |
473ea7 |
is NULL, then the active file contexts configuration is loaded by default,
|
|
Chris PeBenito |
473ea7 |
i.e. the path returned by
|
|
Chris PeBenito |
473ea7 |
.B selinux_file_context_path(3).
|
|
Chris PeBenito |
473ea7 |
Unless the
|
|
Chris PeBenito |
473ea7 |
.B MATCHPATHCON_BASEONLY
|
|
Chris PeBenito |
473ea7 |
flag has been set via
|
|
Chris PeBenito |
473ea7 |
.B set_matchpathcon_flags,
|
|
Chris PeBenito |
473ea7 |
files with the same path prefix but a
|
|
Chris PeBenito |
473ea7 |
.B .homedirs
|
|
Chris PeBenito |
473ea7 |
and
|
|
Chris PeBenito |
473ea7 |
.B .local
|
|
Chris PeBenito |
473ea7 |
suffix are also looked up and loaded if present. These files provide
|
|
Chris PeBenito |
473ea7 |
dynamically generated entries for user home directories and for local
|
|
Chris PeBenito |
473ea7 |
customizations.
|
|
Chris PeBenito |
473ea7 |
.br
|
|
Chris PeBenito |
473ea7 |
.sp
|
|
Chris PeBenito |
473ea7 |
.B matchpathcon
|
|
Chris PeBenito |
473ea7 |
matches the specified pathname and mode against the file contexts
|
|
Chris PeBenito |
473ea7 |
configuration and sets the security context
|
|
Chris PeBenito |
473ea7 |
.I con
|
|
Chris PeBenito |
473ea7 |
to refer to the
|
|
Chris PeBenito |
473ea7 |
resulting context. The caller must free the returned security context
|
|
Chris PeBenito |
473ea7 |
.I con
|
|
Chris PeBenito |
473ea7 |
using freecon when finished using it.
|
|
Chris PeBenito |
473ea7 |
.I mode
|
|
Chris PeBenito |
473ea7 |
can be 0 to disable mode matching, but
|
|
Chris PeBenito |
473ea7 |
should be provided whenever possible, as it may affect the matching.
|
|
Chris PeBenito |
473ea7 |
Only the file format bits (i.e. the file type) of the
|
|
Chris PeBenito |
473ea7 |
.I mode
|
|
Chris PeBenito |
473ea7 |
are used.
|
|
Chris PeBenito |
473ea7 |
If
|
|
Chris PeBenito |
473ea7 |
.B matchpathcon_init
|
|
Chris PeBenito |
473ea7 |
has not already been called, then this function will call it upon
|
|
Chris PeBenito |
473ea7 |
its first invocation with a NULL
|
|
Chris PeBenito |
473ea7 |
.I path,
|
|
Chris PeBenito |
473ea7 |
defaulting to the active file contexts configuration.
|
|
Chris PeBenito |
473ea7 |
.sp
|
|
Chris PeBenito |
473ea7 |
.br
|
|
Chris PeBenito |
473ea7 |
.B set_matchpathcon_printf
|
|
Chris PeBenito |
473ea7 |
sets the function used by
|
|
Chris PeBenito |
473ea7 |
.B matchpathcon_init
|
|
Chris PeBenito |
473ea7 |
when displaying errors about the file contexts configuration. If not set,
|
|
Chris PeBenito |
473ea7 |
then this defaults to fprintf(stderr, fmt, ...). This can be set to redirect
|
|
Chris PeBenito |
473ea7 |
error reporting to a different destination.
|
|
Chris PeBenito |
473ea7 |
.br
|
|
Chris PeBenito |
473ea7 |
.sp
|
|
Chris PeBenito |
473ea7 |
.B set_matchpathcon_invalidcon
|
|
Chris PeBenito |
473ea7 |
sets the function used by
|
|
Chris PeBenito |
473ea7 |
.B matchpathcon_init
|
|
Chris PeBenito |
473ea7 |
when checking the validity of a context in the file contexts
|
|
Chris PeBenito |
473ea7 |
configuration. If not set, then this defaults to a test based
|
|
Chris PeBenito |
473ea7 |
on
|
|
Chris PeBenito |
473ea7 |
.B security_check_context(3),
|
|
Chris PeBenito |
473ea7 |
which checks validity against the active policy on a SELinux system.
|
|
Chris PeBenito |
473ea7 |
This can be set to instead perform checking based on a binary policy file,
|
|
Chris PeBenito |
473ea7 |
e.g. using
|
|
Chris PeBenito |
473ea7 |
.B sepol_check_context(3),
|
|
Chris PeBenito |
473ea7 |
as is done by
|
|
Chris PeBenito |
473ea7 |
.B setfiles -c.
|
|
Chris PeBenito |
473ea7 |
The function is also responsible for reporting any such error, and
|
|
Chris PeBenito |
473ea7 |
may include the
|
|
Chris PeBenito |
473ea7 |
.I path
|
|
Chris PeBenito |
473ea7 |
and
|
|
Chris PeBenito |
473ea7 |
.I lineno
|
|
Chris PeBenito |
473ea7 |
in such error messages.
|
|
Chris PeBenito |
473ea7 |
.br
|
|
Chris PeBenito |
473ea7 |
.sp
|
|
Chris PeBenito |
473ea7 |
.B set_matchpathcon_flags
|
|
Chris PeBenito |
473ea7 |
sets flags controlling the operation of
|
|
Chris PeBenito |
473ea7 |
.B matchpathcon_init
|
|
Chris PeBenito |
473ea7 |
or
|
|
Chris PeBenito |
473ea7 |
.B matchpathcon.
|
|
Chris PeBenito |
473ea7 |
If the
|
|
Chris PeBenito |
473ea7 |
.B MATCHPATHCON_BASEONLY
|
|
Chris PeBenito |
473ea7 |
flag is set, then only the base file contexts configuration file
|
|
Chris PeBenito |
473ea7 |
will be processed, not any dynamically generated entries or local customizations.
|
|
Chris PeBenito |
473ea7 |
.br
|
|
Chris PeBenito |
473ea7 |
.sp
|
|
Chris PeBenito |
473ea7 |
.SH "RETURN VALUE"
|
|
Chris PeBenito |
473ea7 |
Returns 0 on success or -1 otherwise.
|
|
Chris PeBenito |
473ea7 |
|
|
Chris PeBenito |
473ea7 |
.SH "SEE ALSO"
|
|
Chris PeBenito |
473ea7 |
.BR freecon "(3), " setfilecon "(3), " setfscreatecon "(3)"
|