Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 40 additions & 0 deletions src/builtins/kill.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
//! Allow `sys_kill`.

use {crate::RuleSet, syscalls::Sysno};

/// Allow the syscall `kill` to send signals to other processes.
#[derive(Clone, Copy, Debug, Default, Eq, Hash, PartialEq, PartialOrd)]
#[must_use]
pub struct Kill;

impl RuleSet for Kill {
fn simple_rules(&self) -> Vec<Sysno> {
Vec::from([Sysno::kill])
}

fn name(&self) -> &'static str {
"Kill"
}
}

#[cfg(test)]
mod tests {
use {super::Kill, crate::RuleSet as _, syscalls::Sysno};

#[test]
fn name() {
assert_eq!(Kill.name(), "Kill");
}

#[test]
fn simple_rules() {
let rules = Kill.simple_rules();
assert_eq!(rules.len(), 1);
assert!(rules.contains(&Sysno::kill));
}

#[test]
fn conditional_rules() {
assert!(Kill.conditional_rules().is_empty());
}
}
31 changes: 13 additions & 18 deletions src/builtins/mod.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,17 @@
//! Built-in [`RuleSet`](crate::RuleSet)s

pub mod basic;
pub mod danger_zone;
pub mod kill;
pub mod network;
pub mod pipes;
pub mod systemio;
pub mod time;

pub use self::{
basic::BasicCapabilities, kill::Kill, network::Networking, systemio::SystemIO, time::Time,
};

/// A struct whose purpose is to make you read the documentation for the function you're calling.
/// If you're reading this, go read the documentation for the function that is returning this
/// object.
Expand All @@ -16,23 +28,6 @@ impl<T> YesReally<T> {

/// Make a [`YesReally`].
pub fn new(inner: T) -> YesReally<T> {
YesReally {
inner,
}
YesReally { inner }
}
}

pub mod basic;
pub use basic::BasicCapabilities;

pub mod systemio;
pub use systemio::SystemIO;

pub mod network;
pub use network::Networking;

pub mod time;
pub use time::Time;

pub mod danger_zone;
pub mod pipes;