Skip to content

rm: check directory access on wasi - #16095

Open
eduardomourar wants to merge 1 commit into
uutils:mainfrom
eduardomourar:feat/wasi-rm
Open

eduardomourar wants to merge 1 commit into
uutils:mainfrom
eduardomourar:feat/wasi-rm

Conversation

@eduardomourar

@eduardomourar eduardomourar commented Nov 1, 2026 •

Copy link
Copy Markdown
Contributor

WASI has no permission bits, so rm's readability and writability checks need a different implementation, and a few syscalls behave differently than on Unix: path_remove_directory rejects a trailing slash, and the sandbox's preopened directory can resolve to the same (dev, ino) as root.

Add a WASI is_readable that probes with read_dir instead of PermissionsExt, and a WASI handle_writable_directory that uses it. Trim trailing slash bytes before remove_dir on WASI. Move the "." / ".." check before the root check so it also runs for sandbox paths that would otherwise look like root, or fail to stat at all.

Enable test_rm in the WASI test runner, and mark the tests that still can't run under WASI with wasi_ignore.

@eduardomourar
eduardomourar force-pushed the feat/wasi-rm branch 4 times, most recently from 8e28c26 to 3515113 Compare November 5, 2026 14:38
@eduardomourar
eduardomourar force-pushed the feat/wasi-rm branch 3 times, most recently from 231b9f6 to c0f4883 Compare November 7, 2026 23:17
@github-actions

github-actions Bot commented Nov 7, 2026 •

Copy link
Copy Markdown

GNU testsuite comparison:

Skip an intermittent issue tests/misc/usage_vs_getopt (fails in this run but passes in the 'main' branch)

@github-actions

github-actions Bot commented Nov 8, 2026 •

Copy link
Copy Markdown

Binary size comparison:

Individual binary size comparison VS main (threshold: >=5% AND >=4 KB).

Total size of compared binaries: 155.48 MB (+100 KB, +0.06%)

Significant per-binary changes:
  env     1.20 MB ->    1.28 MB  (+80 KB, +6.51%)

Comment thread src/uu/rm/src/rm.rs Resolved
Comment thread src/uu/rm/src/rm.rs Resolved
Comment thread src/uu/rm/src/rm.rs Resolved
Comment thread src/uu/rm/src/rm.rs Resolved
@sylvestre

Copy link
Copy Markdown
Contributor

thanks for working on this!
The WASI remove_dir_path can't land as is: non-UTF-8 paths become "" there (inline comment). Also, the ./.. check now runs before stat for every operand, so this needs a test.

@eduardomourar
eduardomourar force-pushed the feat/wasi-rm branch 2 times, most recently from 37a1a14 to f58b7a9 Compare November 16, 2026 00:21
@eduardomourar

Copy link
Copy Markdown
Contributor Author

@sylvestre, I have simplified WASI remove_dir_path by using from_encoded_bytes_unchecked and I have confirmed that it works for both wasip1 and p2. Now regarding the test, it was already available at test_current_or_parent_dir_missing_parent.

Comment thread src/uu/rm/src/rm.rs Resolved
Comment thread src/uu/rm/src/rm.rs Resolved
Comment thread src/uu/rm/src/rm.rs Resolved

This branch has not been deployed

No deployments
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