mirror of
https://github.com/RGBCube/uutils-coreutils
synced 2025-07-28 11:37:44 +00:00
shred: fails in case of permissions issue
This commit is contained in:
parent
844f077401
commit
bb5111cc71
2 changed files with 27 additions and 1 deletions
|
@ -365,6 +365,7 @@ fn get_size(size_str_opt: Option<String>) -> Option<u64> {
|
||||||
.or_else(|| {
|
.or_else(|| {
|
||||||
if let Some(size) = size_str_opt {
|
if let Some(size) = size_str_opt {
|
||||||
show_error!("invalid file size: {}", size.quote());
|
show_error!("invalid file size: {}", size.quote());
|
||||||
|
// TODO: replace with our error management
|
||||||
std::process::exit(1);
|
std::process::exit(1);
|
||||||
}
|
}
|
||||||
None
|
None
|
||||||
|
@ -578,7 +579,8 @@ fn wipe_name(orig_path: &Path, verbose: bool, remove_method: RemoveMethod) -> Op
|
||||||
new_path.quote(),
|
new_path.quote(),
|
||||||
e
|
e
|
||||||
);
|
);
|
||||||
return None;
|
// TODO: replace with our error management
|
||||||
|
std::process::exit(1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,6 +6,7 @@
|
||||||
// spell-checker:ignore wipesync
|
// spell-checker:ignore wipesync
|
||||||
|
|
||||||
use crate::common::util::TestScenario;
|
use crate::common::util::TestScenario;
|
||||||
|
use std::path::Path;
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_invalid_arg() {
|
fn test_invalid_arg() {
|
||||||
|
@ -163,3 +164,26 @@ fn test_shred_empty() {
|
||||||
|
|
||||||
assert!(!at.file_exists(file_a));
|
assert!(!at.file_exists(file_a));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
#[cfg(all(unix, feature = "chmod"))]
|
||||||
|
fn test_shred_fail_no_perm() {
|
||||||
|
let scene = TestScenario::new(util_name!());
|
||||||
|
let at = &scene.fixtures;
|
||||||
|
let dir = "dir";
|
||||||
|
|
||||||
|
let file = "test_shred_remove_a";
|
||||||
|
|
||||||
|
let binding = Path::new("dir").join(file);
|
||||||
|
let path = binding.to_str().unwrap();
|
||||||
|
at.mkdir(dir);
|
||||||
|
at.touch(path);
|
||||||
|
scene.ccmd("chmod").arg("a-w").arg(dir).succeeds();
|
||||||
|
|
||||||
|
scene
|
||||||
|
.ucmd()
|
||||||
|
.arg("-uv")
|
||||||
|
.arg(path)
|
||||||
|
.fails()
|
||||||
|
.stderr_contains("Couldn't rename to");
|
||||||
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue