selabel_digest(3)

πŸ’– selabel_digest β€” the tea β˜•

okay bestie, so this is selabel_digest(3) from the SELinux API documentation, section 3, and it's literally the little function that hands you a digest and the receipts for which specfiles went into it. let's get into it 🫢


✨ NAME ✨

selabel_digest β€” Return digest of specfiles and list of files used πŸ’…


🌸 SYNOPSIS 🌸

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

int selabel_digest(struct selabel_handle *hnd,
                   unsigned char **digest, size_t *digest_len,
                   char ***specfiles, size_t *num_specfiles);

πŸ¦‹ DESCRIPTION πŸ¦‹

so selabel_digest() does a whole operation on the handle hnd, and it hands you back the results of the SHA256 digest that digest points at β€” and the length of that lil digest goes into digest_len. ✨

then the list of specfiles that were used in the SHA256 digest calculation comes back in specfiles, with the number of entries in num_specfiles. it's giving "here's the math, and here's everything that went into the math" πŸ‘‘

important bestie moment: for selabel_digest() to be able to return any of this info, the SELABEL_OPT_DIGEST option has to be enabled in selabel_open(3). no option, no digest, periodt.

⚠️ and the result of selabel_digest() must not be used after selabel_close(3). like, do not. it's gone. it's giving expired. 😭

⭐ RETURN VALUE ⭐

  • on success, zero is returned πŸŽ€
  • on error, -1 is returned and errno is set appropriately 🌈

πŸ’€ ERRORS πŸ’€

  • EINVAL β€” No digest available (returned if SELABEL_OPT_DIGEST option not enabled). yeah she'll hit you with this one if you forgot the option, no cap πŸ™ˆ
  • ENOMEM β€” An attempt to allocate memory failed. the memory said no πŸ’”

πŸ‘‘ SEE ALSO πŸ‘‘

iykyk, go read those next fr fr 🌸


and that's the whole page bestie!! this icon of a manpage was brought to you by the SELinux API documentation, dated 16 Sept 2015, and this rewrite is signing off β€” stay slay, keep your options enabled, and never touch a digest after close πŸ’…βœ¨πŸ’–

πŸ“¦ where this page comes from