1
Fork 0
mirror of https://github.com/RGBCube/uutils-coreutils synced 2025-07-28 03:27:44 +00:00

chmod: show an error if a permission wasn't removed due to umask

This commit is contained in:
Michael Debertol 2021-08-17 00:20:44 +02:00
parent 15b40f6aa2
commit 945e57ea22
5 changed files with 60 additions and 24 deletions

View file

@ -201,11 +201,6 @@ fn test_chmod_ugoa() {
before: 0o100000,
after: 0o100755,
},
TestCase {
args: vec!["-w", TEST_FILE],
before: 0o100777,
after: 0o100577,
},
TestCase {
args: vec!["-x", TEST_FILE],
before: 0o100777,
@ -213,6 +208,21 @@ fn test_chmod_ugoa() {
},
];
run_tests(tests);
// check that we print an error if umask prevents us from removing a permission
let (at, mut ucmd) = at_and_ucmd!();
at.touch("file");
set_permissions(at.plus("file"), Permissions::from_mode(0o777)).unwrap();
ucmd.args(&["-w", "file"])
.fails()
.code_is(1)
// spell-checker:disable-next-line
.stderr_is("chmod: file: new permissions are r-xrwxrwx, not r-xr-xr-x");
assert_eq!(
metadata(at.plus("file")).unwrap().permissions().mode(),
0o100577
);
unsafe {
umask(last);
}