devutils/ATFQ/book ATFQ git

Part II · Your system

15.4 ACLs and capabilities

alsoaclaclsgetfaclsetfaclcapabilitiescapabilitysetcapgetcapcap_net_bind_service

TL;DR

  • An ACL gives rights to more people than owner, group and others: "bob may read this file too".
  • A + after the rights in ls -l means the file has an ACL.
  • Capabilities split root's power into pieces: a program can get one, such as listening on ports under 1024, without running as root.
setfacl -m u:bob:r report.pdf
getfacl report.pdf
sudo setcap cap_net_bind_service=+ep ./server

Pitfalls

Deep dive 2 questions

How does an ACL work?

It adds entries next to the classic three: named users, named groups, and a mask that caps what they and the owning group can get. The kernel checks the owner first, then named users, then groups, then others. ext4, btrfs and XFS support ACLs without any special setting.

Which capabilities exist?

About forty. CAP_NET_BIND_SERVICE opens ports under 1024, CAP_NET_ADMIN changes network settings, CAP_DAC_OVERRIDE ignores file rights, and CAP_SYS_ADMIN is a catch-all close to full root. man 7 capabilities lists them all; grep Cap /proc/self/status shows the sets of a process, as hex numbers that capsh --decode translates.

Commands
getfacl setfacl getcap setcap
See also
15. Permissions
15.1 rwx, octal and umask
15.2 setuid, setgid and sticky bit