Function exacl::getfacl

source ·
pub fn getfacl<P, O>(path: P, options: O) -> Result<Vec<AclEntry>>
where P: AsRef<Path>, O: Into<Option<AclOption>>,
Expand description

Get access control list (ACL) for a file or directory.

On success, returns a vector of AclEntry with all access control entries for the specified path. The semantics and permissions of the access control list depend on the underlying platform.

§macOS

The ACL only includes the extended entries beyond the normal permission mode of the file. macOS provides several ACL entry flags to specify how entries may be inherited by directory sub-items. If there’s no extended ACL for a file, this function may return zero entries.

If path points to a symlink, getfacl returns the ACL of the file pointed to by the symlink. Use AclOption::SYMLINK_ACL to obtain the ACL of a symlink itself.

AclOption::DEFAULT_ACL option is not supported on macOS.

§Linux

The ACL includes entries related to the permission mode of the file. These are marked with empty names (“”).

Both the access ACL and the default ACL are returned in one list, with the default ACL entries indicated by a Flag::DEFAULT flag.

If path points to a symlink, getfacl returns the ACL of the file pointed to by the symlink. AclOption::SYMLINK_ACL is not supported on Linux.

AclOption::DEFAULT_ACL causes getfacl to only include entries for the default ACL, if present for a directory path. When called with AclOption::DEFAULT_ACL, getfacl may return zero entries.

§Example

use exacl::getfacl;

let entries = getfacl("./tmp/foo", None)?;

§Errors

Returns an io::Error on failure.