SEPOL_CHECK_CONTEXT(3)

πŸ“¦
version 3.11 Β· 2 versions
, in alpine 3.24, centos-stream 10, centos-stream 9, debian trixie, fedora 43, fedora 44, nixpkgs unstable, opensuse-leap 16.0, ubuntu questing, ubuntu resolute, ubuntu stonking

πŸ’– sepol_check_context β€” the vibe check for security contexts πŸ’–

okay bestie, welcome to the SE Linux binary policy API documentation, section 3 of the manual (yes, that's the sepol_...context(3) girlies 🫢). pull up a chair, grab a strawberry, and let's talk about checking whether your security context is actually valid. πŸ“βœ¨


✨ NAME ✨

sepol_check_context β€” checking the validity of a security context against a binary policy, fr fr. πŸ‘‘


🌸 SYNOPSIS 🌸

#include <sepol/sepol.h>

int sepol_check_context(const char *context);

int sepol_set_policydb_from_file(FILE *fp);

two functions, one header, zero drama. iconic. πŸ’…


πŸ¦‹ DESCRIPTION πŸ¦‹

so sepol_check_context does exactly what it says on the tin: it checks the validity of a security context against a binary policy. and like, not any policy β€” specifically one that was previously loaded from a file via sepol_set_policydb_from_file. no cap, that's the whole setup. πŸŽ€

who's using this?? bestie, it's what setfiles -c uses to validate a file contexts configuration against the binary policy when you do policy builds. that's its moment. its main character era. 🌈

⚠️ okay important psa: if you're trying to validate a context against the active policy on a SELinux system, this is not the function you want. go use security_check_context from libselinux instead. iykyk. πŸ’€

⭐ RETURN VALUE ⭐

  • returns 0 on success πŸ₯³
  • returns -1 with errno set otherwise 😭

that's it. that's the whole vibe check.


πŸ’œ sign-off πŸ’œ

this little baddie was brought to you by stephen.smalley.work@gmail.com, dated 15 March 2005 β€” old enough to be a whole legend, still serving. periodt. 🧚✨