When using setcap, where is the permission stored

capabilitiessetcap

Using setcap to give additional permissions to a binary should write the new permission somewhere, on storage or in memory, where is it stored ?

Using lsof as is doesn't work because the process disappear too quickly.

Best Answer

Extended permissions such as access control lists set by setfacl and capability flags set by setcap are stored in the same place as traditional permissions and set[ug]id flags set by chmod: in the file's inode.

(They may actually be stored in a separate block on the disk, because an inode has a fixed size which has room for the traditional permission bits but not for the potentially unbounded extended permissions. But that only matters in rare cases, such as having to care that setcap could run out of disk space. But even chmod could run out of disk space on a system that uses deduplication!)

GNU ls doesn't display a file's setcap attributes. You can display them with getcap. You can list all the extended attributes with getfattr -d -m -; the setcap attribute is called security.capability and it is encoded in a binary format which getcap decodes for you.

Related Question