feat: add inherit
All checks were successful
continuous-integration/drone/push Build is passing

Signed-off-by: kjuulh <contact@kjuulh.io>
This commit is contained in:
Kasper Juul Hermansen 2024-12-02 21:00:20 +01:00
parent 5e1b585a2d
commit 21a13f3444
Signed by: kjuulh
GPG Key ID: D85D7535F18F35FA

View File

@ -6,7 +6,7 @@ use tokio::io::AsyncWriteExt;
use tokio::sync::Mutex;
use wasmtime::component::*;
use wasmtime::{Config, Engine, Store};
use wasmtime_wasi::{WasiCtx, WasiCtxBuilder, WasiView};
use wasmtime_wasi::{DirPerms, FilePerms, WasiCtx, WasiCtxBuilder, WasiView};
wasmtime::component::bindgen!({
path: "wit/world.wit",
@ -144,7 +144,14 @@ struct ServerWasiView {
impl ServerWasiView {
fn new() -> Self {
let table = ResourceTable::new();
let ctx = WasiCtxBuilder::new().inherit_stdio().build();
let ctx = WasiCtxBuilder::new()
.inherit_stdio()
.inherit_env()
.inherit_network()
.preopened_dir("/", "/", DirPerms::all(), FilePerms::all())
.expect("to be able to open root")
.build();
Self { table, ctx }
}