rust-lang / rust-lang/libs-team
Add security_attributes() to windows::OpenOptionsExt
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 178
- Forks
- 28
- Avg merge
- 15m
- Merged PRs (30d)
- 1
Description
Proposal
Problem statement
There is currently no means, using std::fs, to provide SECURITY_ATTRIBUTES when opening a file. A private implementation of OpenOptions do have a security_attributes function but it is not expose through the OpenOptionExt trait. In order to provide a SECURITY_ATTRIBUTES, one must use the windows crate directly calling C ffi bindings.
Motivating examples or use cases
let file = std::fs::File::options()
.access_mode(1179785u32) // FILE_GENERIC_READ
.share_mode(0) // FILE_SHARE_NONE
// no means to pass security attributes to add more security.
.open("foo.txt").unwrap();
Solution sketch
Extends OpenOptionsExt for windows
pub trait OpenOptionsExt {
// Required methods
fn [access_mode](https://doc.rust-lang.org/std/os/windows/fs/trait.OpenOptionsExt.html#tymethod.access_mode)(&mut self, access: [u32](https://doc.rust-lang.org/std/primitive.u32.html)) -> [&mut Self](https://doc.rust-lang.org/std/primitive.reference.html);
// ...
fn security_attributes(&mut self, attributes: SECURITY_ATTRIBUTES) -> &mut Self;
}
let attributes = // ...;
let file = std::fs::File::options()
.access_mode(1179785u32) // FILE_GENERIC_READ
.share_mode(0) // FILE_SHARE_NONE
.security_attributes(attributes)
.open("foo.txt").unwrap();
Links and related work
Design issue
The main design issue I see is how to provide a safe way to create security attributes.
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the Windows OpenOptionsExt trait and the existing private OpenOptions security_attributes implementation described in the issue. Determine a safe public representation for SECURITY_ATTRIBUTES and its ownership requirements; done means the trait exposes the capability without requiring direct windows-crate FFI, with appropriate coverage for the proposed usage.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- operating-systems
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 30/100