sefcontext_compile(8)

πŸ“¦
version 3.11 Β· 2 versions
, in alpine 3.24, centos-stream 10, centos-stream 9, debian bookworm, fedora 43, fedora 44, nixos 26.05, nixpkgs unstable, opensuse-leap 16.0, ubuntu jammy, ubuntu noble

πŸ’– 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 .bin suffix 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, -1 is returned. 😭
  • On success, 0 is 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. πŸŽ€πŸ’…πŸŒˆ