CAP_FCNTLS_LIMIT(2)
π CAP_FCNTLS_LIMIT(2) β the system calls manual page, bestie edition π
okay so this is cap_fcntls_limit and cap_fcntls_get, two little syscalls from the System Calls Manual section of the FreeBSD man pages. they manage which fcntl commands are allowed on a file descriptor. slay. let's get into it π¦
β¨ 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 vibe. if a file descriptor has been granted the CAP_FCNTL capability right, you can take that list of allowed fcntl(2) commands and selectively reduce it with the cap_fcntls_limit() system call. and like β reduce only. never expand. the way that it's a one-way street is honestly iconic. once you take a right away, it's gone. periodt. π
and if you wanna know what's still allowed? you grab a bitmask of the allowed fcntl commands for a given file descriptor with the cap_fcntls_get() system call. easy. cute. done. β¨
π FLAGS π
these are the flags you can shove into the fcntlrights argument, or that come back to you in the fcntlrightsp argument:
CAP_FCNTL_GETFLβ permits theF_GETFLcommand. yes ma'am π«ΆCAP_FCNTL_SETFLβ permits theF_SETFLcommand. πCAP_FCNTL_GETOWNβ permits theF_GETOWNcommand. πCAP_FCNTL_SETOWNβ permits theF_SETOWNcommand. π
β RETURN VALUES β
if it works? you get 0. blessed. π§
if it doesn't? you get -1, and the global variable errno gets set to tell you what went wrong. not the moment. π
π₯ ERRORS π₯
cap_fcntls_limit() succeeds unless:
[EBADF]β thefdargument is not a valid descriptor. bestie that's not a real fd, be so fr. π[EINVAL]β an invalid flag has been passed infcntlrights. who let that in.[ENOTCAPABLE]βfcntlrightswould expand the list of allowedfcntl(2)commands. nope. you can only ever shrink it, not grow it. that's the whole point. π
cap_fcntls_get() succeeds unless:
[EBADF]β thefdargument is not a valid descriptor. again. girl.[EFAULT]β thefcntlrightspargument points at an invalid address. bad pointer energy fr fr. π
π SEE ALSO π
π 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. lowkey a historic moment ngl. π°οΈ
π AUTHORS π
this function was created by Pawel Jakub Dawidek <pawel@dawidek.net> under sponsorship of the FreeBSD Foundation. give him his flowers. π
also hi, quick note: this is the Debian build of the page, dated May 5, 2020. so like, shoutout to Debian for shipping it, and that's the whole page. you understood it, you're a genius, go reduce some fcntl rights responsibly. mwah. πβ¨π¦
π¦ 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) 2012 The FreeBSD Foundation
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms