semanage_query(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_query(3) ✨

okay bestie, so this is a page from the Libsemanage API documentation and it's all about semanage_query, the little function that goes and finds you a semanage record. it's giving "where is my stuff" energy and honestly? iconic. πŸŽ€


🌸 NAME 🌸

semanage_query β€” SELinux Management API. yes that's the whole name section, she's brief and she knows it πŸ’…


πŸ¦‹ SYNOPSIS πŸ¦‹

so here's the tea: the query function below works for any semanage record. you just swap out the function name and the object name to match whatever you're querying, okurrr? 🫢

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

πŸ’– DESCRIPTION πŸ’–

πŸ”₯ Behavior

lowkey the rules are simple:

  • the query function will fail if a matching key is not found β€” no key, no vibes, no record 😭
  • otherwise, the corresponding object gets returned to you. slay. ✨

🌈 Parameters

let's break down who's who in this little friend group:

  • the handle β€” this one tracks persistent state across all your semanage calls, and it's also the one that reports errors. main character energy fr fr. πŸ‘‘
  • the key β€” identifies the object you're querying. the matching object gets stored in the address pointed to by response. and here's the important part: the key is a property of the caller, so it will not be stored or modified internally. it's just visiting, not moving in. πŸ™ˆ
  • the object returned β€” that becomes a property of the caller too, which means you have to free it with semanage_OBJECT_free. don't forget bestie, that's a memory leak waiting to happen πŸ’€

⭐ Requirements

this function needs an semanage connection to already be established β€” go check semanage_connect(3) if you haven't done that yet. no connection, no query, periodt. πŸ’…


πŸ“ RETURN VALUE πŸ“

  • if it fails, -1 is returned and the semanage error callback gets invoked to describe what went wrong. rude but informative. 😭
  • otherwise you get a non-negative integer back β€” and that's a commit number. the same number will be returned by all the other semanage object read calls until the next commit. consistent queen. ✨

πŸ’œ SEE ALSO πŸ’œ

  • semanage_handle_create(3)
  • semanage_connect(3)

and that's the whole page, bestie!! 🧚 written by ivg2@cornell.edu on 15 March 2006 β€” yes she's been serving this documentation since 2006 and she still ate. πŸ’–πŸŒΈπŸ’