From 244b3314a69189c999d60eae915c78a9a949599b Mon Sep 17 00:00:00 2001 From: "Roscoe A. Bartlett" Date: Fri, 1 May 2020 15:21:07 -0600 Subject: [PATCH] Automatic snapshot commit from tribits at 4b335ea Origin repo remote tracking branch: 'github/master' Origin repo remote repo URL: 'github = git@github.com:TriBITSPub/TriBITS.git' At commit: commit 4b335ea765597db4f0bf3e77f7e0c90891635ef4 Author: Roscoe A. Bartlett Date: Fri May 1 11:55:06 2020 -0600 Summary: Implement check for non-owning base dir (#314) --- ...t_installed_group_and_permissions.cmake.in | 34 +++++++++++++++---- 1 file changed, 27 insertions(+), 7 deletions(-) diff --git a/cmake/tribits/core/installation/set_installed_group_and_permissions.cmake.in b/cmake/tribits/core/installation/set_installed_group_and_permissions.cmake.in index 196cc0c56492..4e5444773ef1 100644 --- a/cmake/tribits/core/installation/set_installed_group_and_permissions.cmake.in +++ b/cmake/tribits/core/installation/set_installed_group_and_permissions.cmake.in @@ -11,7 +11,9 @@ SET(projectSubdirPathsArray "@PROJECT_SUBDIR_PATHS_ARRAY@") SET(PROJECT_MAKE_INSTALL_GROUP "@PROJECT_MAKE_INSTALL_GROUP@") SET(PROJECT_MAKE_INSTALL_PERMS_CHANGE "@PROJECT_MAKE_INSTALL_PERMS_CHANGE@") +# # Helper functions +# SET(CHMOD_CHGRP_IDX 0) @@ -26,14 +28,26 @@ ENDFUNCTION() FUNCTION(SET_DIR_OWNER_AND_PERMS dirPath recurseFlag) - IF (NOT "${PROJECT_MAKE_INSTALL_GROUP}" STREQUAL "") - ECHO_AND_RUN_CMND( - chgrp ${PROJECT_MAKE_INSTALL_GROUP} ${recurseFlag} "${dirPath}") - ENDIF() + EXECUTE_PROCESS(COMMAND stat -c %U "${dirPath}" + OUTPUT_STRIP_TRAILING_WHITESPACE + OUTPUT_VARIABLE dirOwner) + + IF (NOT "${dirOwner}" STREQUAL "${CURRENT_USER_RUNNING_INSTALL}") + + MESSAGE(STATUS "${CHMOD_CHGRP_IDX}: NOTE: Not calling chgrp and chmod on ${dirPath} since owner '${dirOwner}' != current owner '${CURRENT_USER_RUNNING_INSTALL}'!") + + ELSE() + + IF (NOT "${PROJECT_MAKE_INSTALL_GROUP}" STREQUAL "") + ECHO_AND_RUN_CMND( + chgrp ${PROJECT_MAKE_INSTALL_GROUP} ${recurseFlag} "${dirPath}") + ENDIF() + + IF (NOT "${PROJECT_MAKE_INSTALL_PERMS_CHANGE}" STREQUAL "") + ECHO_AND_RUN_CMND( + chmod ${PROJECT_MAKE_INSTALL_PERMS_CHANGE} ${recurseFlag} "${dirPath}") + ENDIF() - IF (NOT "${PROJECT_MAKE_INSTALL_PERMS_CHANGE}" STREQUAL "") - ECHO_AND_RUN_CMND( - chmod ${PROJECT_MAKE_INSTALL_PERMS_CHANGE} ${recurseFlag} "${dirPath}") ENDIF() MATH(EXPR CHMOD_CHGRP_IDX "${CHMOD_CHGRP_IDX}+1") @@ -41,10 +55,16 @@ FUNCTION(SET_DIR_OWNER_AND_PERMS dirPath recurseFlag) ENDFUNCTION() +# # Executable script +# IF (EXISTS "${projectInstallBaseDir}") + EXECUTE_PROCESS(COMMAND whoami + OUTPUT_STRIP_TRAILING_WHITESPACE + OUTPUT_VARIABLE CURRENT_USER_RUNNING_INSTALL) + LIST(LENGTH projectSubdirPathsArray numSubDirs) # Get projectSubdirPathsArrayLessOne and CMAKE_INSTALL_PREFIX