Debian Codegraph @

docs/capng_lock.3

raw
1 .TH "CAPNG_LOCK" "3" "Mar 2026" "Red Hat" "Libcap-ng API"
2 .SH NAME
3 capng_lock \- lock the current process capabilities settings
4 .SH "SYNOPSIS"
5 .B #include <cap-ng.h>
6 .sp
7 int capng_lock(void);
8
9 .SH "DESCRIPTION"
10
11 capng_lock will take steps to prevent children of the current process
12 to regain full privileges if the uid is 0. This should be called while
13 possessing the CAP_SETPCAP capability in the kernel. This function will
14 do the following if permitted by the kernel:
15 .IP \[bu] 2
16 Set the NOROOT option on for PR_SET_SECUREBITS.
17 .IP \[bu] 2
18 Set the NOROOT_LOCKED option to on for PR_SET_SECUREBITS.
19 .IP \[bu] 2
20 Set the PR_NO_SETUID_FIXUP option on for PR_SET_SECUREBITS.
21 .IP \[bu] 2
22 Set the PR_NO_SETUID_FIXUP_LOCKED option on for PR_SET_SECUREBITS.
23 .PP
24 It does not enable PR_SET_KEEPCAPS or the KEEP_CAPS/KEEP_CAPS_LOCKED
25 securebits; after a successful call those usually remain off unless the
26 caller changed them separately.
27
28
29 .SH "RETURN VALUE"
30
31 This returns 0 on success and a negative number on failure. -1 means a failure setting any of the PR_SET_SECUREBITS options. -2 means failure setting PR_SET_NO_NEW_PRIVS. These are additive meaning -3 is a failure of both.
32
33 .SH "SEE ALSO"
34
35 .BR capng_apply (3),
36 .BR prctl (2),
37 .BR capabilities (7)
38
39 .SH AUTHOR
40 Steve Grubb