ACL_SET_FD(3)

πŸ“¦
version 2.4.0 Β· 2 versions
  • 2.4.0 Β· alpine 3.22, alpine 3.23, alpine 3.24, arch rolling, centos-stream 10, centos-stream 9, debian bookworm, debian trixie, fedora 43, fedora 44, nixpkgs unstable, opensuse-leap 16.0, ubuntu jammy, ubuntu noble, ubuntu resolute, ubuntu stonking (latest)
  • 15.1 Β· freebsd 14.5, freebsd 15.1
, in alpine 3.22, alpine 3.23, alpine 3.24, arch rolling, centos-stream 10, centos-stream 9, debian bookworm, debian trixie, fedora 43, fedora 44, nixpkgs unstable, opensuse-leap 16.0, ubuntu jammy, ubuntu noble, ubuntu resolute, ubuntu stonking

πŸ’– ACL_SET_FD(3) πŸ’–

okay bestie, so this one lives in section 3 of the manual β€” that's the library functions section, for when you're writing actual C code and not just yelling at your shell. Welcome to the Linux Access Control Lists corner of the internet. Let's get into it. πŸ¦‹


🌸 LIBRARY 🌸

Linux Access Control Lists library β€” link it with libacl, -lacl. That's the vibe. πŸ’…


✨ SYNOPSIS ✨

#include <sys/types.h>
#include <sys/acl.h>

int
acl_set_fd(int fd, acl_t acl);

two includes, one function, zero drama. iconic honestly. πŸŽ€


🫢 DESCRIPTION 🫢

So like, what does acl_set_fd() actually do? It associates an access ACL with the file referred to by fd. That's the whole plot. You hand it a file descriptor, you hand it an ACL, and boom β€” they're together now. πŸ’ž

But wait, there's a gatekeeper. 😀 For the request to succeed, the effective user ID of the process must match the owner of the file, OR the process must have the CAP_FOWNER capability. That's it, that's the entry fee. No matching owner and no cap? No ACL for you, babes.


πŸ’… RETURN VALUE πŸ’…

  • On success: acl_set_fd() returns the value 0. πŸŽ‰ slay.
  • On failure: the value -1 is returned, and the global variable errno gets set to tell you exactly what went wrong. 😭 read your errno, bestie, it's literally trying to communicate with you.

πŸ”₯ ERRORS πŸ”₯

If any of these conditions occur, acl_set_fd() returns the value -1 and sets errno to the corresponding value. Here's the whole roster, no skips:

  • [EBADF] β€” the fd argument is not a valid file descriptor. not a real fd, not a real problem we can solve. πŸ’€
  • [EINVAL] β€” the argument acl does not point to a valid ACL. OR: the ACL has more entries than the file referred to by fd can obtain. too much ACL for this file to hold, sorry. πŸ™ˆ
  • [ENOSPC] β€” the directory or file system that would contain the new ACL cannot be extended, or the file system is out of file allocation resources. no room, no resources, no ACL. 😭
  • [ENOTSUP] β€” the file identified by fd cannot be associated with the ACL because the file system on which the file is located does not support this. the filesystem literally said "not my thing." πŸ’€
  • [EPERM] β€” the process does not have appropriate privilege to perform the operation to set the ACL. permissions said no. 🚫
  • [EROFS] β€” this function requires modification of a file system which is currently read-only. you cannot write to a read-only filesystem, that's the whole point of read-only. πŸ₯²
fr fr, if you're getting -1 back, check errno before you do literally anything else. it's giving helpful, let it help you. 🫢

πŸ‘‘ STANDARDS πŸ‘‘

IEEE Std 1003.1e draft 17 β€” aka β€œPOSIX.1e”, aka the abandoned one. 😭 it's canon but it's also kinda orphaned. we still love it though. periodt.


🌈 SEE ALSO 🌈

Go read these too, bestie, they're all in the group chat:


πŸ’œ AUTHOR πŸ’œ

Derived from the FreeBSD manual pages written by Robert N M Watson <rwatson@FreeBSD.org>, and adapted for Linux by Andreas Gruenbacher <andreas.gruenbacher@gmail.com>. absolute legends, we thank them for their service. 🫑✨


aaaand that's the whole page, babe. this one's from Linux ACL, dated March 23, 2002 β€” old but still holding it down. go set some ACLs, you've got this. πŸ’–πŸ¦‹πŸŽ€

πŸ“¦ where this page comes from