trailofbits / windows-acl

Rust crate to simplify Windows ACL operations
https://blog.trailofbits.com/2018/08/23/introducing-windows-acl-working-with-acls-in-rust/
MIT License
18 stars 7 forks source link

Add ability to use object handles as ACL source #12

Closed gentoo90 closed 3 years ago

gentoo90 commented 3 years ago

This adds from_handle, from_file_handle, from_object_handle and from_registry_handle methods to ACL allowing to use Windows object handles instead of paths.

use std::fs::File;
use std::os::windows::io::AsRawHandle;
use winapi::ctypes::c_void;
use windows_acl::acl::ACL;

let file = File::open(path)?;
acl = ACL::from_file_handle(file.as_raw_handle() as *mut c_void, false)?;

CC gentoo90/winreg-rs#41

CLAassistant commented 3 years ago

CLA assistant check
All committers have signed the CLA.

woodruffw commented 3 years ago

Awesome, thank you! Would you mind adding some brief unit tests for these new API surfaces?

gentoo90 commented 3 years ago

Would you mind adding some brief unit tests for these new API surfaces?

I'm not sure what is the best way to test this. Should I just copy the tests with from_file_path and replace it with from_file_handle?

woodruffw commented 3 years ago

I'm not sure what is the best way to test this. Should I just copy the tests with from_file_path and replace it with from_file_handle?

Yep, something like that sounds good to me.

woodruffw commented 3 years ago

Grr, CI got disabled at some point.

woodruffw commented 3 years ago

Thanks again!