summaryrefslogtreecommitdiffstats
path: root/Source
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:09 (GMT)
commitae7f8ee0fb39be47fcd310ab1750c5c6a945c4ee (patch)
tree4ab5b8f6c71625da7b3267c85ab1b7a234cf80d0 /Source
parent394e1540a3aa3d0309bef87f3ec11de6d1c081e7 (diff)
parent963440ec01183824a2f3cf5d32fe11471881eadc (diff)
downloadCMake-ae7f8ee0fb39be47fcd310ab1750c5c6a945c4ee.zip
CMake-ae7f8ee0fb39be47fcd310ab1750c5c6a945c4ee.tar.gz
CMake-ae7f8ee0fb39be47fcd310ab1750c5c6a945c4ee.tar.bz2
Merge topic 'file-install-macos'
963440ec01 Merge branch 'backport-3.26-file-install-macos' 81ac174514 Merge branch 'upstream-KWSys' into file-install-macos a87ea777d4 KWSys 2023-03-08 (a3ff01ab) 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
Diffstat (limited to 'Source')
-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 6cdd5a3..3bb7869 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,