Skip to content

Commit 7cdcd89

Browse files
committed
uucore/safe_copy: use rustix Mode flags to avoid mode_t width mismatch
`Mode::from_bits_truncate(DEST_INITIAL_MODE)` failed to build on macOS because `mode_t` is `u16` there but `u32` on Linux. Compose the mode from `Mode::RUSR | Mode::WUSR` so the call is portable by construction and self-documents the intent (read+write owner = 0o600).
1 parent fdafdca commit 7cdcd89

1 file changed

Lines changed: 2 additions & 6 deletions

File tree

src/uucore/src/lib/features/safe_copy.rs

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
// For the full copyright and license information, please view the LICENSE
44
// file that was distributed with this source code.
55

6-
// spell-checker:ignore TOCTOU NOFOLLOW CLOEXEC ELOOP RDONLY WRONLY
6+
// spell-checker:ignore TOCTOU NOFOLLOW CLOEXEC ELOOP RDONLY WRONLY WUSR RUSR
77

88
//! Path-based primitives for security-sensitive file copies.
99
//!
@@ -77,11 +77,7 @@ pub fn create_dest_restrictive<P: AsRef<Path>>(path: P, nofollow: bool) -> io::R
7777
if nofollow {
7878
flags |= OFlags::NOFOLLOW;
7979
}
80-
let fd: OwnedFd = open(
81-
path.as_ref(),
82-
flags,
83-
Mode::from_bits_truncate(DEST_INITIAL_MODE),
84-
)?;
80+
let fd: OwnedFd = open(path.as_ref(), flags, Mode::RUSR.union(Mode::WUSR))?;
8581
Ok(File::from(fd))
8682
}
8783

0 commit comments

Comments
 (0)