pub struct SecurityAttributes { /* private fields */ }Expand description
An owned capture of a caller’s lpSecurityAttributes argument.
Three outcomes that a single nullable pointer runs together are kept apart
by this type and AclState, because they are three different grants:
| Caller passed | Meaning | Represented as |
|---|---|---|
NULL attributes | default security, non-inheritable handle | None where a SecurityAttributes is expected |
attributes with a NULL descriptor | default security, caller’s inheritance choice | descriptor is None |
| attributes with a descriptor | the caller’s security | descriptor is Some |
and within a descriptor, an absent DACL, a NULL DACL, and an empty DACL are
three further distinct grants, reported by SecurityDescriptor::dacl.
§Example
The distinction a single nullable pointer runs together. Passing no attributes at all and passing attributes that carry no descriptor are different requests – the second still states an inheritance choice:
use windows_namespace_request_sys::SecurityAttributes;
// Attributes with no descriptor: default security, but the caller's
// inheritance choice is still carried.
let inheritable = SecurityAttributes::new(None, true);
assert!(inheritable.descriptor().is_none());
assert!(inheritable.inherit_handle());
let raw = inheritable.to_raw();
assert!(raw.lpSecurityDescriptor.is_null());
assert_ne!(raw.bInheritHandle, 0, "the choice survives into the Win32 struct");
// Passing *no* attributes is the third case, and is spelled `None` where a
// `SecurityAttributes` is expected rather than being confused with this.
let none: Option<SecurityAttributes> = None;
assert!(none.is_none());Implementations§
Source§impl SecurityAttributes
impl SecurityAttributes
Sourcepub fn new(descriptor: Option<SecurityDescriptor>, inherit_handle: bool) -> Self
pub fn new(descriptor: Option<SecurityDescriptor>, inherit_handle: bool) -> Self
Builds a capture from an already-owned descriptor and an inheritance choice.
Sourcepub unsafe fn capture(
attributes: *const SECURITY_ATTRIBUTES,
) -> Result<Option<Self>, SecurityCaptureError>
pub unsafe fn capture( attributes: *const SECURITY_ATTRIBUTES, ) -> Result<Option<Self>, SecurityCaptureError>
Captures the SECURITY_ATTRIBUTES at attributes.
A null attributes is not an error: it is the caller declining to
supply any, which is reported as Ok(None) rather than being confused
with attributes that carry no descriptor.
§Errors
Returns a SecurityCaptureError when the referenced descriptor cannot
be captured.
§Safety
attributes, if non-null, must point to a SECURITY_ATTRIBUTES that
stays valid for the duration of this call, as must any descriptor it
names.
Sourcepub fn descriptor(&self) -> Option<&SecurityDescriptor>
pub fn descriptor(&self) -> Option<&SecurityDescriptor>
The captured descriptor, if the caller supplied one.
Sourcepub fn inherit_handle(&self) -> bool
pub fn inherit_handle(&self) -> bool
Whether the caller asked for the resulting handle to be inheritable.
Trait Implementations§
Source§impl Clone for SecurityAttributes
impl Clone for SecurityAttributes
Source§fn clone(&self) -> SecurityAttributes
fn clone(&self) -> SecurityAttributes
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more