SELINUX_FILE_CONTEXT_VERIFY(3)
β¨ selinux_file_context_verify(3) β¨
okay so bestie, we're in the Library Functions Manual today and the function we're stanning is selinux_file_context_verify β she lives in section 3 with all the other library functions π
πΈ NAME πΈ
selinux_file_context_verify β compare the SELinux security context on disk to the default security context required by the policy file contexts file π
π¦ SYNOPSIS π¦
#include <selinux/selinux.h>
int selinux_file_context_verify(const char *path, mode_t mode);
π DESCRIPTION π
selinux_file_context_verify() does a little vibe check β it compares the context of the path you hand it, the one sitting on disk in the extended attribute, against the system default entry that lives in the file contexts series of files. like, on-disk reality vs. policy's dream scenario, and she's the matchmaker β¨
The mode may be zero. (yes bestie, zero is a totally valid mode here, no cap)
β οΈ Heads up: the two contexts get compared for "significant" differences only β the user component of the contexts is ignored. There's a whole demonstration of this in the EXAMPLE section, so scroll down, iykyk π
π₯ RETURN VALUE π₯
1(one) β returned if the contexts significantly match. slay, they're compatible π0(zero) β returned if the contexts do not match, anderrnogets set to eitherENOENTorEINVALfor the reasons listed down in ERRORS, or iferrno = 0then the contexts just... did not match. the silence is loud π-1β returned on failure, witherrnoset appropriately.
π ERRORS π
ENOTSUPβ if extended attributes are not supported by the file system. the filesystem said "not my thing" πENOENTβ if there is no entry in the file contexts series of files, or thepathdoes not exist. she's simply not there, bestie πEINVALβ if the entry in the file contexts series of files or thepathare invalid, or the returned context fails validation. invalid, rejected, blocked π«ENOMEMβ if the attempt to allocate memory failed. the memory budget said no π
π FILES π
The following configuration files β the file contexts series of files β supporting the active policy will be used (should they exist) to determine the path default context:
contexts/files/file_contextsβ This file must exist. non-negotiable, she's the main character πcontexts/files/file_contexts.localβ if it exists, it has local customizations. your personal touches πcontexts/files/file_contexts.homedirsβ if it exists, it has users home directory customizations. home sweet home πcontexts/files/file_contexts.subsβ if it exists, it has substitutions that are then applied to the 'in memory' version of the file contexts files. swaps and swaps and swaps β¨
π EXAMPLE π
Say the files context is:
unconfined_u:object_r:admin_home_t:s0
and the default context defined in the file contexts file is:
system_u:object_r:admin_home_t:s0
then the actual strings compared are:
:object_r:admin_home_t:s0 and :object_r:admin_home_t:s0
see how the user part just got ghosted?? π» the user component is ignored, remember!
Therefore they will match and selinux_file_context_verify() will return 1. ate and left no crumbs π
β SEE ALSO β
selinux(8)go read the big one, bestie π
and that's the whole page, fr fr β this was SELinux API documentation, dated 08 March 2011, section 3 (selinux_fi...text_verify(3)) π«Ά kisses, go verify those contexts, mwah π
π¦ where this page comes from
- alpine 3.24: libselinux-doc 3.10-r1 Β· Public-Domain
- centos-stream 10: libselinux-devel 3.11-3.el10 Β· LicenseRef-Fedora-Public-Domain
- centos-stream 9: libselinux-devel 3.6-5.el9 Β· Public Domain
- centos-stream 9: libselinux-devel 3.6-5.el9 Β· Public Domain
- debian bookworm: libselinux1-dev 3.4-1+b6
- debian trixie: libselinux1-dev 3.8.1-1 Β· LicenseRef-public-domain
- fedora 43: libselinux-devel 3.9-5.fc43 Β· LicenseRef-Fedora-Public-Domain
- fedora 43: libselinux-devel 3.9-5.fc43 Β· LicenseRef-Fedora-Public-Domain
- fedora 44: libselinux-devel 3.10-1.fc44 Β· LicenseRef-Fedora-Public-Domain
- fedora 44: libselinux-devel 3.10-1.fc44 Β· LicenseRef-Fedora-Public-Domain
- fedora 44: libselinux-devel 3.11-2.fc44 Β· LicenseRef-Fedora-Public-Domain
- fedora 44: libselinux-devel 3.11-2.fc44 Β· LicenseRef-Fedora-Public-Domain
- nixos 26.05: libselinux 3.10
- nixpkgs unstable: libselinux 3.11
- opensuse-leap 16.0: libselinux-devel 3.8.1-160000.4.1 Β· SUSE-Public-Domain
- opensuse-leap 16.0: libselinux-devel 3.8.1-160000.4.1 Β· SUSE-Public-Domain
- opensuse-leap 16.0: libselinux-devel 3.8.1-160000.4.1 Β· SUSE-Public-Domain
- opensuse-leap 16.0: libselinux-devel 3.8.1-160000.4.1 Β· SUSE-Public-Domain
- ubuntu jammy: libselinux1-dev 3.3-1build2
- ubuntu noble: libselinux1-dev 3.5-2ubuntu2 Β· LicenseRef-public-domain
- ubuntu noble: libselinux1-dev 3.5-2ubuntu2.1 Β· LicenseRef-public-domain
- ubuntu questing: libselinux1-dev 3.8.1-1build1
- ubuntu resolute: libselinux-dev 3.9-4build1 Β· LicenseRef-public-domain
- ubuntu stonking: libselinux-dev 3.11-2.1 Β· LicenseRef-public-domain
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms