Without a preserve flag, cp -r gave every directory it created the
source's mode unmasked, so a 777 source directory became 777 regardless
of the umask, while regular files in the same copy were masked correctly.
The final permission pass defaulted a freshly-created directory to
preserving the source mode. Apply the umask in that defaulted case, as
GNU does, while a real preserve (-p/-a) and --no-preserve=mode are
unchanged.
Fixes#14549
Signed-off-by: nagendramohan <nagendramohan1990@gmail.com>
The baud rate is printed by one of three cfg-gated branches. The first
one is for "BSDs and Linux (not ppc/big-endian ppc64)", but its PowerPC
exclusion was a second #[cfg] stacked on top of
any(target_os = "linux", bsd), so it applied to the BSDs as well. The
second branch is Linux-only and the third covers everything that is
neither Linux nor a BSD. On FreeBSD/powerpc64 (big-endian) and
FreeBSD/powerpc none of the three was compiled in, and stty silently
left "speed N baud;" out of its output.
The PowerPC special case is only needed on Linux, where those targets
get a BaudRate enum instead of a number. On the BSDs the baud rate is a
plain u32 on every architecture, which string_to_baud() already relies
on with a bare #[cfg(bsd)]. Restrict the architecture exclusion to
Linux so that the BSDs always take the u32 path.
Fixes test_stty::test_basic and test_stty::test_stty_uses_stdin on
FreeBSD/powerpc64.
translate! hands Fluent a number whenever the argument parses as one,
so the error for -d 1e9 showed '1000000000', -d -0 showed '0', and
-d 9. showed '9'. Use translate_text! for the invalid-date and
missing-plus messages, which echo what the user typed.
Fixes#14669. Fixes#14670.
`from_obsolete_args` built `Signum::Positive(args.num)` unconditionally, while
`parse_num` — behind `-n +N` / `-c +N` — maps zero to `PlusZero`. So `+0`,
`+00`, `+0c` and `+0l` produced `Positive(0)`, which misses `unbounded_tail`'s
`PlusZero | Positive(1)` arms and underflows at `*count - 1`. Release wrapped
to `u64::MAX` and printed nothing, exiting 0 where GNU prints the whole input;
overflow-checks aborted. `bounded_tail` guards with `count > &1`, so only stdin
or a file at or below the block size is affected.
Obsolete `-0`/`-0c` now give `MinusZero` like `-n 0`, taking the existing
`-[nc]0` early exit: `tail -0 <missing>` exits 0 silently instead of 1,
matching GNU.
Fixes#14660
The `xattr` crate enables a default feature for unsupported Unix platforms. That is, it builds on all Unix platforms but always fails at runtime on unsupported Unix platforms.
Disable the default features so `xattr` does not build on unsupported platforms.
install -D copies through DirFd::open_file_at(), which passed
O_CREAT|O_WRONLY|O_TRUNC with mode 0o666, while the path-based
copy_file() it is documented to mirror uses create_new(true).mode(0o600).
#10647 made sort's spill directory 0700 and its chunks 0600, but
replace_output_file_in_input_files() still used fs::copy() for the case
where the output file is also one of the inputs. fs::copy() applies the
source's permission bits to the destination, so that copy -- a full
copy of the output -- was put back to the source's mode (0644 in the
common case) right after next_file() had created it 0600.
Write through the descriptor next_file() already returned instead. That
also drops the pointless second open of a file we just created.
Also fix uucore's safe-copy feature, which did not enable rustix/fs and
so failed to build when selected on its own.
Taken from #14536.
* generalize the mv code for ln, cp
replace links atomically instead of unlinking first
Forced replacement was unlink(dst) then create. The gap lets another user
claim dst in a directory they can write to -- including a name the sticky
bit forbids them to remove -- so a privileged ln hands them a trusted name.
* ln: don't leave the temp behind when the rename is a no-op
Renaming the temp onto a destination that is already a link to the same
inode does nothing and returns success, so the temp name survived:
`ln -f a b` with b already hard-linked to a left a stray Cu* file.
Unlink the temp after the rename either way; on the normal path it is
already gone.