Name
_setfilecap, _getfilecap, _fsetfilecap, _fgetfilecap - set/get file capabilitiesSynopsis
#include <sys/capability.h> int _setfilecap(char const *" filename ", size_t " usize ", __cap_s const *" iset ", __cap_s const *" pset ", __cap_s const * eset );int _getproccap(char const *" filename ", size_t " usize ", __cap_s *" iset ", __cap_s *" pset ", __cap_s * eset );
int _fsetfilecap(int " fd ", size_t " usize ", __cap_s const *" iset ", __cap_s const *" pset ", __cap_s const * eset );
int _fgetproccap(int " fd ", size_t " usize ", __cap_s *" iset ", __cap_s *" pset ", __cap_s * eset );
Usage
cc ... -lcapDescription
_setfilecap sets the specifiedfilename 's
Inheritable, Permitted and Effective capabilities to the sets specified. A NULL pointer specifies that a set should not be changed. _fsetfilecap does the same thing to the file referenced by file descriptor fd
.
_getfilecap and _fgetfilecap copy the file's capability sets into the sets provided. A NULL pointer specifies that a set should not be returned.
The 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.
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.
Return Value
On success, zero is returned. On error, -1 is returned, and errno is set appropriately.Errors
One of the capability arguments or the filename was an invalid data pointer.
An attempt was made to set non-empty capabilities on a file, and the caller does not have the capability raised.
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 capability raised.
An attempt was made to set non-empty capabilities on a file residing on a file system that does not support them.
An attempt was made to set capabilities on a file residing on a read-only file system.
filename is too long.
The file specified does not exist.
Insufficient kernel memory was available.
A component of the path prefix is not a directory.
Search permission is denied on a component of the path prefix.
filename contains a circular reference (via symlinks).
fd is not a valid file descriptor.
A hard error occurred while reading or writing the file system.
The POSIX.1e capability system was not configured into the kernel.
Conforming To
These system calls are specific to Linux. The portable interfaces arecap_set_file (3),
cap_get_file (3),
cap_set_fd (3),
and cap_get_fd (3).
See Also
_setproccap (2).