Not able to set custom Security Attributes
Describe the bug
I'm attempting to set custom security attributes for the ListenerOption of a LocalSocket. The method SecurityDescriptor::write_to_security_attributes takes a mutable reference to a SECURITY_ATTRIBUTES object from windows_sys::Win32::Security. However, the interprocess crate does not expose the underlying SECURITY_ATTRIBUTES type. I tried addding windows_sys to my project dependencies. This leads to a conflict since Rust treats different versions of the same crate as distinct types:
two different versions of crate
windows_sysare being used; two types coming from two different versions of the same crate are different types even if they look the same
Steps to Reproduce
- Add the latest version of
windows-systo the project dependency - Create object to the
windows_sys::Win32::Security::SECURITY_ATTRIBUTES - Create new
SecurityDescriptorobject usinginterprocess::os::windows::security_descriptor::owned::SecurityDescriptor::new() - Try to pass object of the
SECURITY_ATTRIBUTESto theSecurityDescriptor::write_to_security_attributes()method
My Code Snippet
use windows_sys::Win32::Security::SECURITY_ATTRIBUTES;
let printname = "example.sock";
let name = printname.to_ns_name::<GenericNamespaced>()?;
let mut sa: SECURITY_ATTRIBUTES = unsafe { zeroed() };
// modifying `sa` here
let mut sd = SecurityDescriptor::new()?;
sd.write_to_security_attributes(&mut sa); // mismatch type if we use latest version of `windows-sys`
Workaround Using the same version of windows-sys as interprocess uses which is:
windows-sys = { version = "0.52.0", features = ["Win32_Security"] }
fixes the problem, but it forces the project to lock to an older version of windows-sys