diff --git a/src/lib.rs b/src/lib.rs index cc558ba..40cdfea 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -220,6 +220,20 @@ impl RuleSet for &T { } } +impl RuleSet for syscalls::Sysno { + fn simple_rules(&self) -> Vec { + Vec::from([*self]) + } + + fn conditional_rules(&self) -> HashMap> { + HashMap::new() + } + + fn name(&self) -> &'static str { + self.name() + } +} + #[must_use] /// A struct representing a set of rules to be loaded into a seccomp filter and applied to the /// current thread, or all threads in the current process. diff --git a/tests/sysno.rs b/tests/sysno.rs new file mode 100644 index 0000000..78d6a86 --- /dev/null +++ b/tests/sysno.rs @@ -0,0 +1,21 @@ +use extrasafe::SafetyContext; +use syscalls::Sysno; + +#[test] +#[should_panic] +fn hello_void() { + SafetyContext::new().apply_to_current_thread().unwrap(); + + println!("Hello, World!"); +} + +#[test] +fn hello_world() { + SafetyContext::new() + .enable(Sysno::write) + .unwrap() + .apply_to_current_thread() + .unwrap(); + + println!("Hello, World!"); +}