summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2023-03-08 07:44:36 -0500
committerBrad King <brad.king@kitware.com>2023-03-08 07:44:36 -0500
commita6373caaec9c85d1ab3d070e180c8d33b91a7f76 (patch)
treee467397120494b55b5f2d444c2430feee27dd763
parentab7085db359da111a68dcddcbb1e7dbaa84d0173 (diff)
parenta5d6548587f1cf3c57f639fa5671bb6c4e130211 (diff)
downloadcmake-a6373caaec9c85d1ab3d070e180c8d33b91a7f76.tar.gz
Merge branch 'backport-3.24-file-install-macos' into release-3.24
Merge-request: !8293
-rw-r--r--Source/kwsys/SystemTools.cxx6
1 files changed, 6 insertions, 0 deletions
diff --git a/Source/kwsys/SystemTools.cxx b/Source/kwsys/SystemTools.cxx
index 5889a4b0b4..6173f235c5 100644
--- a/Source/kwsys/SystemTools.cxx
+++ b/Source/kwsys/SystemTools.cxx
@@ -2483,6 +2483,12 @@ Status SystemTools::CloneFileContent(std::string const& source,
return status;
#elif defined(__APPLE__) && \
defined(KWSYS_SYSTEMTOOLS_HAVE_MACOS_COPYFILE_CLONE)
+ // When running as root, copyfile() copies more metadata than we
+ // want, such as ownership. Pretend it is not available.
+ if (getuid() == 0) {
+ return Status::POSIX(ENOSYS);
+ }
+
// NOTE: we cannot use `clonefile` as the {a,c,m}time for the file needs to
// be updated by `copy_file_if_different` and `copy_file`.
if (copyfile(source.c_str(), destination.c_str(), nullptr,