Skip to main content

RulesetCreated

Struct RulesetCreated 

Source
pub struct RulesetCreated { /* private fields */ }
Expand description

Ruleset created with Ruleset::create().

Implementations§

Source§

impl RulesetCreated

Source

pub fn restrict_self(self) -> Result<RestrictionStatus, RulesetError>

Attempts to restrict the calling thread with the ruleset according to the best-effort configuration (see RulesetCreated::set_compatibility() and CompatLevel::BestEffort). Call prctl(2) with the PR_SET_NO_NEW_PRIVS according to the ruleset configuration.

On error, returns a wrapped RestrictSelfError.

Source

pub fn try_clone(&self) -> Result<Self>

Creates a new RulesetCreated instance by duplicating the underlying file descriptor. Rule modification will affect both RulesetCreated instances simultaneously.

On error, returns std::io::Error.

Trait Implementations§

Source§

impl AsMut<RulesetCreated> for RulesetCreated

Source§

fn as_mut(&mut self) -> &mut RulesetCreated

Converts this type into a mutable reference of the (usually inferred) input type.
Source§

impl Compatible for &mut RulesetCreated

Source§

fn set_compatibility(self, level: CompatLevel) -> Self

To enable a best-effort security approach, Landlock features that are not supported by the running system are silently ignored by default, which is a sane choice for most use cases. However, on some rare circumstances, developers may want to have some guarantees that their applications will not run if a certain level of sandboxing is not possible. If we really want to error out when not all our requested requirements are met, then we can configure it with set_compatibility(). Read more
Source§

fn set_best_effort(self, best_effort: bool) -> Self
where Self: Sized,

👎Deprecated: Use set_compatibility() instead
Source§

impl Compatible for RulesetCreated

Source§

fn set_compatibility(self, level: CompatLevel) -> Self

To enable a best-effort security approach, Landlock features that are not supported by the running system are silently ignored by default, which is a sane choice for most use cases. However, on some rare circumstances, developers may want to have some guarantees that their applications will not run if a certain level of sandboxing is not possible. If we really want to error out when not all our requested requirements are met, then we can configure it with set_compatibility(). Read more
Source§

fn set_best_effort(self, best_effort: bool) -> Self
where Self: Sized,

👎Deprecated: Use set_compatibility() instead
Source§

impl Debug for RulesetCreated

Source§

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

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

impl From<RulesetCreated> for Option<OwnedFd>

Source§

fn from(ruleset: RulesetCreated) -> Self

Converts to this type from the input type.
Source§

impl RestrictSelfAttr for &mut RulesetCreated

Source§

fn log_subdomains(self, set: bool) -> Result<Self, RulesetError>

Controls logging of denied accesses from nested Landlock domains. Logging is enabled by default. See the kernel documentation. Read more
Source§

impl RestrictSelfAttr for RulesetCreated

Source§

fn log_subdomains(self, set: bool) -> Result<Self, RulesetError>

Controls logging of denied accesses from nested Landlock domains. Logging is enabled by default. See the kernel documentation. Read more
Source§

impl RulesetCreatedAttr for &mut RulesetCreated

Source§

fn add_rule<T, U>(self, rule: T) -> Result<Self, RulesetError>
where T: Rule<U>, U: HandledAccess + PrivateHandledAccess,

Attempts to add a new rule to the ruleset. Read more
Source§

fn add_rules<I, T, U, E>(self, rules: I) -> Result<Self, E>
where I: IntoIterator<Item = Result<T, E>>, T: Rule<U>, U: HandledAccess + PrivateHandledAccess, E: From<RulesetError>,

Attempts to add a set of new rules to the ruleset. Read more
Source§

fn no_new_privs(self, yes: bool) -> Self

Configures the ruleset to call prctl(2) with the PR_SET_NO_NEW_PRIVS command in restrict_self(). Read more
Source§

fn set_no_new_privs(self, yes: bool) -> Self

👎Deprecated: Use no_new_privs() instead.
Alias for no_new_privs().
Source§

fn log_same_exec(self, set: bool) -> Result<Self, RulesetError>

Controls logging of denied accesses for the creating thread and its children running the same executable (before execve(2)). Logging is enabled by default. See kernel documentation. Read more
Source§

fn log_new_exec(self, set: bool) -> Result<Self, RulesetError>

Controls logging of denied accesses after an execve(2) call. Logging is disabled by default. See kernel documentation. Read more
Source§

impl RulesetCreatedAttr for RulesetCreated

Source§

fn add_rule<T, U>(self, rule: T) -> Result<Self, RulesetError>
where T: Rule<U>, U: HandledAccess + PrivateHandledAccess,

Attempts to add a new rule to the ruleset. Read more
Source§

fn add_rules<I, T, U, E>(self, rules: I) -> Result<Self, E>
where I: IntoIterator<Item = Result<T, E>>, T: Rule<U>, U: HandledAccess + PrivateHandledAccess, E: From<RulesetError>,

Attempts to add a set of new rules to the ruleset. Read more
Source§

fn no_new_privs(self, yes: bool) -> Self

Configures the ruleset to call prctl(2) with the PR_SET_NO_NEW_PRIVS command in restrict_self(). Read more
Source§

fn set_no_new_privs(self, yes: bool) -> Self

👎Deprecated: Use no_new_privs() instead.
Alias for no_new_privs().
Source§

fn log_same_exec(self, set: bool) -> Result<Self, RulesetError>

Controls logging of denied accesses for the creating thread and its children running the same executable (before execve(2)). Logging is enabled by default. See kernel documentation. Read more
Source§

fn log_new_exec(self, set: bool) -> Result<Self, RulesetError>

Controls logging of denied accesses after an execve(2) call. Logging is disabled by default. See kernel documentation. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

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

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

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

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

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

Source§

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

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

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

Source§

fn into(self) -> U

Calls U::from(self).

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

Source§

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

Source§

type Error = Infallible

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

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

Performs the conversion.
Source§

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

Source§

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

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

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

Performs the conversion.