Mercurial > public > mercurial-scm > hg-stable
changeset 52552:66e34bc44280
rhg: set the expected temp file permissions (0o666 minus umask)
This continues the theme of a48c688d3e80, and fixes the bug #6375,
which was causing some problems for us, where a non-group-readable
file can't be copied, which breaks some tools that copy the repo.
This affects both the `checkexec` file and the temporary file we
use for filesystem time measurement, since either of these files
remaining on disk can cause this problem, and the 0666 permissions
are just the better default here.
author | Arseniy Alekseyev <aalekseyev@janestreet.com> |
---|---|
date | Thu, 05 Dec 2024 13:17:32 +0000 |
parents | a0587c1b633a |
children | dd052842fc8e |
files | rust/hg-core/src/checkexec.rs rust/hg-core/src/utils/files.rs |
diffstat | 2 files changed, 9 insertions(+), 2 deletions(-) [+] |
line wrap: on
line diff
--- a/rust/hg-core/src/checkexec.rs Fri Dec 13 16:50:21 2024 +0000 +++ b/rust/hg-core/src/checkexec.rs Thu Dec 05 13:17:32 2024 +0000 @@ -98,7 +98,10 @@ leave_file = false; }; - let tmp_file = tempfile::NamedTempFile::new_in(checkdir)?; + let tmp_file = tempfile::Builder::new() + .permissions(std::fs::Permissions::from_mode(0o666)) + .tempfile_in(checkdir)?; + if !is_executable(tmp_file.path())? { make_executable(tmp_file.path())?; if is_executable(tmp_file.path())? {
--- a/rust/hg-core/src/utils/files.rs Fri Dec 13 16:50:21 2024 +0000 +++ b/rust/hg-core/src/utils/files.rs Thu Dec 05 13:17:32 2024 +0000 @@ -19,6 +19,7 @@ use std::ffi::{OsStr, OsString}; use std::iter::FusedIterator; use std::ops::Deref; +use std::os::unix::fs::PermissionsExt; use std::path::{Path, PathBuf}; use std::{ borrow::{Cow, ToOwned}, @@ -324,7 +325,10 @@ /// should continue the `status()` algoritm anyway and consider the current /// date/time to be unknown. pub fn filesystem_now(repo_root: &Path) -> Result<SystemTime, io::Error> { - tempfile::tempfile_in(repo_root.join(".hg"))? + tempfile::Builder::new() + .permissions(std::fs::Permissions::from_mode(0o666)) + .tempfile_in(repo_root.join(".hg"))? + .into_file() .metadata()? .modified() }