[−][src]Struct rctl::Filter
A filter can match a set of Rules.
Implementations
impl Filter
[src]
pub fn new() -> Filter
[src]
Return the filter that matches all rules
Example
let filter = Filter::new(); assert_eq!(filter.to_string(), ":".to_string());
pub fn subject_type(self: Filter, subject_type: &SubjectType) -> Filter
[src]
Constrain the filter to a specific [SubjectType]
If the filter is already constrained to a subject, this is a No-Op.
Example
let filter = Filter::new() .subject_type(&SubjectType::LoginClass); assert_eq!(filter.to_string(), "loginclass:".to_string());
pub fn subject(self: Filter, subject: &Subject) -> Filter
[src]
Constrain the filter to a specific [Subject]
Resets the subject type.
Example
let filter = Filter::new() .subject(&Subject::user_name("nobody").expect("no user 'nobody'")); assert_eq!(filter.to_string(), "user:nobody".to_string());
pub fn resource(self: Filter, resource: &Resource) -> Filter
[src]
Constrain the filter to a specific [Resource]
Example
let filter = Filter::new() .resource(&Resource::MemoryLocked); assert_eq!(filter.to_string(), "::memorylocked".to_string());
pub fn action(self: Filter, action: &Action) -> Filter
[src]
Constrain the filter to a specific [Action]
Example
let filter = Filter::new() .action(&Action::Deny); assert_eq!(filter.to_string(), ":::deny".to_string());
pub fn deny(self: Filter) -> Filter
[src]
Constrain the filter to the Deny [Action]
Example
let filter = Filter::new() .deny(); assert_eq!(filter, Filter::new().action(&Action::Deny));
pub fn log(self: Filter) -> Filter
[src]
Constrain the filter to the Log [Action]
Example
let filter = Filter::new() .log(); assert_eq!(filter, Filter::new().action(&Action::Log));
pub fn devctl(self: Filter) -> Filter
[src]
Constrain the filter to the DevCtl [Action]
Example
let filter = Filter::new() .devctl(); assert_eq!(filter, Filter::new().action(&Action::DevCtl));
pub fn signal(self: Filter, signal: Signal) -> Filter
[src]
Constrain the filter to the Signal [Action]
Example
let filter = Filter::new() .signal(Signal::SIGTERM); assert_eq!(filter.to_string(), ":::sigterm".to_string());
pub fn limit(self: Filter, limit: &Limit) -> Filter
[src]
Constrain the filter to a particular [Limit]
Resets any limit_per, if the given limit has a per
set.
Examples
let filter = Filter::new() .limit(&Limit::amount(100*1024*1024)); assert_eq!(filter.to_string(), ":::=100m".to_string());
let filter = Filter::new() .limit(&Limit::amount_per(100*1024*1024, SubjectType::Process)); assert_eq!(filter.to_string(), ":::=100m/process".to_string());
pub fn to_string(&self) -> String
[src]
Return the string representation of the [Filter].
pub fn rules(&self) -> Result<RuleParsingIntoIter<String>, Error>
[src]
Return an [IntoIterator] over all Rules matching this [Filter].
Example
List all rules:
use rctl; let filter = rctl::Filter::new(); for rule in filter.rules() { println!("{:?}", rule); }
pub fn remove_rules(&self) -> Result<(), Error>
[src]
Remove all matching Rules from the resource limits database.
Examples
use rctl::{Filter, Subject}; let filter = Filter::new() .subject(&Subject::jail_name("testjail_rctl_filter_remove")) .remove_rules() .expect("Could not remove rules");
Remove all rules, clearing the resource limits database by using the
default (':'
) [Filter]:
use rctl; rctl::Filter::new().remove_rules().expect("Could not remove all rules");
Trait Implementations
impl Clone for Filter
[src]
impl Debug for Filter
[src]
impl Display for Filter
[src]
impl<'a> From<&'a Action> for Filter
[src]
impl<'a> From<&'a Limit> for Filter
[src]
impl<'a> From<&'a Rule> for Filter
[src]
impl<'a> From<&'a Subject> for Filter
[src]
impl<'a> From<&'a SubjectType> for Filter
[src]
fn from(subject_type: &'a SubjectType) -> Self
[src]
impl From<Action> for Filter
[src]
impl From<Limit> for Filter
[src]
impl From<Rule> for Filter
[src]
impl From<Subject> for Filter
[src]
impl From<SubjectType> for Filter
[src]
fn from(subject_type: SubjectType) -> Self
[src]
impl<'a> Into<String> for &'a Filter
[src]
impl PartialEq<Filter> for Filter
[src]
impl StructuralPartialEq for Filter
[src]
Auto Trait Implementations
impl RefUnwindSafe for Filter
impl Send for Filter
impl Sync for Filter
impl Unpin for Filter
impl UnwindSafe for Filter
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
fn to_owned(&self) -> T
[src]
fn clone_into(&self, target: &mut T)
[src]
impl<T> ToString for T where
T: Display + ?Sized,
[src]
T: Display + ?Sized,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
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>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,