mirror of
https://github.com/RGBCube/uutils-coreutils
synced 2025-07-28 03:27:44 +00:00
Merge pull request #5278 from sylvestre/ls-no-read
ls -l: show an error when symlink not readable
This commit is contained in:
commit
fe4def8ac0
2 changed files with 71 additions and 43 deletions
|
@ -2908,7 +2908,8 @@ fn display_file_name(
|
||||||
&& path.file_type(out).unwrap().is_symlink()
|
&& path.file_type(out).unwrap().is_symlink()
|
||||||
&& !path.must_dereference
|
&& !path.must_dereference
|
||||||
{
|
{
|
||||||
if let Ok(target) = path.p_buf.read_link() {
|
match path.p_buf.read_link() {
|
||||||
|
Ok(target) => {
|
||||||
name.push_str(" -> ");
|
name.push_str(" -> ");
|
||||||
|
|
||||||
// We might as well color the symlink output after the arrow.
|
// We might as well color the symlink output after the arrow.
|
||||||
|
@ -2959,6 +2960,14 @@ fn display_file_name(
|
||||||
name.push_str(&escape_name(target.as_os_str(), &config.quoting_style));
|
name.push_str(&escape_name(target.as_os_str(), &config.quoting_style));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Err(err) => {
|
||||||
|
show!(LsError::IOErrorContext(
|
||||||
|
err,
|
||||||
|
path.p_buf.to_path_buf(),
|
||||||
|
false
|
||||||
|
));
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Prepend the security context to the `name` and adjust `width` in order
|
// Prepend the security context to the `name` and adjust `width` in order
|
||||||
|
|
|
@ -3503,3 +3503,22 @@ fn test_invalid_utf8() {
|
||||||
at.touch(filename);
|
at.touch(filename);
|
||||||
ucmd.succeeds();
|
ucmd.succeeds();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[cfg(all(unix, feature = "chmod"))]
|
||||||
|
#[test]
|
||||||
|
fn test_ls_perm_io_errors() {
|
||||||
|
let scene = TestScenario::new(util_name!());
|
||||||
|
let at = &scene.fixtures;
|
||||||
|
at.mkdir("d");
|
||||||
|
at.symlink_file("/", "d/s");
|
||||||
|
|
||||||
|
scene.ccmd("chmod").arg("600").arg("d").succeeds();
|
||||||
|
|
||||||
|
scene
|
||||||
|
.ucmd()
|
||||||
|
.arg("-l")
|
||||||
|
.arg("d")
|
||||||
|
.fails()
|
||||||
|
.code_is(1)
|
||||||
|
.stderr_contains("Permission denied");
|
||||||
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue