From d9f73aae6bd814c52b4c0babb8dae977eab4a985 Mon Sep 17 00:00:00 2001 From: Joel Rosdahl Date: Sat, 19 Feb 2022 17:02:23 +0100 Subject: [PATCH] fix: Respect umask when making hard linked files read only Fixes #1007. --- src/Util.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/Util.cpp b/src/Util.cpp index f9636dbc5..a3de8dcde 100644 --- a/src/Util.cpp +++ b/src/Util.cpp @@ -311,9 +311,11 @@ clone_hard_link_or_copy_file(const Context& ctx, LOG("Hard linking {} to {}", source, dest); try { Util::hard_link(source, dest); - if (chmod(dest.c_str(), 0444) != 0) { +#ifndef _WIN32 + if (chmod(dest.c_str(), 0444 & ~Util::get_umask()) != 0) { LOG("Failed to chmod: {}", strerror(errno)); } +#endif return; } catch (const core::Error& e) { LOG_RAW(e.what()); -- 2.47.2