Expand description
§exacl
Manipulate file system access control lists (ACL) on macOS
, Linux
, and
FreeBSD
.
§Example
use exacl::{getfacl, setfacl, AclEntry, Perm};
// Get the ACL from "./tmp/foo".
let mut acl = getfacl("./tmp/foo", None)?;
// Print the contents of the ACL.
for entry in &acl {
println!("{entry}");
}
// Add an ACL entry to the end.
acl.push(AclEntry::allow_user("some_user", Perm::READ, None));
// Set the ACL for "./tmp/foo".
setfacl(&["./tmp/foo"], &acl, None)?;
§API
This module provides two high level functions, getfacl
and setfacl
.
On Linux and FreeBSD
, the ACL contains entries for the default ACL, if
present.
Both getfacl
and setfacl
work with a Vec<AclEntry>
. The
AclEntry
structure contains five fields:
- kind :
AclEntryKind
- the kind of entry (User, Group, Other, Mask, or Unknown). - name :
String
- name of the principal being given access. You can use a user/group name, decimal uid/gid, or UUID (on macOS). - perms :
Perm
- permission bits for the entry. - flags :
Flag
- flags indicating whether an entry is inherited, etc. - allow :
bool
- true if entry is allowed; false means deny. Linux only supports allow=true.
Structs§
- AclEntry
- ACL entry with allow/deny semantics.
- AclOption
- Controls how ACL’s are accessed.
- Flag
- Represents ACL entry inheritance flags.
- Perm
- Represents file access permissions.
Enums§
- AclEntry
Kind - Kind of ACL entry (User, Group, Mask, Other, or Unknown).
Functions§
- from_
mode Linux or FreeBSD - Construct a minimal ACL from the traditional
mode
permission bits. - from_
reader - Read ACL entries from text.
- from_
str - Read ACL entries from text.
- getfacl
- Get access control list (ACL) for a file or directory.
- setfacl
- Set access control list (ACL) for specified files and directories.
- to_
string - Write ACL entries to text.
- to_
writer - Write ACL entries to text.