with a go app opening a file fails with Capabilities insufficient
Describe the bug
With a go app opening a file with os.ReadFile fails with Capabilities insufficient.
The same app runs with wasmtime.
$ wasmer -vV; rustc -vV
wasmer 4.2.5 (0460050 2023-12-23)
binary: wasmer-cli
commit-hash: 04600507844bae978239531c8e6265d410aefe6d
commit-date: 2023-12-23
host: x86_64-unknown-linux-gnu
compiler: singlepass,cranelift,llvm
rustc 1.75.0 (82e1608df 2023-12-21)
binary: rustc
commit-hash: 82e1608dfa6e0b5569232559e3d385fea5a93112
commit-date: 2023-12-21
host: x86_64-unknown-linux-gnu
release: 1.75.0
LLVM version: 17.0.6
Steps to reproduce
- Clone the repository at https://github.com/rgl/go-diskfs-create-fat32-img
- Compile with (see full details at https://github.com/rgl/go-diskfs-create-fat32-img?tab=readme-ov-file#usage-webassemblywasmer):
GOOS=wasip1 GOARCH=wasm go build -o go-diskfs-create-fat32-img.wasm
dd if=/dev/urandom of=Setup.bin bs=123456 count=1 && rm -f Setup.bin.img
wasmer run --mapdir .::/ go-diskfs-create-fat32-img.wasm
- See error:
2024/01/03 07:19:31 open Setup.bin: Capabilities insufficient
panic: open Setup.bin: Capabilities insufficient
goroutine 1 [running]:
log.Panic({0x1461f00, 0x1, 0x1})
/opt/go/src/log/log.go:432 +0x5
main.main()
/home/vagrant/Projects/go-diskfs-create-fat32-img/main.go:17 +0x6
Expected behavior
Expected it to work.
Actual behavior
Crashes with:
2024/01/03 07:19:31 open Setup.bin: Capabilities insufficient
panic: open Setup.bin: Capabilities insufficient
goroutine 1 [running]:
log.Panic({0x1461f00, 0x1, 0x1})
/opt/go/src/log/log.go:432 +0x5
main.main()
/home/vagrant/Projects/go-diskfs-create-fat32-img/main.go:17 +0x6
Additional context
This seems related with https://github.com/wasmerio/wasmer/issues/4259, but this issues reproduces the problem with a go application.
I think you mapped on the wrong direction, you probably want: wasmer run --mapdir /::. go-diskfs-create-fat32-img.wasm.
Can you let us know if this fixed your issue?
@syrusakbary oh indeed, the mapping was swapped. thank you for spotting it! the way wasmer does this is different than docker and wastime, so I was completely oblivious about the error :-(
but still, it errors with the same Capabilities insufficient error :-(