CAPNG_SET_ROOTID(3)

πŸ’– CAPNG_SET_ROOTID πŸ’–

okay bestie, so this one is from the Libcap-ng API β€” it's capng_set_rootid, a lil function that handles namespace root ids. sit with me, it's short but it's important. πŸ¦‹


✨ NAME ✨

capng_set_rootid β€” set namespace root id πŸŽ€


✨ SYNOPSIS ✨

#include <cap-ng.h>

int capng_set_rootid(uid_t rootid);

like. that's it. that's the whole vibe check. πŸ’…


✨ DESCRIPTION ✨

so capng_set_rootid sets the root user ID for file capabilities operations. no cap. 🫢

the value is host-endian and it's relative to the caller's user namespace. yes, that matters, don't come for me.

  • pass CAPNG_UNSET_ROOTID and it clears a previously selected namespace root ID, sending you right back to writing regular V2 file capabilities 🧚
  • any other value selects V3 file capabilities, and the kernel validates and maps the user ID when the capabilities are actually written ✨
fr fr, you don't get to skip the kernel's little check. it does the validating and the mapping, not you. πŸ™ˆ

✨ RETURN VALUE ✨

  • on success, it returns 0 β€” slay, we love a clean return πŸ’–
  • it returns -1 if there's an internal error, OR if the kernel headers that were used to build the library do not support V3 file capabilities 😭

so if you're getting -1 and nothing's obviously wrong... check your kernel headers, bestie. that's the plot twist. πŸ’€


✨ SEE ALSO ✨

go read them, they're giving main character energy too. πŸ‘‘


✨ AUTHOR ✨

Steve Grubb πŸŽ€


okay and for the sign-off: this whole thing is a Red Hat situation, it's part of the Libcap-ng API, and the page is dated March 2026. so like, fresh. ✨ bye bestie, go set some root ids responsibly πŸ’…πŸŒΈ