Skip to content

wasi: follow absolute link targets inside the directory - #313

Merged
andreaTP merged 3 commits into
bytecodealliance:mainfrom
JosepMariaBlasco:wasi-absolute-link-targets
Nov 18, 2026
Merged

andreaTP merged 3 commits into
bytecodealliance:mainfrom
JosepMariaBlasco:wasi-absolute-link-targets

Conversation

@JosepMariaBlasco

@JosepMariaBlasco JosepMariaBlasco commented Nov 17, 2026 •

Copy link
Copy Markdown
Contributor

Since #304 a symbolic link whose target is absolute gives EPERM, also when the target is inside the directory the path starts from. With the host's root preopened every absolute target is inside, and links such as /usr/bin/java -> /etc/alternatives/java could no longer be opened.

An absolute target is a host path. It is followed only when it lies below the directory the walk started from, compared both as configured (made absolute) and as its real path; the walk then starts again in that directory with no parents, so ".." still cannot leave it. Every other absolute target stays EPERM, and path_symlink still refuses to create one.

Since bytecodealliance#304 a symbolic link whose target is absolute gives EPERM, also when
the target is inside the directory the path starts from. With the host's
root preopened every absolute target is inside, and links such as
/usr/bin/java -> /etc/alternatives/java could no longer be opened.

An absolute target is a host path. It is followed only when it lies below
the directory the walk started from, compared both as configured (made
absolute) and as its real path; the walk then starts again in that
directory with no parents, so ".." still cannot leave it. Every other
absolute target stays EPERM, and path_symlink still refuses to create one.

Assisted-by: Claude:claude-fable-5-2
Path.relativize normalizes ".." lexically on the default file system, so
"missing/.." resolved instead of giving ENOENT, and "link/.." ignored where
the link points. Drop the directory's names instead, so the walk sees every
name, as it does on ZeroFs.

@andreaTP andreaTP left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @JosepMariaBlasco great job!
Added a small improvement on top and LGTM

Windows removes ".." from an absolute target when it creates the link, so
the POSIX expectations only apply where the target is kept as written.
@JosepMariaBlasco

Copy link
Copy Markdown
Contributor Author

Thanks, checked again with ooRexx on Linux and Windows at 5a64828, all good.

@andreaTP
andreaTP merged commit 2fc6651 into bytecodealliance:main Nov 18, 2026
25 checks passed
@andreaTP

Copy link
Copy Markdown
Contributor

Thanks again for the help here @JosepMariaBlasco 🙏

@JosepMariaBlasco

Copy link
Copy Markdown
Contributor Author

Thank you for the review and the fixes! I tried main at 2fc6651 with ooRexx: the link probe behaves as with 1.2.0, our Windows tests pass with Endive’s own WASI, and the ooRexx test suite passes on Linux. Looking forward to the next release.

@andreaTP

Copy link
Copy Markdown
Contributor

Going to release sometime soon over the next weeks, I'm trying to squeeze in a few more things.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants