sefcontext_compile(8)
π sefcontext_compile(8) π
okay bestie, so this one lives in the SELinux Command Line documentation and it's genuinely so useful, let me put you on. It's called sefcontext_compile, and it is exactly what it sounds like: the little tool that takes your file context regular expression files and compiles them. periodt. π
β¨ NAME β¨
sefcontext_compile β compile file context regular expression files π¦
πΈ SYNOPSIS πΈ
sefcontext_compile [-o outputfile] [-p policyfile] inputfile
π DESCRIPTION π
So here's the tea, bestie: sefcontext_compile is what you use to compile file context regular expressions into pcre(3) format. It's giving translator energy β your regexes go in, the pcre version comes out. β¨
That compiled file? It's the one that gets used by the libselinux file labeling functions. So it's not just a cute little side quest, it's lowkey load-bearing. π«Ά
And by default β no cap β sefcontext_compile writes that compiled pcre file with the .bin suffix appended, like inputfile.bin. So it names it for you automatically. iconic behavior honestly. π
π OPTIONS π
-oβ specify an outputfile. And listen, this one's important: it must be a fully qualified file name, because the.binsuffix is not automatically added when you use this. You want that suffix, you write it yourself. no hand-holding here π-pβ specify a binary policyfile that will be used to validate the context entries in the inputfile. And if an invalid context gets found? The pcre formatted file will not be written and an error will be returned. So it's a strict queen β it either validates or it refuses. π
β RETURN VALUE β
- On error,
-1is returned. π - On success,
0is returned. π₯³
π EXAMPLES π
Example 1 π§
sefcontext_compile /etc/selinux/targeted/contexts/files/file_contexts
Results in the following file being generated:
/etc/selinux/targeted/contexts/files/file_contexts.bin
Look at that .bin just showing up on its own. main character energy fr fr. π
Example 2 π
sefcontext_compile -o new_fc.bin
/etc/selinux/targeted/contexts/files/file_contexts
Results in the following file being generated in the cwd:
new_fc.bin
See how we had to spell out new_fc.bin ourselves? that's the -o rule in action, bestie. told you. π
π AUTHOR π
Dan Walsh, <dwalsh@redhat.com> π«Ά
π₯ SEE ALSO π₯
selinux(8), semanage(8), π¦
okay that's the whole page, you're officially fluent in sefcontext_compile. go compile something and slay. πβ¨
Bye bestie!! This icon of a manual page is brought to you by <dwalsh@redhat.com> and it's dated 12 Aug 2015 β sefcontext_compile(8), now go be great. ππ
π
π¦ where this page comes from
- alpine 3.24: libselinux-doc 3.10-r1 Β· Public-Domain
- centos-stream 10: libselinux-utils 3.11-3.el10 Β· LicenseRef-Fedora-Public-Domain
- centos-stream 9: libselinux-utils 3.6-5.el9 Β· Public Domain
- debian bookworm: selinux-utils 3.4-1+b6
- fedora 43: libselinux-utils 3.9-5.fc43 Β· LicenseRef-Fedora-Public-Domain
- fedora 44: libselinux-utils 3.10-1.fc44 Β· LicenseRef-Fedora-Public-Domain
- fedora 44: libselinux-utils 3.11-2.fc44 Β· LicenseRef-Fedora-Public-Domain
- nixos 26.05: libselinux 3.10
- nixpkgs unstable: libselinux 3.11
- opensuse-leap 16.0: selinux-tools 3.8.1-160000.4.1 Β· SUSE-Public-Domain
- opensuse-leap 16.0: selinux-tools 3.8.1-160000.4.1 Β· SUSE-Public-Domain
- opensuse-leap 16.0: selinux-tools 3.8.1-160000.4.1 Β· SUSE-Public-Domain
- opensuse-leap 16.0: selinux-tools 3.8.1-160000.4.1 Β· SUSE-Public-Domain
- ubuntu jammy: selinux-utils 3.3-1build2
- ubuntu noble: selinux-utils 3.5-2ubuntu2 Β· LicenseRef-public-domain
- ubuntu noble: selinux-utils 3.5-2ubuntu2.1 Β· LicenseRef-public-domain
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms