RIGHTS(4)
β¨ RIGHTS(4) β the capability rights manual page, bestie edition β¨
Kernel Interfaces Manual Β· RIGHTS(4)
πΈ NAME πΈ
Capability rights β the Capsicum capability rights for file descriptors π
π DESCRIPTION π
okay so picture this: a file descriptor gets born π¦. Like, it just got created by one of these functions:
accept(2)accept4(2)fhopen(2)kqueue(2)mq_open(2)open(2)openat(2)pdfork(2)pipe(2)shm_open(2)socket(2)socketpair(2)
and the very first thing that happens to it? it gets assigned ALL the capability rights. every single one. it's giving main character energy on day one, no cap π .
but here's the thing bestie β those rights can be reduced, and never, ever expanded. like, it's a one-way street, and there is no U-turn, periodt. you do the reducing with these three system calls:
once you've reduced the capability rights on a file descriptor, every operation you try to do on that fd gets limited to only the stuff those remaining rights allow. it's a vibe check for syscalls, fr fr π₯.
the complete list of capability rights is right below π. the cap_rights_t type is what stores the list of capability rights, and you should use the cap_rights_init(3) family of functions to manage that structure π«Ά.
not me hyping up a data structure but the cap_rights_init(3) family really is the moment, iykyk π
β¦to be continued, bestie π
β¨ RIGHTS β¨
okay bestie, so like, the following rights can be specified in a rights mask. it's giving permission slip energy, fr fr. π
CAP_ACCEPTβ Permitaccept(2)andaccept4(2). slay β¨CAP_ACL_CHECKβ Permitacl_valid_fd_np(3). πCAP_ACL_DELETEβ Permitacl_delete_fd_np(3). πCAP_ACL_GETβ Permitacl_get_fd(3)andacl_get_fd_np(3). π¦CAP_ACL_SETβ Permitacl_set_fd(3)andacl_set_fd_np(3). πΈCAP_BINDβ When not in capabilities mode, permitbind(2)andbindat(2)with special valueAT_FDCWDin the fd parameter. Note that sockets can also become bound implicitly as a result ofconnect(2)orsend(2), and that socket options set withsetsockopt(2)may also affect binding behavior. π«ΆCAP_BINDATβ Permitbindat(2). This right has to be present on the directory descriptor. This right includes theCAP_LOOKUPright. πCAP_CHFLAGSATβ An alias toCAP_FCHFLAGSandCAP_LOOKUP. πCAP_CONNECTβ When not in capabilities mode, permitconnect(2)andconnectat(2)with special valueAT_FDCWDin the fd parameter. This right is also required forsendto(2)with a non-NULLdestination address. π₯CAP_CONNECTATβ Permitconnectat(2). This right has to be present on the directory descriptor. This right includes theCAP_LOOKUPright. πCAP_CREATEβ Permitopenat(2)with theO_CREATflag. πCAP_EVENTβ Permitselect(2),poll(2), andkevent(2)to be used in monitoring the file descriptor for events. βCAP_EXTATTR_DELETEβ Permitextattr_delete_fd(2). πCAP_EXTATTR_GETβ Permitextattr_get_fd(2). πCAP_EXTATTR_LISTβ Permitextattr_list_fd(2). πCAP_EXTATTR_SETβ Permitextattr_set_fd(2). π§CAP_FCHDIRβ Permitfchdir(2). πCAP_FCHFLAGSβ Permitfchflags(2)andchflagsat(2)if theCAP_LOOKUPright is also present. β¨CAP_FCHMODβ Permitfchmod(2)andfchmodat(2)if theCAP_LOOKUPright is also present. πCAP_FCHMODATβ An alias toCAP_FCHMODandCAP_LOOKUP. πCAP_FCHOWNβ Permitfchown(2)andfchownat(2)if theCAP_LOOKUPright is also present. π¦CAP_FCHOWNATβ An alias toCAP_FCHOWNandCAP_LOOKUP. πΈCAP_FCNTLβ Permitfcntl(2). Note that only theF_GETFL,F_SETFL,F_GETOWNandF_SETOWNcommands require this capability right. Also note that the list of permitted commands can be further limited with thecap_fcntls_limit(2)system call. π«ΆCAP_FEXECVEβ Permitfexecve(2)andopenat(2)with theO_EXECflag;CAP_READis also required. πCAP_FLOCKβ Permitflock(2),fcntl(2)(withF_GETLK,F_SETLK,F_SETLKWorF_SETLK_REMOTEflag) andopenat(2)(withO_EXLOCKorO_SHLOCKflag). πCAP_FPATHCONFβ Permitfpathconf(2). π₯CAP_FSCKβ Permit UFS background-fsck operations on the descriptor. πCAP_FSTATβ Permitfstat(2)andfstatat(2)if theCAP_LOOKUPright is also present. πCAP_FSTATATβ An alias toCAP_FSTATandCAP_LOOKUP. βCAP_FSTATFSβ Permitfstatfs(2). πCAP_FSYNCβ Permitaio_fsync(2),fdatasync(2),fsync(2)andopenat(2)withO_FSYNCorO_SYNCflag. πCAP_FTRUNCATEβ Permitftruncate(2)andopenat(2)with theO_TRUNCflag. πCAP_FUTIMESβ Permitfutimens(2)andfutimes(2), and permitfutimesat(2)andutimensat(2)if theCAP_LOOKUPright is also present. π§CAP_FUTIMESATβ An alias toCAP_FUTIMESandCAP_LOOKUP. πCAP_GETPEERNAMEβ Permitgetpeername(2). β¨CAP_GETSOCKNAMEβ Permitgetsockname(2). πCAP_GETSOCKOPTβ Permitgetsockopt(2). πCAP_IOCTLβ Permitioctl(2). Be aware that this system call has enormous scope, including potentially global scope for some objects. The list of permitted ioctl commands can be further limited with thecap_ioctls_limit(2)system call. π¦CAP_KQUEUEβ An alias toCAP_KQUEUE_CHANGEandCAP_KQUEUE_EVENT. πΈCAP_KQUEUE_CHANGEβ Permitkevent(2)on akqueue(2)descriptor that modifies list of monitored events (the changelist argument is non-NULL). π«ΆCAP_KQUEUE_EVENTβ Permitkevent(2)on akqueue(2)descriptor that monitors events (the eventlist argument is non-NULL).CAP_EVENTis also required on file descriptors that will be monitored usingkevent(2). πCAP_LINKAT_SOURCEβ Permitlinkat(2)on the source directory descriptor. This right includes theCAP_LOOKUPright.
β οΈ Warning:CAP_LINKAT_SOURCEmakes it possible to link files in a directory for which file descriptors exist that have additional rights. For example, a file stored in a directory that does not allowCAP_READmay be linked in another directory that does allowCAP_READ, thereby granting read access to a file that is otherwise unreadable. π
CAP_LINKAT_TARGETβ Permitlinkat(2)on the target directory descriptor. This right includes theCAP_LOOKUPright. π₯CAP_LISTENβ Permitlisten(2); not much use (generally) withoutCAP_BIND. πCAP_LOOKUPβ Permit the file descriptor to be used as a starting directory for calls such aslinkat(2),openat(2), andunlinkat(2). πCAP_MAC_GETβ Permitmac_get_fd(3). βCAP_MAC_SETβ Permitmac_set_fd(3). πCAP_MKDIRATβ Permitmkdirat(2). This right includes theCAP_LOOKUPright. πCAP_MKFIFOATβ Permitmkfifoat(2). This right includes theCAP_LOOKUPright. πCAP_MKNODATβ Permitmknodat(2). This right includes theCAP_LOOKUPright. π§CAP_MMAPβ Permitmmap(2)with thePROT_NONEprotection. πCAP_MMAP_Rβ Permitmmap(2)with thePROT_READprotection. This right includes theCAP_READandCAP_SEEKrights. β¨CAP_MMAP_RWβ An alias toCAP_MMAP_RandCAP_MMAP_W. πCAP_MMAP_RWXβ An alias toCAP_MMAP_R,CAP_MMAP_WandCAP_MMAP_X. πCAP_MMAP_RXβ An alias toCAP_MMAP_RandCAP_MMAP_X. π¦CAP_MMAP_Wβ Permitmmap(2)with thePROT_WRITEprotection. This right includes theCAP_WRITEandCAP_SEEKrights. πΈCAP_MMAP_WXβ An alias toCAP_MMAP_WandCAP_MMAP_X. π«ΆCAP_MMAP_Xβ Permitmmap(2)with thePROT_EXECprotection. This right includes theCAP_SEEKright. πCAP_PDGETPIDβ Permitpdgetpid(2). πCAP_PDKILLβ Permitpdkill(2). π₯CAP_PEELOFFβ Permitsctp_peeloff(2). πCAP_PREADβ An alias toCAP_READandCAP_SEEK. πCAP_PWRITEβ An alias toCAP_SEEKandCAP_WRITE. βCAP_READβ Permitaio_read(2)(CAP_SEEKis also required),openat(2)with theO_RDONLYflag,read(2),readv(2),recv(2),recvfrom(2),recvmsg(2),pread(2)(CAP_SEEKis also required),preadv(2)(CAP_SEEKis also required) and related system calls. πCAP_RECVβ An alias toCAP_READ. πCAP_RENAMEAT_SOURCEβ Permitrenameat(2)on the source directory descriptor. This right includes theCAP_LOOKUPright.
β οΈ Warning:CAP_RENAMEAT_SOURCEmakes it possible to move files to a directory for which file descriptors exist that have additional rights. For example, a file stored in a directory that does not allowCAP_READmay be moved to another directory that does allowCAP_READ, thereby granting read access to a file that is otherwise unreadable. π
CAP_RENAMEAT_TARGETβ Permitrenameat(2)on the target directory descriptor. This right includes theCAP_LOOKUPright. π§CAP_SEEKβ Permit operations that seek on the file descriptor, such aslseek(2), but also required for I/O system calls that can read or write at any position in the file, such aspread(2)andpwrite(2). πCAP_SEM_GETVALUEβ Permitsem_getvalue(3). β¨CAP_SEM_POSTβ Permitsem_post(3). πCAP_SEM_WAITβ Permitsem_wait(3)andsem_trywait(3). πCAP_SENDβ An alias toCAP_WRITE. π¦CAP_SETSOCKOPTβ Permitsetsockopt(2); this controls various aspects of socket behavior and may affect binding, connecting, and other behaviors with global scope. πΈCAP_SHUTDOWNβ Permit explicitshutdown(2); closing the socket will also generally shut down any connections on it. π«ΆCAP_SYMLINKATβ Permitsymlinkat(2). This right includes theCAP_LOOKUPright. πCAP_TTYHOOKβ Allow configuration of TTY hooks, such assnp(4), on the file descriptor. πCAP_UNLINKATβ Permitunlinkat(2)andrenameat(2). This right is only required forrenameat(2)on the destination directory descriptor if the destination object already exists and will be removed by the rename. This right includes theCAP_LOOKUPright. π₯CAP_WRITEβ Allowaio_write(2),openat(2)withO_WRONLYandO_APPENDflags set,send(2),sendmsg(2),sendto(2),write(2),writev(2),pwrite(2),pwritev(2)and related system calls. Forsendto(2)with a non-NULLconnection address,CAP_CONNECTis also required. Foropenat(2)with theO_WRONLYflag, but without theO_APPENDflag,CAP_SEEKis also required. Foraio_write(2),pwrite(2)andpwritev(2)CAP_SEEKis also required. π
β¨ SEE ALSO β¨
okay so literally the entire squad pulled up π every single one of these is your bestie now, bestie:
accept(2),accept4(2),aio_fsync(2),aio_read(2),aio_write(2),bind(2),bindat(2),cap_enter(2),cap_fcntls_limit(2),cap_ioctls_limit(2),cap_rights_limit(2),chflagsat(2),connect(2),connectat(2),extattr_delete_fd(2),extattr_get_fd(2),extattr_list_fd(2),extattr_set_fd(2)fchflags(2),fchmod(2),fchmodat(2),fchown(2),fchownat(2),fcntl(2),fexecve(2),fhopen(2),flock(2),fpathconf(2),fstat(2),fstatat(2),fstatfs(2),fsync(2),ftruncate(2),futimes(2)getpeername(2),getsockname(2),getsockopt(2),ioctl(2),kevent(2),kqueue(2),linkat(2),listen(2),mmap(2),mq_open(2),open(2),openat(2),pdfork(2),pdgetpid(2),pdkill(2),pdwait4(2)pipe(2),poll(2),pread(2),preadv(2),pwrite(2),pwritev(2),read(2),readv(2),recv(2),recvfrom(2),recvmsg(2),renameat(2),sctp_peeloff(2),select(2),send(2),sendmsg(2),sendto(2),setsockopt(2),shm_open(2),shutdown(2),socket(2),socketpair(2),symlinkat(2),unlinkat(2),write(2),writev(2)acl_delete_fd_np(3),acl_get_fd(3),acl_get_fd_np(3),acl_set_fd(3),acl_set_fd_np(3),acl_valid_fd_np(3),mac_get_fd(3),mac_set_fd(3),sem_getvalue(3),sem_post(3),sem_trywait(3),sem_wait(3),capsicum(4),snp(4)
like, that's the whole group chat, no one's getting left on read π
π HISTORY π
Support for capabilities and capabilities mode was developed as part of the TrustedBSD Project. lowkey a whole era for the BSD girlies, and we're still reaping the benefits π
π AUTHORS π
This manual page was created by Pawel Jakub Dawidek <pawel@dawidek.net> under sponsorship from the FreeBSD Foundation, based on the cap_new(2) manual page by Robert Watson <rwatson@FreeBSD.org>.
ngl, building docs on top of someone else's docs and crediting them properly? that's main character energy, that's academic integrity, that's iconic π
okay bestie that's a wrap on the whole page π«Ά go forth and cap_rights_limit(2) responsibly, and remember: capability mode is not a vibe you half-do. it's giving all or nothing π
this came to you from the Debian camp, dated February 28, 2019, and it lives under the name RIGHTS(4) β the fourth section, the file formats one, iykyk πβ¨
π¦ where this page comes from
- debian bookworm: freebsd-manpages 12.2-1 Β· BSD-2-Clause-FreeBSD AND BSD-4-Clause
- debian trixie: freebsd-manpages 12.2-2 Β· BSD-2-Clause-FreeBSD AND BSD-4-Clause
- ubuntu jammy: freebsd-manpages 12.2-1 Β· BSD-2-Clause-FreeBSD AND BSD-4-Clause
- ubuntu noble: freebsd-manpages 12.2-1 Β· BSD-2-Clause-FreeBSD AND BSD-4-Clause
- ubuntu questing: freebsd-manpages 12.2-2
- ubuntu resolute: freebsd-manpages 12.2-2build1 Β· BSD-2-Clause-FreeBSD AND BSD-4-Clause
- ubuntu stonking: freebsd-manpages 12.2-2build1 Β· BSD-2-Clause-FreeBSD AND BSD-4-Clause
- Copyright (c) 2008-2010 Robert N. M. Watson
- Copyright (c) 2012-2013 The FreeBSD Foundation
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms