Description
Version
v19.8.1, v20.5.1
Platform
Darwin uhyo 21.6.0 Darwin Kernel Version 21.6.0: Mon Aug 22 20:19:52 PDT 2022; root:xnu-8020.140.49~2/RELEASE_ARM64_T6000 arm64
Subsystem
No response
What steps will reproduce the bug?
Reproduction repo: https://github.com/uhyo/node-wasi-symlink-bug
Some of filesystem APIs (including path_open
) cannot handle symbolic links correctly. Consider below file structure:
.
├── Cargo.toml
└── dir
└── link -> ../Cargo.toml
Create a WASM binary that tries to open ./dir/link
with path_open
. Pre-opening the current directory (.
) should be enough for the program to work, but with Node.js' WASI implementation it fails with a "Capabilities insufficient" error.
How often does it reproduce? Is there a required condition?
always (sorry, not tested on other platforms than my Mac)
What is the expected behavior? Why is that the expected behavior?
The program should be able to read the contents of dir/link
(symlinked to Cargo.toml
).
What do you see instead?
Call to path_open
fails with error code 76 (notcapable
).
Additional information
- Reproduction steps and more details are available in the reproduction repostitory.
- Looking at the implementation, the logic for following symlinks doesn't take the location of the link into consideration. Content of
./dir/link
(../Cargo.toml
) should be treated as relative to./dir
, but is actually treated as relative to the current directory.