pub struct SanitizedMode(/* private fields */);Expand description
A Unix permission mode that has already passed through
[sanitize_permissions].
This newtype closes the gap between “a raw mode read from an archive
header” and “a mode safe to apply to an extracted file”: both are
otherwise a plain u32, so a caller could pass an unsanitized mode to
permission-setting code by mistake, with the invariant living only in a
doc comment. SanitizedMode can only be constructed by
[sanitize_permissions] — its single field is private, so external
callers (and other modules in this crate) cannot fabricate one that
skipped the setuid/setgid/world-writable stripping.
§Examples
use exarch_core::SecurityConfig;
use exarch_core::security::sanitize_permissions;
let config = SecurityConfig::default().validate()?;
// Setuid bit is stripped
let sanitized = sanitize_permissions(0o4755, &config);
assert_eq!(sanitized.as_u32(), 0o755);Implementations§
Trait Implementations§
Source§impl Clone for SanitizedMode
impl Clone for SanitizedMode
impl Copy for SanitizedMode
Source§impl Debug for SanitizedMode
impl Debug for SanitizedMode
impl Eq for SanitizedMode
Source§impl PartialEq for SanitizedMode
impl PartialEq for SanitizedMode
impl StructuralPartialEq for SanitizedMode
Auto Trait Implementations§
impl Freeze for SanitizedMode
impl RefUnwindSafe for SanitizedMode
impl Send for SanitizedMode
impl Sync for SanitizedMode
impl Unpin for SanitizedMode
impl UnsafeUnpin for SanitizedMode
impl UnwindSafe for SanitizedMode
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to
key and return true if they are equal.