diff options
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(), }) } |
