Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .vscode/cspell.dictionaries/jargon.wordlist.txt
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,9 @@ nofield
dtolnay
Swatinem

preopened
dotdot

# * clippy
uninlined
nonminimal
Expand Down
14 changes: 13 additions & 1 deletion src/uu/ls/src/ls.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1265,7 +1265,19 @@ fn depth_first_list(
false,
),
PathData::new(
path_data.path().join("..").into(),
// On WASI the sandbox may block access to ".." at the
// preopened root. Fall back to "." so the entry still
// appears with valid metadata instead of an error.
{
let dotdot = path_data.path().join("..");
#[cfg(target_os = "wasi")]
let dotdot = if dotdot.metadata().is_err() {
path_data.path().into()
} else {
dotdot
};
dotdot.into()
},
None,
Some(OsStr::new("..").into()),
config,
Expand Down
16 changes: 16 additions & 0 deletions tests/by-util/test_ls.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7133,3 +7133,19 @@ fn test_ls_non_utf8_hidden() {

scene.ucmd().succeeds().stdout_does_not_contain(".hidden");
}

#[test]
#[cfg(target_os = "wasi")]
fn test_ls_a_dotdot_no_error_on_wasi() {
// On WASI the sandbox may block access to ".." at the preopened root.
// ls -a should still succeed and show ".." without an error message.
let scene = TestScenario::new(util_name!());
scene
.ucmd()
.arg("-a")
.arg("-1")
.succeeds()
.stdout_contains("..")
.stdout_contains(".")
Comment thread
cakebaker marked this conversation as resolved.
Outdated
.no_stderr();
}
Loading