pub struct Capabilities { /* private fields */ }Expand description
The capabilities a spec grants a job.
v1 has exactly one kind, filesystem reads under named roots. An empty set grants nothing — deny-by-default is the whole posture, so “no capabilities declared” must never read as “unrestricted”.
Implementations§
Source§impl Capabilities
impl Capabilities
Sourcepub fn allows_read(&self, path: &Path) -> bool
pub fn allows_read(&self, path: &Path) -> bool
Whether path may be read.
Both sides are canonicalized before comparison, and that is the entire
substance of this function. The tempting implementation —
path.starts_with(root) on the raw strings — admits two escapes:
- Traversal.
/granted/inner/../../secrethas/granted/inneras a string prefix while naming a file outside it. - Symlinks. A path genuinely under the granted root can name a file anywhere on the system.
canonicalize resolves .. and follows symlinks, so the comparison is
between the real locations rather than the spellings. Comparing with
Path::starts_with rather than string prefixes additionally means
/data-secret is not treated as nested inside /data.
A path that cannot be canonicalized — because it does not exist — is denied. That is deliberate on two counts: a nonexistent path cannot be proven inside the grant, and refusing it here means the decision cannot be made against a file that only appears afterwards.
Note the residual limitation: this resolves the path once, and the caller
opens it separately. A sufficiently determined attacker who can swap a
symlink between those two steps still has a window. Closing it properly
needs the caller to pass an already-open descriptor; see the transport
discussion in the cuttlefishd crate docs.
Sourcepub fn read_roots(&self) -> &[PathBuf]
pub fn read_roots(&self) -> &[PathBuf]
The granted read roots, as configured.
Trait Implementations§
Source§impl Clone for Capabilities
impl Clone for Capabilities
Source§fn clone(&self) -> Capabilities
fn clone(&self) -> Capabilities
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 Capabilities
impl Debug for Capabilities
Source§impl Default for Capabilities
impl Default for Capabilities
Source§fn default() -> Capabilities
fn default() -> Capabilities
Auto Trait Implementations§
impl Freeze for Capabilities
impl RefUnwindSafe for Capabilities
impl Send for Capabilities
impl Sync for Capabilities
impl Unpin for Capabilities
impl UnsafeUnpin for Capabilities
impl UnwindSafe for Capabilities
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
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> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more