]> git.ipfire.org Git - thirdparty/ccache.git/commitdiff
fix: Respect umask when making hard linked files read only
authorJoel Rosdahl <joel@rosdahl.net>
Sat, 19 Feb 2022 16:02:23 +0000 (17:02 +0100)
committerJoel Rosdahl <joel@rosdahl.net>
Sat, 19 Feb 2022 20:51:27 +0000 (21:51 +0100)
Fixes #1007.

src/Util.cpp

index f9636dbc52a7738ef5a951c001e21fe4631b2d58..a3de8dcde850609d083d903871469727739f3727 100644 (file)
@@ -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());