207 lines
5.6 KiB
HTML
207 lines
5.6 KiB
HTML
|
|
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
|
|
<HTML><HEAD><TITLE>Man page of matchpathcon</TITLE>
|
|
</HEAD><BODY>
|
|
<H1>matchpathcon</H1>
|
|
Section: SELinux API documentation (3)<BR>Updated: 21 November 2009<BR><A HREF="#index">Index</A>
|
|
<A HREF="/cgi-bin/man/man2html">Return to Main Contents</A><HR>
|
|
|
|
<A NAME="lbAB"> </A>
|
|
<H2>NAME</H2>
|
|
|
|
matchpathcon, matchpathcon_index - get the default SELinux security context for the specified path from the file contexts configuration
|
|
<A NAME="lbAC"> </A>
|
|
<H2>SYNOPSIS</H2>
|
|
|
|
<B>#include <<A HREF="file:///usr/include/selinux/selinux.h">selinux/selinux.h</A>></B>
|
|
|
|
<P>
|
|
<B>int matchpathcon_init(const char *</B><I>path</I><B>);</B>
|
|
|
|
<P>
|
|
<B>int matchpathcon_init_prefix(const char *</B><I>path</I><B>, const char *</B><I>prefix</I><B>);</B>
|
|
|
|
<P>
|
|
<B>int matchpathcon_fini(void);</B>
|
|
|
|
<P>
|
|
<B>int matchpathcon(const char *</B><I>path</I><B>, mode_t </B><I>mode</I><B>, char **</B><I>con</I><B>);</B>
|
|
|
|
<P>
|
|
<B>int matchpathcon_index(const char *</B><I>name</I><B>, mode_t </B><I>mode</I><B>, char **</B><I>con</I><B>);</B>
|
|
|
|
<A NAME="lbAD"> </A>
|
|
<H2>DESCRIPTION</H2>
|
|
|
|
<P>
|
|
This family of functions is deprecated. For new code, please use
|
|
<B><A HREF="/cgi-bin/man/man2html?3+selabel_open">selabel_open</A></B>(3)
|
|
|
|
with the
|
|
<B>SELABEL_CTX_FILE</B>
|
|
|
|
backend in place of
|
|
<B>matchpathcon_init</B>(),
|
|
|
|
use
|
|
<B><A HREF="/cgi-bin/man/man2html?3+selabel_close">selabel_close</A></B>(3)
|
|
|
|
in place of
|
|
<B>matchpathcon_fini</B>(),
|
|
|
|
and use
|
|
<B><A HREF="/cgi-bin/man/man2html?3+selabel_lookup">selabel_lookup</A></B>(3)
|
|
|
|
in place of
|
|
<B>matchpathcon</B>().
|
|
|
|
<P>
|
|
The remaining description below is for the legacy interface.
|
|
<P>
|
|
<B>matchpathcon_init</B>()
|
|
|
|
loads the file contexts configuration specified by
|
|
<I>path</I>
|
|
|
|
into memory for use by subsequent
|
|
<B>matchpathcon</B>()
|
|
|
|
calls. If
|
|
<I>path</I>
|
|
|
|
is NULL, then the active file contexts configuration is loaded by default,
|
|
i.e. the path returned by
|
|
<B><A HREF="/cgi-bin/man/man2html?3+selinux_file_context_path">selinux_file_context_path</A></B>(3).
|
|
|
|
Unless the
|
|
<B>MATCHPATHCON_BASEONLY </B>
|
|
|
|
flag has been set via
|
|
<B><A HREF="/cgi-bin/man/man2html?3+set_matchpathcon_flags">set_matchpathcon_flags</A></B>(3),
|
|
|
|
files with the same path prefix but a
|
|
<B>.homedirs</B>
|
|
|
|
and
|
|
<B>.local</B>
|
|
|
|
suffix are also looked up and loaded if present. These files provide
|
|
dynamically generated entries for user home directories and for local
|
|
customizations.
|
|
<P>
|
|
<B>matchpathcon_init_prefix</B>()
|
|
|
|
is the same as
|
|
<B>matchpathcon_init</B>()
|
|
|
|
but only loads entries with regular expressions whose first pathname
|
|
component is a prefix of
|
|
<I>prefix</I>
|
|
|
|
, e.g. pass "/dev" if you only intend to call
|
|
<B>matchpathcon</B>()
|
|
|
|
with pathnames beginning with /dev.
|
|
However, this optimization is no longer necessary due to the use of
|
|
<I>file_contexts.bin</I>
|
|
|
|
files with precompiled regular expressions, so use of this interface
|
|
is deprecated.
|
|
<P>
|
|
<B>matchpathcon_fini</B>()
|
|
|
|
frees the memory allocated by a prior call to
|
|
<B>matchpathcon_init.</B>()
|
|
|
|
This function can be used to free and reset the internal state between multiple
|
|
<B>matchpathcon_init</B>()
|
|
|
|
calls, or to free memory when finished using
|
|
<B>matchpathcon</B>().
|
|
|
|
<P>
|
|
<B>matchpathcon</B>()
|
|
|
|
matches the specified
|
|
<I>pathname,</I>
|
|
|
|
after transformation via
|
|
<B><A HREF="/cgi-bin/man/man2html?3+realpath">realpath</A></B>(3)
|
|
|
|
excepting any final symbolic link component if S_IFLNK was
|
|
specified as the
|
|
<I>mode,</I>
|
|
|
|
and
|
|
<I>mode</I>
|
|
|
|
against the
|
|
<I>file contexts</I>
|
|
|
|
configuration and sets the security context
|
|
<I>con </I>
|
|
|
|
to refer to the
|
|
resulting context. The caller must free the returned security context
|
|
<I>con</I>
|
|
|
|
using
|
|
<B><A HREF="/cgi-bin/man/man2html?3+freecon">freecon</A></B>(3)
|
|
|
|
when finished using it.
|
|
<I>mode</I>
|
|
|
|
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
|
|
<I>mode </I>
|
|
|
|
are used.
|
|
If
|
|
<B>matchpathcon_init</B>()
|
|
|
|
has not already been called, then this function will call it upon
|
|
its first invocation with a NULL
|
|
<I>path,</I>
|
|
|
|
defaulting to the active file contexts configuration.
|
|
<P>
|
|
<B>matchpathcon_index</B>()
|
|
|
|
is the same as
|
|
<B>matchpathcon</B>()
|
|
|
|
but returns a specification index that can later be used in a
|
|
<B><A HREF="/cgi-bin/man/man2html?3+matchpathcon_filespec_add">matchpathcon_filespec_add</A></B>(3)
|
|
|
|
call.
|
|
<A NAME="lbAE"> </A>
|
|
<H2>RETURN VALUE</H2>
|
|
|
|
Returns zero on success or -1 otherwise.
|
|
<A NAME="lbAF"> </A>
|
|
<H2>SEE ALSO</H2>
|
|
|
|
|
|
|
|
<B><A HREF="/cgi-bin/man/man2html?8+selinux">selinux</A></B>(8), <B><A HREF="/cgi-bin/man/man2html?3+set_matchpathcon_flags">set_matchpathcon_flags</A></B>(3), <B><A HREF="/cgi-bin/man/man2html?3+set_matchpathcon_invalidcon">set_matchpathcon_invalidcon</A></B>(3), <B><A HREF="/cgi-bin/man/man2html?3+set_matchpathcon_printf">set_matchpathcon_printf</A></B>(3), <B><A HREF="/cgi-bin/man/man2html?3+matchpathcon_filespec_add">matchpathcon_filespec_add</A></B>(3), <B><A HREF="/cgi-bin/man/man2html?3+matchpathcon_checkmatches">matchpathcon_checkmatches</A></B>(3), <B><A HREF="/cgi-bin/man/man2html?3+freecon">freecon</A></B>(3), <B><A HREF="/cgi-bin/man/man2html?3+setfilecon">setfilecon</A></B>(3), <B><A HREF="/cgi-bin/man/man2html?3+setfscreatecon">setfscreatecon</A></B>(3)
|
|
|
|
<P>
|
|
|
|
<HR>
|
|
<A NAME="index"> </A><H2>Index</H2>
|
|
<DL>
|
|
<DT id="1"><A HREF="#lbAB">NAME</A><DD>
|
|
<DT id="2"><A HREF="#lbAC">SYNOPSIS</A><DD>
|
|
<DT id="3"><A HREF="#lbAD">DESCRIPTION</A><DD>
|
|
<DT id="4"><A HREF="#lbAE">RETURN VALUE</A><DD>
|
|
<DT id="5"><A HREF="#lbAF">SEE ALSO</A><DD>
|
|
</DL>
|
|
<HR>
|
|
This document was created by
|
|
<A HREF="/cgi-bin/man/man2html">man2html</A>,
|
|
using the manual pages.<BR>
|
|
Time: 00:05:47 GMT, March 31, 2021
|
|
</BODY>
|
|
</HTML>
|