CAPNG_APPLY(3)
β¨ CAPNG_APPLY β¨
okay bestie, gather round, because this is the capng_apply page from the Libcap-ng API and it's lowkey the moment where all your carefully hoarded capability settings actually get yeeted into the kernel. π
πΈ NAME πΈ
capng_apply β apply the stored capabilities settings
π SYNOPSIS π
#include <cap-ng.h>
int capng_apply(capng_select_t set);
π¦ DESCRIPTION π¦
so here's the tea: capng_apply transfers the internal POSIX capabilities settings you've been curating (slay) over to the kernel. it's the "go" button. the "post it" button. the "manifest it and it's real now" button. π₯
and you get to pick what gets applied with the set argument:
CAPNG_SELECT_CAPSβ the traditional capabilities, classic behavior, iconic β¨CAPNG_SELECT_BOUNDSβ the bounding setCAPNG_SELECT_BOTHβ when you want both of them, because why choose πCAPNG_SELECT_AMBIENTβ if you're only operating on the ambient capabilitiesCAPNG_SELECT_ALLβ applying literally everything, main character energy, no crumbs left π
π RETURN VALUE π
it returns 0 on success, and a negative value on failure. and babes, the negative values are specific. here's the whole roster, no skips:
-1β not initialized-2βCAPNG_SELECT_BOUNDSand failure to drop a bounding set capability-3βCAPNG_SELECT_BOUNDSand failure to re-read bounding set-4βCAPNG_SELECT_BOUNDSand process does not haveCAP_SETPCAP-5βCAPNG_SELECT_CAPSand failure incapsetsyscall-6βCAPNG_SELECT_AMBIENTand process has no capabilities and failed clearing ambient capabilities-7βCAPNG_SELECT_AMBIENTand process has capabilities and failed clearing ambient capabilities-8βCAPNG_SELECT_AMBIENTand process has capabilities and failed setting an ambient capability-9β Unable to acquire process capabilities to check ifCAP_SETPCAPis set.
not me getting a -9 and spiraling π every single one of these is a real, distinct vibe check failure, so read the number, don't just assume.
β NOTES β
okay this part is important, bestie, so sit up. π«Ά
if you are doing multi-threaded programming, calling this function will only set capabilities on the calling thread. all other threads are unaffected. so if you want to set overall capabilities for a multi-threaded process, you will need to do that before creating any threads. periodt. see the capset syscall for more information on this topic.
also β and this is the part that gets people β bits in the bounding set can only be dropped. you cannot set them. it's giving one-way street, no u-turns, no take-backs π after dropping bounding set capabilities, the bounding set is synchronized with the kernel to reflect the true state in the kernel.
π SEE ALSO π
π AUTHOR π
Steve Grubb
and that's the whole page, bestie. this is CAPNG_APPLY(3) from the Libcap-ng API, brought to you by Red Hat, dated Sept 2023. go forth and apply those capabilities, you absolute icon ππ¦β¨
π¦ where this page comes from
- alpine 3.22: libcap-ng-doc 0.8.5-r0 Β· GPL-2.0-or-later AND LGPL-2.1-or-later
- alpine 3.23: libcap-ng-doc 0.8.5-r0 Β· GPL-2.0-or-later AND LGPL-2.1-or-later
- alpine 3.24: libcap-ng-doc 0.8.5-r2 Β· GPL-2.0-or-later AND LGPL-2.1-or-later
- arch rolling: libcap-ng 0.9.6-1 Β· GPL-2.0-or-later AND LGPL-2.1-or-later
- centos-stream 10: libcap-ng-devel 0.9.3-2.el10 Β· LGPL-2.0-or-later
- debian trixie: libcap-ng-dev 0.8.5-4+b1 Β· LGPL-2.1-or-later
- fedora 43: libcap-ng-devel 0.8.5-8.fc43 Β· LGPL-2.0-or-later
- fedora 43: libcap-ng-devel 0.8.5-8.fc43 Β· LGPL-2.0-or-later
- fedora 43: libcap-ng-devel 0.9.6-1.fc43 Β· LGPL-2.0-or-later
- fedora 43: libcap-ng-devel 0.9.6-1.fc43 Β· LGPL-2.0-or-later
- fedora 44: libcap-ng-devel 0.9.2-1.fc44 Β· LGPL-2.0-or-later
- fedora 44: libcap-ng-devel 0.9.2-1.fc44 Β· LGPL-2.0-or-later
- fedora 44: libcap-ng-devel 0.9.6-1.fc44 Β· LGPL-2.0-or-later
- fedora 44: libcap-ng-devel 0.9.6-1.fc44 Β· LGPL-2.0-or-later
- nixos 26.05: libcap-ng 0.9.3
- nixpkgs unstable: libcap-ng 0.9.6
- opensuse-leap 16.0: libcap-ng-devel 0.8.5-160000.3.2 Β· LGPL-2.1-or-later
- opensuse-leap 16.0: libcap-ng-devel 0.8.5-160000.3.2 Β· LGPL-2.1-or-later
- opensuse-leap 16.0: libcap-ng-devel 0.8.5-160000.3.2 Β· LGPL-2.1-or-later
- opensuse-leap 16.0: libcap-ng-devel 0.8.5-160000.3.2 Β· LGPL-2.1-or-later
- ubuntu noble: libcap-ng-dev 0.8.4-2build2 Β· LGPL-2.1-or-later
- ubuntu questing: libcap-ng-dev 0.8.5-4build2
- ubuntu resolute: libcap-ng-dev 0.8.5-4build5 Β· LGPL-2.1-or-later
- ubuntu stonking: libcap-ng-dev 0.9.6-1 Β· LGPL-2.1-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms