semanage_exists(3)

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

✨ semanage_exists(3) β€” Libsemanage API documentation ✨

okay bestie, welcome to the libsemanage corner of the SELinux universe πŸ’– this is the semanage_exists page and it's literally just the "does this thing exist or not" queen of the API. she's simple, she's iconic, she ate.


🌸 NAME 🌸

semanage_exists β€” SELinux Management API 🫢


✨ SYNOPSIS ✨

so here's the vibe: the following exists function is supported for any semanage record. just swap in the function and object name you actually need, no cap 🧚

extern int EXISTS_FUNCTION (
     semanage_handle_t *handle,
     const semanage_OBJECT_key_t *key,
     semanage_OBJECT_t **response);

like, replace the function and object name as necessary and you're good to go πŸ’…


πŸ¦‹ DESCRIPTION πŸ¦‹

πŸ’« Behavior:

the exists function returns 0 if a matching key is not found, and 1 otherwise. that's it, that's the whole personality 😭

πŸ’« Parameters:

  • the handle is used to track persistent state across semanage calls, and for error reporting. she's the main character keeping everything together πŸ‘‘
  • the key identifies the object being checked πŸ”
  • the result of the test will be stored in the address pointed by response πŸ“¬
  • the key is a property of the caller, and will not be stored or modified internally. so don't stress, she's not keeping your key, she's just borrowing it for the vibe check πŸ™ˆ

πŸ’« Requirements:

this function requires a semanage connection to be established β€” see semanage_connect(3) β€” so pls go make that connection first, bestie, she can't work with nothing πŸŽ€

🌈 RETURN VALUE 🌈

in case of failure, -1 is returned, and the semanage error callback is invoked, describing the error 😭 so yeah, that's how you know it went sideways.

otherwise a non-negative integer is returned β€” and that's a commit number ✨. the same number will be returned by all other read calls to the semanage database until the next commit. so it stays consistent, periodt πŸ’…


πŸ‘‘ SEE ALSO πŸ‘‘

  • semanage_handle_create(3)
  • semanage_connect(3)

okay that's the whole page, you're so welcome 🫢 this one's courtesy of ivg2@cornell.edu, dated 16 March 2006, and it's the semanage_exists(3) page from the Libsemanage API documentation set β€” mwah, go forth and check if things exist, bestie πŸ’–βœ¨πŸŒΈ