From 6cc4d706fba2577babc076ad0d2ef145c0c648d7 Mon Sep 17 00:00:00 2001 From: "Sergey A. Osokin" Date: Fri, 22 Nov 2024 22:13:18 -0500 Subject: wasm: Fix build with wasmtime 27.0.0 Wasmtime 27.0.0 adjusted the C API to start flowing through the directory and file permission bits of the underlying rust wasi_config_preopen_dir() implementation. The directory permissions control whether a directory is read-only or whether you can create/modify files within. You always need at least WASMTIME_WASI_DIR_PERMS_READ. The file permissions control whether you can read or read/write files. WASMTIME_WASI_FILE_PERMS_WRITE seems to imply WASMTIME_WASI_FILE_PERMS_READ (but we add both just to make it clear what we want) [ Permissions tweak and commit message - Andrew ] Signed-off-by: Andrew Clayton --- src/wasm/nxt_rt_wasmtime.c | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'src') diff --git a/src/wasm/nxt_rt_wasmtime.c b/src/wasm/nxt_rt_wasmtime.c index bf0b0a0f..64ef775d 100644 --- a/src/wasm/nxt_rt_wasmtime.c +++ b/src/wasm/nxt_rt_wasmtime.c @@ -281,7 +281,13 @@ nxt_wasmtime_wasi_init(const nxt_wasm_ctx_t *ctx) wasi_config_inherit_stderr(wasi_config); for (dir = ctx->dirs; dir != NULL && *dir != NULL; dir++) { +#if defined(WASMTIME_VERSION_MAJOR) && (WASMTIME_VERSION_MAJOR >= 27) + wasi_config_preopen_dir(wasi_config, *dir, *dir, + WASMTIME_WASI_DIR_PERMS_READ|WASMTIME_WASI_DIR_PERMS_WRITE, + WASMTIME_WASI_FILE_PERMS_READ|WASMTIME_WASI_FILE_PERMS_WRITE); +#else wasi_config_preopen_dir(wasi_config, *dir, *dir); +#endif } error = wasmtime_context_set_wasi(rt_ctx->ctx, wasi_config); -- cgit