Skip to content

Commit

Permalink
feat: allow unlink and unlinkat for SystemIO
Browse files Browse the repository at this point in the history
Fixes #17
  • Loading branch information
gotlougit authored and boustrophedon committed Sep 1, 2023
1 parent 8709822 commit c6bd29e
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions src/builtins/systemio.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ const IO_METADATA_SYSCALLS: &[Sysno] = &[Sysno::stat, Sysno::fstat, Sysno::newfs
Sysno::getdents, Sysno::getdents64,
Sysno::getcwd];
const IO_CLOSE_SYSCALLS: &[Sysno] = &[Sysno::close, Sysno::close_range];
const IO_UNLINK_SYSCALLS: &[Sysno] = &[Sysno::unlink, Sysno::unlinkat];

/// A [`RuleSet`] representing syscalls that perform IO - open/close/read/write/seek/stat.
///
Expand Down Expand Up @@ -50,6 +51,7 @@ impl SystemIO {
.allow_write()
.allow_open().yes_really()
.allow_metadata()
.allow_unlink()
.allow_close()
}

Expand All @@ -71,6 +73,14 @@ impl SystemIO {
self
}

/// Allow `unlink` syscalls.
#[must_use]
pub fn allow_unlink(mut self) -> SystemIO {
self.allowed.extend(IO_UNLINK_SYSCALLS);

self
}

/// Allow `open` syscalls.
///
/// # Security
Expand Down

0 comments on commit c6bd29e

Please sign in to comment.