CAP_FCNTLS_LIMIT(2)
π cap_fcntls_limit, cap_fcntls_get β the system call manual page, bestie edition
okay so you found the CAP_FCNTLS_LIMIT(2) page, from the System Calls Manual β¨ β welcome, sit down, let's talk about managing allowed fcntl commands π
πΈ NAME πΈ
cap_fcntls_limit, cap_fcntls_get β manage allowed fcntl commands π¦
π LIBRARY π
Standard C Library (libc, -lc) π
β¨ SYNOPSIS β¨
#include <sys/capsicum.h>
int
cap_fcntls_limit(int fd, uint32_t fcntlrights);
int
cap_fcntls_get(int fd, uint32_t *fcntlrightsp);
π« DESCRIPTION π«
So here's the tea, bestie π« β if a file descriptor has been granted the CAP_FCNTL capability right, you can selectively reduce the list of allowed fcntl(2) commands using the cap_fcntls_limit() system call. Reduce only though!! You can never expand it back. That's the whole point, no cap π
And if you just wanna look at which fcntl commands a given file descriptor is allowed to run? That's cap_fcntls_get(), which hands you back a bitmask of allowed fcntl commands π
π© FLAGS π©
These are the flags you can pop into the fcntlrights argument, or that come back out in the fcntlrightsp argument:
CAP_FCNTL_GETFLβ lets theF_GETFLcommand through πCAP_FCNTL_SETFLβ lets theF_SETFLcommand through πCAP_FCNTL_GETOWNβ lets theF_GETOWNcommand through πCAP_FCNTL_SETOWNβ lets theF_SETOWNcommand through π
π«Ά RETURN VALUES π«Ά
If everything goes slay, the value 0 is returned π Otherwise you get the value -1 back, and the global variable errno gets set so it can tell you what went wrong π
π ERRORS π
cap_fcntls_limit() succeeds unless one of these happens:
[EBADF]β the fd argument is not a valid descriptor π[EINVAL]β an invalid flag got passed in fcntlrights π¬[ENOTCAPABLE]β fcntlrights would expand the list of allowedfcntl(2)commands π« (not allowed, bestie, that door only swings one way)
cap_fcntls_get() succeeds unless one of these happens:
[EBADF]β the fd argument is not a valid descriptor π[EFAULT]β the fcntlrightsp argument points at an invalid address π₯[ENOSYS]β the running kernel was compiled withoutoptions CAPABILITY_MODEπ
π SEE ALSO π
cap_ioctls_limit(2), cap_rights_limit(2), fcntl(2) β go read these next, iykyk π
π°οΈ HISTORY π°οΈ
The cap_fcntls_get() and cap_fcntls_limit() system calls first appeared in FreeBSD 8.3 β And support for capabilities and capabilities mode was developed as part of the TrustedBSD Project π§
π AUTHORS π
This function was created by Pawel Jakub Dawidek <pawel@dawidek.net> under sponsorship of the FreeBSD Foundation π
okay that's the whole page, main character energy from start to finish πΈ this version came from Debian, dated March 9, 2023 β mwah, go forth and cap your fcntls responsibly π β¨
π¦ where this page comes from
- freebsd 14.5: base 14.5
- freebsd 15.1: base 15.1
- Copyright (c) 2012 The FreeBSD Foundation
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms