wasictxbuilder: assert that stdio is provided

This commit is contained in:
Pat Hickey
2021-01-29 15:48:55 -08:00
parent 5ee605995d
commit 897b4fb8ab

View File

@@ -64,6 +64,17 @@ pub struct WasiCtxBuilder(WasiCtx);
impl WasiCtxBuilder {
pub fn build(self) -> Result<WasiCtx, Error> {
use crate::file::TableFileExt;
let t = self.0.table();
for (fd, name) in ["stdin", "stdout", "stderr"].iter().enumerate() {
if t.get_file(fd as u32).is_err() {
return Err(anyhow::anyhow!(
"Cannot build WasiCtx: Missing required file `{}`",
name
));
}
}
drop(t);
Ok(self.0)
}