windows-acl
Rust library to simplify Windows ACL operations.
Using windows-acl
First, add the following line to the dependencies section of the project’s Cargo.toml
file.
winapi = “0.3.5”
windows-acl = “0.1.0”
In the main Rust source code file, add the windows-acl external crate and import the symbols as follows:
extern crate winapi;
extern crate windows_acl;
use ;
use ACL;
NOTE: Altering system ACL entries require either Administrator privileges or the ability to acquire the SeSecurityPrivilege
privilege.
Adding a mandatory integrity label
let high_integrity_level_sid = string_to_sid.unwrap;
let mut acl = ACL from_file_path.unwrap;
// Set high_il to be a high integrity level directory
match acl.integrity_level
Adding an audit entry
let world_sid = string_to_sid.unwrap;
let mut acl = ACL from_file_path.unwrap;
// Audit every file operation in sensitive_files from anyone in the Everyone group
match acl.audit
Denying guest access to a directory
let guests = string_to_sid.unwrap;
let mut acl = ACL from_file_path.unwrap;
// Guests cannot read anything in this directory. However, they can still drop files there
match acl.deny
Removing entries
let world_sid = string_to_sid.unwrap;
let mut acl = ACL from_file_path.unwrap;
// Remove a SystemAudit entry; remove() can also remove DACL entries as well
match acl.remove
Example Applications
See query_acl.rs
in the example/
directory.
Unit Tests
The current unit tests expect to be run in a single threaded environment with elevated privileges. By default, Rust executes unit tests with multiple threads. To successfully run tests, the following must be done:
- Open an elevated privilege/Administrator Command Prompt or Powershell Terminal.
- Set the
RUST_TEST_THREADS
environment variable to 1. - Run
cargo test