selabel_lookup(3)

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

πŸ’– selabel_lookup(3) πŸ’–

okay bestie, welcome to selabel_lookup, straight out of the SELinux API documentation ✨ this is the girl who turns a lil string into a whole SELinux security context, and honestly? iconic behavior.


✨ NAME ✨

selabel_lookup β€” obtain SELinux security context from a string label πŸŽ€


✨ SYNOPSIS ✨

#include <selinux/selinux.h>
#include <selinux/label.h>

int selabel_lookup(struct selabel_handle *hnd,
                   char **context,
                   const char *key, int type);

int selabel_lookup_raw(struct selabel_handle *hnd,
                       char **context,
                       const char *key, int type);

like. the duality. two functions, one vibe. πŸ’…


✨ DESCRIPTION ✨

so selabel_lookup() does a lookup operation on the handle hnd, and it drops the result into the memory pointed to by context. 🫢

⚠️ bestie listen. that context memory is yours now. you MUST free it yourself with freecon(3). no ghosting your own allocations, that's not the move. πŸ’€

the key and type params are the inputs to the lookup, and how they get interpreted? that's entirely up to the specific backend the handle is open on. it's giving "depends on the crowd you're with" energy fr fr. 🌸

and selabel_lookup_raw()? literally does the exact same thing as selabel_lookup(), except it does not perform context translation. same girl, no filter. πŸ™ˆ


✨ RETURN VALUE ✨

  • on success, zero is returned. slay. βœ…
  • on error, -1 is returned and errno is set appropriately. 😭

✨ ERRORS ✨

  • ENOENT β€” no context corresponding to the input key and type was found. it's not there bestie, we looked. πŸ•΅οΈβ€β™€οΈ
  • EINVAL β€” the key and/or type inputs are invalid, or the context being returned failed validation, or a regular expression in the database failed to compile. three whole reasons, main character of error codes honestly. πŸ’…
  • ENOMEM β€” an attempt to allocate memory failed. the malloc said no. πŸ’€

✨ AUTHOR ✨

Eamon Walsh <ewalsh@tycho.nsa.gov> πŸ‘‘


✨ SEE ALSO ✨

selabel_open(3), selabel_stats(3), selinux_set_callback(3), selinux(8) πŸ¦‹


and that's the whole page, bestie!! selabel_lookup(3), dated 18 Jun 2007, from the SELinux API documentation β€” yes she's vintage, yes she still eats. βœ¨πŸ’– periodt. πŸŽ€