summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2023-03-08 13:51:52 (GMT)
committerKitware Robot <kwrobot@kitware.com>2023-03-08 13:52:08 (GMT)
commitd7481673d28e4d20389fababac5a6efbb74ade1a (patch)
treea51b1851ea52a33e2613687c1f15713d285700d7
parent5f4dad37f03b36131e41306773a665486797733d (diff)
parenta6f5bdd650fc85db0a16e9b9454c5be23fae2863 (diff)
downloadCMake-d7481673d28e4d20389fababac5a6efbb74ade1a.zip
CMake-d7481673d28e4d20389fababac5a6efbb74ade1a.tar.gz
CMake-d7481673d28e4d20389fababac5a6efbb74ade1a.tar.bz2
Merge topic 'file-install-macos' into release-3.26
a6f5bdd650 Merge branch 'backport-3.24-file-install-macos' 35f2b1bf5b file(INSTALL): Fix file ownership regression when running as root on macOS a5d6548587 file(INSTALL): Fix file ownership regression when running as root on macOS Acked-by: Kitware Robot <kwrobot@kitware.com> 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 a3ab51a..573cc6a 100644
--- a/Source/kwsys/SystemTools.cxx
+++ b/Source/kwsys/SystemTools.cxx
@@ -2528,6 +2528,12 @@ SystemTools::CopyStatus SystemTools::CloneFileContent(
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 CopyStatus{ Status::POSIX(ENOSYS), CopyStatus::NoPath };
+ }
+
// 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,