CAPNG_GET_CAPS_PROCESS(3)

πŸ“¦
version 0.9.6 Β· 3 versions
  • 0.9.6 Β· alpine 3.22, alpine 3.23, alpine 3.24, arch rolling, centos-stream 10, debian bookworm, debian trixie, fedora 43, fedora 44, nixos 26.05, nixpkgs unstable, opensuse-leap 16.0, ubuntu noble, ubuntu questing, ubuntu resolute, ubuntu stonking (latest)
  • 0.8.2 Β· centos-stream 9
  • 0.7.9 Β· ubuntu jammy
, in alpine 3.22, alpine 3.23, alpine 3.24, arch rolling, centos-stream 10, debian bookworm, debian trixie, fedora 43, fedora 44, nixos 26.05, nixpkgs unstable, opensuse-leap 16.0, ubuntu noble, ubuntu questing, ubuntu resolute, ubuntu stonking

πŸ’– CAPNG_GET_CAPS_PROCESS(3) β€” the Libcap-ng API girlies know πŸ’–

okay bestie, so this is a page from the Libcap-ng API (section 3 of the manual, the library-call section, iykyk) and it's literally just one tiny little function that's about to become your new obsession. sit down, grab a strawberry drink, let's go πŸ“


✨ NAME ✨

capng_get_caps_process β€” get the capabilities from a process 🫢


🌸 SYNOPSIS 🌸

#include <cap-ng.h>

int capng_get_caps_process(void);

πŸ¦‹ DESCRIPTION πŸ¦‹

so here's the vibe: capng_get_caps_process will get the capabilities and bounding set of the pid that's stored inside libcap-ng's state table. that's it, that's the whole job, and honestly? iconic for it πŸ’…

and the default pid in that state table? it's the pid of the running process. yes girl, you β€” main character energy πŸŽ€. but lowkey if you wanna snoop on a different pid, you can totally change that by using the capng_setpid function. flexible fr fr.


⭐ RETURN VALUE ⭐

she keeps it simple:

  • 0 β€” success, we ate ✨
  • -1 β€” failure, and we're not talking about it 😭

πŸ’€ NOTES πŸ’€

okay this is the part where you need to actually listen, bestie, because there are two whole situations that will absolutely humble you:

  • if you're doing multi-threaded programming, calling this function will only get capabilities on the calling thread. that's it. just that one thread. no cap. if you want the overall capabilities for a multi-threaded process, the way that you can only do that is before creating any threads. after that point, threads may be able to independently set capabilities β€” so like, do it early or don't do it at all, periodt πŸ™ˆ
  • capng_get_caps_process needs a mounted /proc to read the current bounding set. no /proc, no bounding set, and she will just straight-up fail. sorry girl πŸ’”
🚨 real talk: no mounted /proc = this function fails. not a vibe check you want to fail.

🌈 SEE ALSO 🌈


πŸ‘‘ AUTHOR πŸ‘‘

Steve Grubb β€” we stan a legend, fr fr 🫢


and that's the whole page, bestie!! this one comes to you from the Libcap-ng API, dropped by Red Hat back in June 2009 (yes, she's been serving since 2009 and she's still relevant, we love a timeless queen πŸ‘‘). now go get those capabilities, you got this πŸ’–βœ¨

πŸ“¦ where this page comes from