set_matchpathcon_flags(3)

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

✨ set_matchpathcon_flags(3) ✨

okay bestie, this is the set_matchpathcon_flags(3) page from the SELinux API docs and it's lowkey a whole vibe β€” it's three little functions that tweak how matchpathcon does its thing πŸ’…


🌸 NAME 🌸

set_matchpathcon_flags, set_matchpathcon_invalidcon, set_matchpathcon_printf β€” these set flags that control the operation of matchpathcon or matchpathcon_index, and configure the behaviour of validity checking and error displaying. so like, the vibes-controller panel for your pathcon setup πŸŽ›οΈβœ¨


πŸ¦‹ SYNOPSIS πŸ¦‹

#include <selinux/selinux.h>

void set_matchpathcon_flags(unsigned int flags);

void set_matchpathcon_invalidcon(int (*f)(const char *path, unsigned
lineno, char *context));

void set_matchpathcon_printf(void (*f)(const char *fmt, ...));

πŸ’– DESCRIPTION πŸ’–

🌈 set_matchpathcon_flags()

this one sets the flags that control the operation of matchpathcon_init(3) and then, like, subsequently matchpathcon_index(3) or matchpathcon(3). she's the boss of the whole flow, no cap.

so if the MATCHPATHCON_BASEONLY flag is set, then only the base file contexts configuration file gets processed β€” not any dynamically generated entries, and not any local customizations either. literally just the base, nothing else, periodt. πŸŽ€

🌸 set_matchpathcon_invalidcon()

this sets the function used by matchpathcon_init(3) when it's checking the validity of a context inside the file contexts configuration.

if you don't set it, it defaults to a test based on security_check_context(3), which checks validity against the active policy on a SELinux system. iconic default behaviour honestly ✨

but you can set it to instead perform checking based on a binary policy file β€” for example using sepol_check_context(3), exactly like setfiles -c does. iykyk πŸ”₯

the function is also the one responsible for reporting any such error, and it may include the path and lineno in those error messages. so she's doing double duty β€” checking AND telling you what went wrong πŸ’…

🧚 set_matchpathcon_printf()

this sets the function used by matchpathcon_init(3) when displaying errors about the file contexts configuration.

if not set, it defaults to fprintf(stderr, fmt, ...). classic.

you can set this to redirect error reporting to a different destination β€” send those errors wherever you want, main character energy, you're in charge 🫢


⭐ RETURN VALUE ⭐

Returns zero on success or -1 otherwise. that's it, that's the whole thing, short and sweet πŸ’œ


πŸ‘‘ SEE ALSO πŸ‘‘


ngl the manpage header for this one is literally set_matchpathcon_flags(3) β€” it's from the SELinux API documentation. and shoutout to stephen.smalley.work@gmail.com who wrote this on 21 November 2009 πŸŽ€ tysm for your service, bestie, we're obsessed πŸ’–βœ¨πŸ¦‹πŸŒΈπŸ’…
πŸ“¦ where this page comes from