1CAP_GET_PROC(3)            Linux Programmer's Manual           CAP_GET_PROC(3)
2
3
4

NAME

6       cap_get_proc, cap_set_proc - POSIX capability manipulation on processes
7
8       capgetp,  capsetp - Linux specific capability manipulation on arbitrary
9       processes
10

SYNOPSIS

12       #include <sys/capability.h>
13
14       cap_t cap_get_proc(void);
15       int cap_set_proc(cap_t cap_p);
16
17       #undef _POSIX_SOURCE
18       #include <sys/capability.h>
19
20       cap_t capgetp(pid_t pid, cap_t cap_d);
21       cap_t capsetp(pid_t pid, cap_t cap_d);
22
23

USAGE

25       cc ... -lcap
26

DESCRIPTION

28       cap_get_proc allocates a capability state in working storage, sets  its
29       state  to  that  of  the calling process, and returns a pointer to this
30       newly created capability state.  The caller should free any  releasable
31       memory,  when  the  capability  state  in  working storage is no longer
32       required, by calling cap_free with the cap_t as an argument.
33
34       cap_set_proc sets the values for all capability flags for all capabili‐
35       ties with the capability state identified by cap_p.  The new capability
36       state of the process will be completely determined by the  contents  of
37       cap_p  upon successful return from this function.  If any flag in cap_p
38       is set for any capability  not  currently  permitted  for  the  calling
39       process,  the  function  will  fail,  and  the  capability state of the
40       process will remain unchanged.
41
42       capgetp fills an existing cap_d,  see  cap_init(3),  with  the  process
43       capabilities  of  the  process  indicated by pid.  This information can
44       also be obtained from the /proc/<pid>/status file.
45
46       capsetp attempts to set the capabilities  of  some  other  process(es),
47       pid.   If  pid  is  positive it refers to a specific process;  if it is
48       zero, it refers to the current process;  -1  refers  to  all  processes
49       other  than  the  current  process and process '1' (typically init(8));
50       other negative values refer to the -pid process-group.  In order to use
51       this  function, the current process must have CAP_SETPCAP raised in its
52       Effective  capability  set.   The  capabilities  set  in   the   target
53       process(es) are those contained in cap_d.
54
55

RETURN VALUE

57       cap_get_proc returns a non-NULL value on success, and NULL on failure.
58
59       cap_set_proc,  capgetp  and  capsetp return zero for success, and -1 on
60       failure.
61
62       On failure, errno(3) is set to EINVAL, EPERM, or ENOMEM.
63

CONFORMING TO

65       cap_set_proc and cap_get_proc are functions specified in the draft  for
66       POSIX.1e.
67
68

NOTES

70       The  function  capsetp should be used with care.  It exists, primarily,
71       to overcome a lack of support for capabilities in any of  the  filesys‐
72       tems  supported by Linux.  The semantics of this function may change as
73       it is better understood.  Please note, by default, the  only  processes
74       that have CAP_SETPCAP available to them are processes started as a ker‐
75       nel-thread.  (Typically this includes init(8), kflushd and kswapd). You
76       will need to recompile the kernel to modify this default.
77
78

SEE ALSO

80       cap_clear(3),   cap_copy_ext(3),   cap_from_text(3),   cap_get_file(3),
81       cap_init(3)
82
83
84
85                                 26th May 1997                 CAP_GET_PROC(3)
Impressum