| 1 |
.TH "selinux_file_context_verify" "3" "08 March 2011" "SELinux API documentation" |
| 2 |
.SH "NAME" |
| 3 |
selinux_file_context_verify \- Compare the SELinux security context on disk to the default security context required by the policy file contexts file |
| 4 |
. |
| 5 |
.SH "SYNOPSIS" |
| 6 |
.B #include <selinux/selinux.h> |
| 7 |
.sp |
| 8 |
.BI "int selinux_file_context_verify(const char *" path ", mode_t " mode ");" |
| 9 |
. |
| 10 |
.SH "DESCRIPTION" |
| 11 |
.BR selinux_file_context_verify () |
| 12 |
compares the context of the specified |
| 13 |
.I path |
| 14 |
that is held on disk (in the extended attribute), to the system default entry held in the file contexts series of files. |
| 15 |
.sp |
| 16 |
The |
| 17 |
.I mode |
| 18 |
may be zero. |
| 19 |
.sp |
| 20 |
Note that the two contexts are compared for "significant" differences (i.e. the user component of the contexts are ignored) as shown in the |
| 21 |
.B EXAMPLE |
| 22 |
section. |
| 23 |
. |
| 24 |
.SH "RETURN VALUE" |
| 25 |
If the contexts significantly match, 1 (one) is returned. |
| 26 |
.sp |
| 27 |
If the contexts do not match 0 (zero) is returned and |
| 28 |
.I errno |
| 29 |
is set to either |
| 30 |
.B ENOENT |
| 31 |
or |
| 32 |
.B EINVAL |
| 33 |
for the reasons listed in the |
| 34 |
.B ERRORS |
| 35 |
section, or if |
| 36 |
.I errno |
| 37 |
= 0 then the contexts did not match. |
| 38 |
.sp |
| 39 |
On failure \-1 is returned and |
| 40 |
.I errno |
| 41 |
set appropriately. |
| 42 |
. |
| 43 |
.SH "ERRORS" |
| 44 |
.TP |
| 45 |
.B ENOTSUP |
| 46 |
if extended attributes are not supported by the file system. |
| 47 |
.TP |
| 48 |
.B ENOENT |
| 49 |
if there is no entry in the file contexts series of files or |
| 50 |
.I path |
| 51 |
does not exist. |
| 52 |
.TP |
| 53 |
.B EINVAL |
| 54 |
if the entry in the file contexts series of files or |
| 55 |
.I path |
| 56 |
are invalid, or the returned context fails validation. |
| 57 |
.TP |
| 58 |
.B ENOMEM |
| 59 |
if attempt to allocate memory failed. |
| 60 |
. |
| 61 |
.SH "FILES" |
| 62 |
The following configuration files (the file contexts series of files) supporting the active policy will be used (should they exist) to determine the |
| 63 |
.I path |
| 64 |
default context: |
| 65 |
.sp |
| 66 |
.RS |
| 67 |
.I contexts/files/file_contexts |
| 68 |
- This file must exist. |
| 69 |
.sp |
| 70 |
.I contexts/files/file_contexts.local |
| 71 |
- If exists has local customizations. |
| 72 |
.sp |
| 73 |
.I contexts/files/file_contexts.homedirs |
| 74 |
- If exists has users home directory customizations. |
| 75 |
.sp |
| 76 |
.I contexts/files/file_contexts.subs |
| 77 |
- If exists has substitutions that are then applied to the 'in memory' version of the file contexts files. |
| 78 |
.RE |
| 79 |
. |
| 80 |
.SH "EXAMPLE" |
| 81 |
If the files context is: |
| 82 |
.RS |
| 83 |
unconfined_u:object_r:admin_home_t:s0 |
| 84 |
.RE |
| 85 |
.sp |
| 86 |
and the default context defined in the file contexts file is: |
| 87 |
.RS |
| 88 |
system_u:object_r:admin_home_t:s0 |
| 89 |
.RE |
| 90 |
.sp |
| 91 |
then the actual strings compared are: |
| 92 |
.RS |
| 93 |
:object_r:admin_home_t:s0 and :object_r:admin_home_t:s0 |
| 94 |
.RE |
| 95 |
.sp |
| 96 |
Therefore they will match and |
| 97 |
.BR selinux_file_context_verify () |
| 98 |
will return 1. |
| 99 |
. |
| 100 |
.SH "SEE ALSO" |
| 101 |
.BR selinux "(8)" |