diff options
| author | tv <tv@krebsco.de> | 2026-12-01 01:59:16 +0000 |
|---|---|---|
| committer | tv <tv@krebsco.de> | 2026-12-01 01:59:16 +0000 |
| commit | 2af90fd35ea8a0aafb9156653f5b28cbac4e1677 (patch) | |
| tree | c2eceb7e2dae9625bb4e5a994e13151e11fd44d4 /src/store.rs | |
| parent | 5804d2b952ebead3d9bc238fc8db20af6563fddc (diff) | |
By bubblewrap: everything read-only but OUT (and IN bound again after a
fresh /tmp), a new /dev and /proc, namespaces of their own (no network),
no capabilities, a new session, gone with the receptor. The setting
sandbox is bwrap (found in the receptor's PATH, as the programs'
environment is empty), or none; the module sets its bubblewrap. The
tests run their programs in it where bubblewrap can make one (not in
Nix's build sandbox), and a test checks that a program can't write
outside OUT, nor into IN, and has no network nor environment.
Diffstat (limited to 'src/store.rs')
| -rw-r--r-- | src/store.rs | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/src/store.rs b/src/store.rs index 9de62d3..c6d4d6c 100644 --- a/src/store.rs +++ b/src/store.rs @@ -35,6 +35,8 @@ pub type Kept = std::collections::BTreeMap<String, (String, Vec<u8>)>; pub struct Store { pub state: PathBuf, pub run: PathBuf, + /// bubblewrap, for running programs in a sandbox (`program::Runner`). + pub sandbox: Option<PathBuf>, } #[derive(Debug, Clone)] @@ -71,6 +73,7 @@ impl Store { Self { state: absolute(state), run: absolute(run), + sandbox: None, } } @@ -98,6 +101,20 @@ impl Store { self.run.join("tmp") } + /// How programs run: their scratch directories, and the sandbox. + pub fn runner(&self) -> crate::program::Runner { + crate::program::Runner { + scratch: self.scratch(), + sandbox: self.sandbox.clone(), + } + } + + /// The store, its programs run in a sandbox by `bwrap` (bubblewrap), or not. + pub fn with_sandbox(mut self, bwrap: Option<PathBuf>) -> Self { + self.sandbox = bwrap; + self + } + fn channel_dir(&self, channel: &str) -> PathBuf { self.state.join("channels").join(channel) } @@ -261,6 +278,7 @@ impl Store { Ok(Store { state: dir.to_owned(), run: self.run.clone(), + sandbox: self.sandbox.clone(), }) } |
