From: Joel Rosdahl Date: Sat, 19 Feb 2022 16:02:23 +0000 (+0100) Subject: fix: Respect umask when making hard linked files read only X-Git-Tag: v4.6~13 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=d9f73aae6bd814c52b4c0babb8dae977eab4a985;p=thirdparty%2Fccache.git fix: Respect umask when making hard linked files read only Fixes #1007. --- 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());