Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
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
4 changes: 2 additions & 2 deletions src/uu/install/src/install.rs
Original file line number Diff line number Diff line change
Expand Up @@ -803,7 +803,7 @@ fn standard(mut paths: Vec<OsString>, b: &Behavior) -> UResult<()> {
{
show_error!(
"{}",
translate!("install-error-failed-to-remove", "path" => target.quote(), "error" => format!("{e:?}"))
translate!("install-error-failed-to-remove", "path" => target.quote(), "error" => strip_errno(&e))
);
}

Expand Down Expand Up @@ -1033,7 +1033,7 @@ fn copy_file(from: &Path, to: &Path) -> UResult<()> {
}
_ => show_error!(
"{}",
translate!("install-error-failed-to-remove", "path" => to.quote(), "error" => format!("{e:?}"))
translate!("install-error-failed-to-remove", "path" => to.quote(), "error" => strip_errno(&e))
),
}
}
Expand Down
20 changes: 20 additions & 0 deletions tests/by-util/test_install.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2703,6 +2703,26 @@ fn test_install_non_utf8_paths() {
ucmd.arg("-D").arg(source_file).arg(&target_path).succeeds();
}

/// The error for a failed removal of the existing destination must be the
/// plain OS message, not the `Debug` form of the Rust error.
#[test]
fn test_install_failed_remove_existing_error_is_plain() {
// Root can always remove the file.
if geteuid().is_root() {
return;
}

let (at, mut ucmd) = at_and_ucmd!();
at.touch("f");
at.mkdir("r--");
at.set_mode("r--", 0o400);

ucmd.args(&["-D", "f", "r--/f"])
.fails()
.stderr_contains("Error: Permission denied")
.stderr_does_not_contain("Os {");
}

/// A failed ownership change must not leave the setuid/setgid mode applied.
#[test]
fn test_install_failed_chown_does_not_leave_setuid() {
Expand Down
Loading