182 lines
4.3 KiB
HTML
182 lines
4.3 KiB
HTML
|
|
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
|
|
<HTML><HEAD><TITLE>Man page of selabel_lookup_best_match</TITLE>
|
|
</HEAD><BODY>
|
|
<H1>selabel_lookup_best_match</H1>
|
|
Section: SELinux API documentation (3)<BR>Updated: 05 May 2015<BR><A HREF="#index">Index</A>
|
|
<A HREF="/cgi-bin/man/man2html">Return to Main Contents</A><HR>
|
|
|
|
<P>
|
|
<A NAME="lbAB"> </A>
|
|
<H2>NAME</H2>
|
|
|
|
selabel_lookup_best_match - obtain a best match SELinux security
|
|
context - Only supported on file backend.
|
|
<A NAME="lbAC"> </A>
|
|
<H2>SYNOPSIS</H2>
|
|
|
|
<B>#include <<A HREF="file:///usr/include/selinux/selinux.h">selinux/selinux.h</A>></B>
|
|
|
|
<BR>
|
|
|
|
<B>#include <<A HREF="file:///usr/include/selinux/label.h">selinux/label.h</A>></B>
|
|
|
|
<P>
|
|
<B>int selabel_lookup_best_match(struct selabel_handle *</B><I>hnd</I><B>,</B>
|
|
|
|
|
|
<B>char **</B><I>context</I><B>,</B>
|
|
|
|
<BR>
|
|
|
|
<B>const char *</B><I>key</I><B>,</B>
|
|
|
|
<BR>
|
|
|
|
<B>const char **</B><I>links</I><B>,</B>
|
|
|
|
<BR>
|
|
|
|
<B>int </B><I>type</I><B>);</B>
|
|
|
|
|
|
<P>
|
|
<B>int selabel_lookup_best_match_raw(struct selabel_handle *</B><I>hnd</I><B>,</B>
|
|
|
|
|
|
<B>char **</B><I>context</I><B>,</B>
|
|
|
|
<BR>
|
|
|
|
<B>const char *</B><I>key</I><B>,</B>
|
|
|
|
<BR>
|
|
|
|
<B>const char **</B><I>links</I><B>,</B>
|
|
|
|
<BR>
|
|
|
|
<B>int </B><I>type</I><B>);</B>
|
|
|
|
|
|
<A NAME="lbAD"> </A>
|
|
<H2>DESCRIPTION</H2>
|
|
|
|
<B>selabel_lookup_best_match</B>()
|
|
|
|
performs a best match lookup operation on the handle
|
|
<I>hnd</I>,
|
|
|
|
returning the result in the memory pointed to by
|
|
<I>context</I>,
|
|
|
|
which must be freed by the caller using
|
|
<B><A HREF="/cgi-bin/man/man2html?3+freecon">freecon</A></B>(3).
|
|
|
|
The <I>key</I> parameter is a file path to check for best match using zero or
|
|
more <I>link</I> (aliases) parameters. The order of precedence for best match is:
|
|
<DL COMPACT><DT id="1"><DD>
|
|
<DL COMPACT>
|
|
<DT id="2">1.<DD>
|
|
An exact match for the real path (<I>key</I>) or
|
|
<DT id="3">2.<DD>
|
|
An exact match for any of the <I>link</I>s (aliases), or
|
|
<DT id="4">3.<DD>
|
|
The longest fixed prefix match.
|
|
</DL>
|
|
</DL>
|
|
|
|
<P>
|
|
The <I>type</I> parameter is an optional file <I>mode</I> argument that should
|
|
be set to the mode bits of the file, as determined by <B><A HREF="/cgi-bin/man/man2html?2+lstat">lstat</A></B>(2).
|
|
<I>mode</I> may be zero, however full matching may not occur.
|
|
<P>
|
|
<B>selabel_lookup_best_match_raw</B>()
|
|
|
|
behaves identically to
|
|
<B>selabel_lookup_best_match</B>()
|
|
|
|
but does not perform context translation.
|
|
<A NAME="lbAE"> </A>
|
|
<H2>RETURN VALUE</H2>
|
|
|
|
On success, zero is returned. On error, -1 is returned and
|
|
<I>errno</I>
|
|
|
|
is set appropriately.
|
|
<A NAME="lbAF"> </A>
|
|
<H2>ERRORS</H2>
|
|
|
|
<DL COMPACT>
|
|
<DT id="5"><B>ENOENT</B>
|
|
|
|
<DD>
|
|
No context corresponding to the input
|
|
<I>key</I>
|
|
|
|
and
|
|
<I>type</I>
|
|
|
|
was found.
|
|
<DT id="6"><B>EINVAL</B>
|
|
|
|
<DD>
|
|
The
|
|
<I>key</I>
|
|
|
|
and/or
|
|
<I>type</I>
|
|
|
|
inputs are invalid, or the context being returned failed validation.
|
|
<DT id="7"><B>ENOMEM</B>
|
|
|
|
<DD>
|
|
An attempt to allocate memory failed.
|
|
<P>
|
|
</DL>
|
|
<A NAME="lbAG"> </A>
|
|
<H2>NOTES</H2>
|
|
|
|
Example usage - When a service creates a device node, it may also create one
|
|
or more symlinks to the device node. These symlinks may be the only stable
|
|
name for the device, e.g. if the partition is dynamically assigned.
|
|
The file label backend supports this by looking up the "best match"
|
|
for a device node based on its real path (<I>key</I>) and any <I>link</I>s to it
|
|
(aliases). The order of precedence for best match is described above.
|
|
<P>
|
|
<A NAME="lbAH"> </A>
|
|
<H2>SEE ALSO</H2>
|
|
|
|
<B><A HREF="/cgi-bin/man/man2html?3+selabel_open">selabel_open</A></B>(3),
|
|
|
|
<B><A HREF="/cgi-bin/man/man2html?3+selabel_stats">selabel_stats</A></B>(3),
|
|
|
|
<B><A HREF="/cgi-bin/man/man2html?3+selinux_set_callback">selinux_set_callback</A></B>(3),
|
|
|
|
<B><A HREF="/cgi-bin/man/man2html?8+selinux">selinux</A></B>(8),
|
|
|
|
<B><A HREF="/cgi-bin/man/man2html?2+lstat">lstat</A></B>(2),
|
|
|
|
<B><A HREF="/cgi-bin/man/man2html?5+selabel_file">selabel_file</A></B>(5)
|
|
|
|
<P>
|
|
|
|
<HR>
|
|
<A NAME="index"> </A><H2>Index</H2>
|
|
<DL>
|
|
<DT id="8"><A HREF="#lbAB">NAME</A><DD>
|
|
<DT id="9"><A HREF="#lbAC">SYNOPSIS</A><DD>
|
|
<DT id="10"><A HREF="#lbAD">DESCRIPTION</A><DD>
|
|
<DT id="11"><A HREF="#lbAE">RETURN VALUE</A><DD>
|
|
<DT id="12"><A HREF="#lbAF">ERRORS</A><DD>
|
|
<DT id="13"><A HREF="#lbAG">NOTES</A><DD>
|
|
<DT id="14"><A HREF="#lbAH">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:56 GMT, March 31, 2021
|
|
</BODY>
|
|
</HTML>
|