Debian Codegraph @

libselinux/man/man3/selinux_file_context_cmp.3

raw
1 .TH "selinux_file_context_cmp" "3" "08 March 2011" "SELinux API documentation"
2 .SH "NAME"
3 selinux_file_context_cmp \- Compare two SELinux security contexts excluding the 'user' component
4 .
5 .SH "SYNOPSIS"
6 .B #include <selinux/selinux.h>
7 .sp
8 .BI "int selinux_file_context_cmp(const char *" a ", "
9 .RS
10 .BI "const char *" b ");"
11 .RE
12 .
13 .SH "DESCRIPTION"
14 .BR selinux_file_context_cmp ()
15 compares two context strings excluding the user component with
16 .BR strcmp (3)
17 as shown in the
18 .B EXAMPLE
19 section.
20 .sp
21 This is useful as for most object contexts, the user component is not relevant.
22 .
23 .SH "RETURN VALUE"
24 The return values follow the
25 .BR strcmp (3)
26 function, where:
27 .RS
28 0 if they are equal.
29 .RE
30 .RS
31 1 if
32 .I a
33 is greater than
34 .I b
35 .RE
36 .RS
37 \-1 if
38 .I a
39 is less than
40 .I b
41 .RE
42 .
43 .SH "ERRORS"
44 None.
45 .
46 .SH "NOTES"
47 The contexts being compared do not specifically need to be file contexts.
48 .
49 .SH "EXAMPLE"
50 If context
51 .I a
52 is:
53 .RS
54 user_u:user_r:user_t:s0
55 .RE
56 .sp
57 and context
58 .I b
59 is:
60 .RS
61 root:user_r:user_t:s0
62 .RE
63 .sp
64 then the actual strings compared are:
65 .RS
66 :user_r:user_t:s0 and :user_r:user_t:s0
67 .RE
68 .sp
69 Therefore they will match and
70 .BR selinux_file_context_cmp ()
71 will return zero.
72 .
73 .SH "SEE ALSO"
74 .BR selinux "(8)"