mirror of
https://github.com/RGBCube/uutils-coreutils
synced 2025-07-28 11:37:44 +00:00
Merge pull request #5353 from tommady/fix-5327
cp: fix cp -a --no-preserve=mode doesn't keep fully the mode
This commit is contained in:
commit
6085cf12e3
2 changed files with 102 additions and 23 deletions
|
@ -2,7 +2,7 @@
|
|||
//
|
||||
// For the full copyright and license information, please view the LICENSE
|
||||
// file that was distributed with this source code.
|
||||
// spell-checker:ignore (flags) reflink (fs) tmpfs (linux) rlimit Rlim NOFILE clob btrfs ROOTDIR USERDIR procfs outfile
|
||||
// spell-checker:ignore (flags) reflink (fs) tmpfs (linux) rlimit Rlim NOFILE clob btrfs ROOTDIR USERDIR procfs outfile uufs
|
||||
|
||||
use crate::common::util::TestScenario;
|
||||
#[cfg(not(windows))]
|
||||
|
@ -1551,6 +1551,32 @@ fn test_cp_preserve_links_case_7() {
|
|||
assert!(at.plus("dest").join("g").exists());
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[cfg(unix)]
|
||||
fn test_cp_no_preserve_mode() {
|
||||
use libc::umask;
|
||||
use uucore::fs as uufs;
|
||||
let (at, mut ucmd) = at_and_ucmd!();
|
||||
|
||||
at.touch("a");
|
||||
at.set_mode("a", 0o731);
|
||||
unsafe { umask(0o077) };
|
||||
|
||||
ucmd.arg("-a")
|
||||
.arg("--no-preserve=mode")
|
||||
.arg("a")
|
||||
.arg("b")
|
||||
.succeeds();
|
||||
|
||||
assert!(at.file_exists("b"));
|
||||
|
||||
let metadata_b = std::fs::metadata(at.subdir.join("b")).unwrap();
|
||||
let permission_b = uufs::display_permissions(&metadata_b, false);
|
||||
assert_eq!(permission_b, "rw-------".to_string());
|
||||
|
||||
unsafe { umask(0o022) };
|
||||
}
|
||||
|
||||
#[test]
|
||||
// For now, disable the test on Windows. Symlinks aren't well support on Windows.
|
||||
// It works on Unix for now and it works locally when run from a powershell
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue