pub struct UnixSocketCapability {
pub original: PathBuf,
pub resolved: PathBuf,
pub scope: SocketScope,
pub mode: UnixSocketMode,
pub source: CapabilitySource,
}Expand description
A capability granting AF_UNIX socket access on a filesystem path.
Only pathname sockets (filesystem-backed) are grantable through this
type. Abstract-namespace sockets (sun_path[0] == '\0') and unnamed
sockets are never covered by a grant — see issue #685 for the design
note. Those kinds are denied by the sandbox’s decide_network_notification
policy on Linux and have no analog on macOS.
Invariants:
path-canonicalize: canonicalised at construction. ForConnectBindgrants where the socket itself doesn’t yet exist, we canonicalise the parent directory and re-append the final component (bind creates the socket file).lib-policy-free: this is a pure data type. Policy coupling (e.g. auto-granting an impliedFsCapability) lives innono-cli.
Fields§
§original: PathBufOriginal path as specified by the caller, pre-canonicalisation.
Retained for diagnostic output and for macOS dual-path emission
(/tmp/foo.sock vs /private/tmp/foo.sock).
resolved: PathBufCanonical absolute path.
scope: SocketScopePath matching scope for this grant.
mode: UnixSocketModeWhich socket operations are permitted.
source: CapabilitySourceWhere this capability originated.
Implementations§
Source§impl UnixSocketCapability
impl UnixSocketCapability
Sourcepub fn new_file(path: impl AsRef<Path>, mode: UnixSocketMode) -> Result<Self>
pub fn new_file(path: impl AsRef<Path>, mode: UnixSocketMode) -> Result<Self>
Grant for a single socket file.
If mode == Connect, the path must already exist and must not be
a directory.
If mode == ConnectBind, the path may not yet exist (bind creates
it). In that case the parent directory must exist; canonicalisation
resolves the parent and re-appends the final path component.
Sourcepub fn new_dir(path: impl AsRef<Path>, mode: UnixSocketMode) -> Result<Self>
pub fn new_dir(path: impl AsRef<Path>, mode: UnixSocketMode) -> Result<Self>
Grant for any pathname socket directly within a directory.
Non-recursive: a socket one level deeper (e.g. <dir>/subdir/foo.sock)
is not covered. The directory itself must already exist.
Rejects the filesystem root (/) as defence-in-depth against
accidental grants that would cover sockets anywhere at top level
(cf. [validate_platform_rule]’s rejection of root-level subpath
grants for filesystem rules). Use explicit subdirectory paths.
Sourcepub fn new_dir_subtree(
path: impl AsRef<Path>,
mode: UnixSocketMode,
) -> Result<Self>
pub fn new_dir_subtree( path: impl AsRef<Path>, mode: UnixSocketMode, ) -> Result<Self>
Grant for any pathname socket within a directory subtree.
Recursive: sockets in nested subdirectories are covered. The directory itself must already exist.
Sourcepub fn covers(&self, sockaddr_path: &Path) -> bool
pub fn covers(&self, sockaddr_path: &Path) -> bool
True if sockaddr_path is covered by this grant.
- File grants:
sockaddr_path == resolvedexactly. - Direct-child directory grants:
sockaddr_path’s parent equalsresolved, component-wise (non-recursive). - Subtree directory grants:
sockaddr_pathstarts withresolved, component-wise.
Uses Path component semantics; never string prefix
(path-component-compare invariant).
Sourcepub fn is_directory(&self) -> bool
pub fn is_directory(&self) -> bool
Whether this grant is directory-backed.
Trait Implementations§
Source§impl Clone for UnixSocketCapability
impl Clone for UnixSocketCapability
Source§fn clone(&self) -> UnixSocketCapability
fn clone(&self) -> UnixSocketCapability
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for UnixSocketCapability
impl Debug for UnixSocketCapability
Source§impl<'de> Deserialize<'de> for UnixSocketCapability
impl<'de> Deserialize<'de> for UnixSocketCapability
Source§fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>where
D: Deserializer<'de>,
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>where
D: Deserializer<'de>,
Source§impl Display for UnixSocketCapability
impl Display for UnixSocketCapability
Auto Trait Implementations§
impl Freeze for UnixSocketCapability
impl RefUnwindSafe for UnixSocketCapability
impl Send for UnixSocketCapability
impl Sync for UnixSocketCapability
impl Unpin for UnixSocketCapability
impl UnsafeUnpin for UnixSocketCapability
impl UnwindSafe for UnixSocketCapability
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> Pointable for T
impl<T> Pointable for T
Source§impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> PolicyExt for Twhere
T: ?Sized,
Source§impl<T> ToStringFallible for Twhere
T: Display,
impl<T> ToStringFallible for Twhere
T: Display,
Source§fn try_to_string(&self) -> Result<String, TryReserveError>
fn try_to_string(&self) -> Result<String, TryReserveError>
ToString::to_string, but without panic on OOM.