summaryrefslogtreecommitdiff
path: root/doc/old/_setfilecap.2
blob: 6a0538cca3c12708269c6d726ff27eafb775dcf9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
.\"
.\" $Id: _setfilecap.2,v 1.1.1.1 1999/04/17 22:16:31 morgan Exp $
.\" written by Andrew Main <zefram@dcs.warwick.ac.uk>
.\"
.TH _SETFILECAP 2 "26th April 1997" "Linux 2.1" "Linux Programmer's Manual"
.SH NAME
_setfilecap, _getfilecap, _fsetfilecap, _fgetfilecap \- set/get file capabilities
.SH SYNOPSIS
.B #include <sys/capability.h>
.sp
.BI "int _setfilecap(char const *" filename ", size_t " usize ", __cap_s const *" iset ", __cap_s const *" pset ", __cap_s const *" eset );
.sp
.BI "int _getproccap(char const *" filename ", size_t " usize ", __cap_s *" iset ", __cap_s *" pset ", __cap_s *" eset );
.sp
.BI "int _fsetfilecap(int " fd ", size_t " usize ", __cap_s const *" iset ", __cap_s const *" pset ", __cap_s const *" eset );
.sp
.BI "int _fgetproccap(int " fd ", size_t " usize ", __cap_s *" iset ", __cap_s *" pset ", __cap_s *" eset );
.SH USAGE
.br
.B cc ... -lcap
.SH DESCRIPTION
.B _setfilecap
sets the specified
.IR filename 's
Inheritable, Permitted and Effective capabilities to the sets specified.
A NULL pointer specifies that a set should not be changed.
.PP
.B _fsetfilecap
does the same thing to the file referenced by file descriptor
.IR fd .
.PP
.B _getfilecap
and
.B _fgetfilecap
copy the file's capability sets into the sets provided.
A NULL pointer specifies that a set should not be returned.
.PP
The
.I usize
argument specifies the size of the user-space capability sets, in bytes.
If the kernel uses a different size internally, it will truncate or
zero-fill as required.
.PP
Files don't actually have a proper Effective capability set.  Instead they
have a single-bit flag, that indicates that the set is either full or
empty.  When setting a file's capabilities, that flag will be set if
and only if the Effective set specified has at least one bit set.
.SH "RETURN VALUE"
On success, zero is returned.  On error, -1 is returned, and
.I errno
is set appropriately.
.SH ERRORS
.TP
.SB EFAULT
One of the capability arguments or the filename was an invalid data pointer.
.TP
.SB EPERM
An attempt was made to set non-empty capabilities on a file,
and the caller does not have the
.SB CAP_FSETCAP
capability raised.
.TP
.SB EPERM
An attempt was made to set capabilities on a file, and
the effective UID does not match the owner of the file, and the caller
does not have the
.SB CAP_FOWNER
capability raised.
.TP
.SB EINVAL
An attempt was made to set non-empty capabilities on a file
residing on a file system that does not support them.
.TP
.SB EROFS
An attempt was made to set capabilities on a file residing
on a read-only file system.
.TP
.SB ENAMETOOLONG
.I filename
is too long.
.TP
.SB ENOENT
The file specified does not exist.
.TP
.SB ENOMEM
Insufficient kernel memory was available.
.TP
.SB ENOTDIR
A component of the path prefix is not a directory.
.TP
.SB EACCES
Search permission is denied on a component of the path prefix.
.TP
.SB ELOOP
.I filename
containes a circular reference (via symlinks).
.TP
.SB EBADF
.I fd
is not a valid file descriptor.
.TP
.SB EIO
A hard error occurred while reading or writing the file system.
.TP
.SB ENOSYS
The POSIX.1e capability system was not configured into the kernel.
.SH "CONFORMING TO"
These system calls are specific to Linux.
The portable interfaces are
.IR cap_set_file (3),
.IR cap_get_file (3),
.IR cap_set_fd (3),
and
.IR cap_get_fd (3).
.SH "SEE ALSO"
.IR _setproccap (2).