summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2023-03-08 07:45:15 -0500
committerBrad King <brad.king@kitware.com>2023-03-08 07:45:15 -0500
commit24f356cd5e014bda88581759b677ecb9a039503a (patch)
tree6724d757b07c7002a936f7a87019eeb29b8fa0b6
parentb8916bca0c46ffc2dab3158ea43a90442d25e98c (diff)
parenta5d6548587f1cf3c57f639fa5671bb6c4e130211 (diff)
downloadcmake-24f356cd5e014bda88581759b677ecb9a039503a.tar.gz
Merge branch 'backport-3.24-file-install-macos' into release-3.25
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 a20901cb29..b5d45e8332 100644
--- a/Source/kwsys/SystemTools.cxx
+++ b/Source/kwsys/SystemTools.cxx
@@ -2500,6 +2500,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,