man-pages/man3/selinux_file_context_cmp.3.html
2021-03-31 01:06:50 +01:00

134 lines
2.7 KiB
HTML

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<HTML><HEAD><TITLE>Man page of selinux_file_context_cmp</TITLE>
</HEAD><BODY>
<H1>selinux_file_context_cmp</H1>
Section: C Library Functions (3)<BR>Updated: 08 March 2011<BR><A HREF="#index">Index</A>
<A HREF="/cgi-bin/man/man2html">Return to Main Contents</A><HR>
<A NAME="lbAB">&nbsp;</A>
<H2>NAME</H2>
selinux_file_context_cmp - Compare two SELinux security contexts excluding the 'user' component
<A NAME="lbAC">&nbsp;</A>
<H2>SYNOPSIS</H2>
<B>#include &lt;<A HREF="file:///usr/include/selinux/selinux.h">selinux/selinux.h</A>&gt;</B>
<P>
<B>int selinux_file_context_cmp(const char *</B><I>a</I><B>, </B>
<DL COMPACT><DT id="1"><DD>
<B>const char *</B><I>b</I><B>);</B>
</DL>
<A NAME="lbAD">&nbsp;</A>
<H2>DESCRIPTION</H2>
<B>selinux_file_context_cmp</B>()
compares two context strings excluding the user component with
<B><A HREF="/cgi-bin/man/man2html?3+strcmp">strcmp</A></B>(3)
as shown in the
<B>EXAMPLE</B>
section.
<P>
This is useful as for most object contexts, the user component is not relevant.
<A NAME="lbAE">&nbsp;</A>
<H2>RETURN VALUE</H2>
The return values follow the
<B><A HREF="/cgi-bin/man/man2html?3+strcmp">strcmp</A></B>(3)
function, where:
<DL COMPACT><DT id="2"><DD>
0 if they are equal.
</DL>
<DL COMPACT><DT id="3"><DD>
1 if
<I>a</I>
is greater than
<I>b</I>
</DL>
<DL COMPACT><DT id="4"><DD>
-1 if
<I>a</I>
is less than
<I>b</I>
</DL>
<A NAME="lbAF">&nbsp;</A>
<H2>ERRORS</H2>
None.
<A NAME="lbAG">&nbsp;</A>
<H2>NOTES</H2>
The contexts being compared do not specifically need to be file contexts.
<A NAME="lbAH">&nbsp;</A>
<H2>EXAMPLE</H2>
If context
<I>a</I>
is:
<DL COMPACT><DT id="5"><DD>
user_u:user_r:user_t:s0
</DL>
<P>
and context
<I>b</I>
is:
<DL COMPACT><DT id="6"><DD>
root:user_r:user_t:s0
</DL>
<P>
then the actual strings compared are:
<DL COMPACT><DT id="7"><DD>
:user_r:user_t:s0 and :user_r:user_t:s0
</DL>
<P>
Therefore they will match and
<B>selinux_file_context_cmp</B>()
will return zero.
<A NAME="lbAI">&nbsp;</A>
<H2>SEE ALSO</H2>
<B><A HREF="/cgi-bin/man/man2html?8+selinux">selinux</A></B>(8)
<P>
<HR>
<A NAME="index">&nbsp;</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">EXAMPLE</A><DD>
<DT id="15"><A HREF="#lbAI">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>