1.9 KiB
1.9 KiB
Name
pledge - reduce process capabilities
Synopsis
#include <unistd.h>
int pledge(const char* promises, const char* execpromises);
Description
pledge()
makes a promise to the kernel that from this moment on, the calling process will only use a subset of system functionality.
Functionality is divided into a curated set of promises (described below), which can be combined to cover the program's needs. Both arguments are space-separated lists of promises.
Note that pledge()
can be called repeatedly to remove previously-pledged promises, but it can never regain capabilities once lost.
promises
are applied to the current process, and will also be inherited by children created by fork
(2).
execpromises
are applied if/when a new process image is created with exec(2)
.
If promises
or execpromises
is null, the corresponding value is unchanged.
Promises
stdio
: Basic I/O, memory allocation, information about self, various non-desctructive syscallsthread
: The POSIX threading APIid
: Ability to change UID/GIDtty
: TTY related functionilityproc
: Process and scheduling related functionalityexec
: Theexec(2)
syscalltty
: TTY related functionilityunix
: UNIX local domain socketsinet
: IPv4 domain socketsrpath
: "Read" filesystem accesswpath
: "Write" filesystem accesscpath
: "Create" filesystem accessdpath
: Creating new device fileschown
: Changing file owner/groupfattr
: Changing file attributes/permissionsshared_buffer
: Shared memory bufferschroot
: Thechroot(2)
syscallvideo
: May useioctl(2)
andmmap(2)
on framebuffer video devices
Errors
EFAULT
:promises
and/orexecpromises
are not null and not in readable memory.EINVAL
: One or more invalid promises were specified.EPERM
: An attempt to increase capabilities was rejected.