From 7358f5530be59dae9bbb7789f2ced83b9586bc26 Mon Sep 17 00:00:00 2001 From: max-amb Date: Thu, 29 Jan 2026 14:37:22 +0000 Subject: [PATCH] Fixed permissions in install for unix --- src/uu/install/src/install.rs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/uu/install/src/install.rs b/src/uu/install/src/install.rs index a3cd779312a..84eefdcc870 100644 --- a/src/uu/install/src/install.rs +++ b/src/uu/install/src/install.rs @@ -813,6 +813,7 @@ fn perform_backup(to: &Path, b: &Behavior) -> UResult> { /// Returns an empty Result or an error in case of failure. /// fn copy_file(from: &Path, to: &Path) -> UResult<()> { + use std::os::unix::fs::OpenOptionsExt; if let Ok(to_abs) = to.canonicalize() { if from.canonicalize()? == to_abs { return Err(InstallError::SameFile(from.to_path_buf(), to.to_path_buf()).into()); @@ -841,7 +842,11 @@ fn copy_file(from: &Path, to: &Path) -> UResult<()> { let mut handle = File::open(from)?; // create_new provides TOCTOU protection - let mut dest = OpenOptions::new().write(true).create_new(true).open(to)?; + let mut dest = OpenOptions::new() + .write(true) + .create_new(true) + .mode(0o600) + .open(to)?; copy_stream(&mut handle, &mut dest).map_err(|err| { InstallError::InstallFailed(from.to_path_buf(), to.to_path_buf(), err.to_string())