CapabilitySet

Struct CapabilitySet 

Source
pub struct CapabilitySet {
    pub effective: Capabilities,
    pub permitted: Capabilities,
    pub inheritable: Capabilities,
    pub bounding: Capabilities,
    pub ambient: Capabilities,
}
Expand description

能力集合

Linux 为每个进程维护 5 个能力集:

  • effective: 当前有效的能力(用于权限检查)
  • permitted: 允许的能力上限
  • inheritable: 可以继承给子进程的能力
  • bounding: 能力边界集(限制可获得的能力)
  • ambient: 环境能力(保持跨 execve)

Fields§

§effective: Capabilities

有效能力集(当前生效的能力)

§permitted: Capabilities

允许能力集(进程可以使用的能力)

§inheritable: Capabilities

可继承能力集(execve 时可以继承的能力)

§bounding: Capabilities

边界能力集(能力的上限)

§ambient: Capabilities

环境能力集(保持跨 execve 的能力)

Implementations§

Source§

impl CapabilitySet

Source

pub const fn full() -> Self

创建拥有所有能力的集合(root 用户)

Source

pub const fn empty() -> Self

创建空能力集

Source

pub fn has(&self, cap: Capabilities) -> bool

检查是否拥有某个能力

Source

pub fn has_all(&self, caps: Capabilities) -> bool

检查是否拥有所有指定的能力

Source

pub fn add(&mut self, cap: Capabilities)

添加能力(在单 root 用户系统中无实际效果)

Source

pub fn remove(&mut self, cap: Capabilities)

移除能力(在单 root 用户系统中无实际效果)

Trait Implementations§

Source§

impl Clone for CapabilitySet

Source§

fn clone(&self) -> CapabilitySet

Returns a duplicate of the value. Read more
1.0.0§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for CapabilitySet

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Copy for CapabilitySet

Auto Trait Implementations§

§

impl Freeze for CapabilitySet

§

impl RefUnwindSafe for CapabilitySet

§

impl Send for CapabilitySet

§

impl Sync for CapabilitySet

§

impl Unpin for CapabilitySet

§

impl UnwindSafe for CapabilitySet

Blanket Implementations§

§

impl<T> Any for T
where T: 'static + ?Sized,

§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
§

impl<T> Borrow<T> for T
where T: ?Sized,

§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
§

impl<T> BorrowMut<T> for T
where T: ?Sized,

§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
§

impl<T> CloneToUninit for T
where T: Clone,

§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
§

impl<T> From<T> for T

§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T, U> Into<U> for T
where U: From<T>,

§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of [From]<T> for U chooses to do.

§

impl<T> ToOwned for T
where T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.