From 2e2158b47a27daac3ceab5ba6fd170f2eede1581 Mon Sep 17 00:00:00 2001 From: UltimateByte Date: Tue, 15 Mar 2016 08:40:43 +0100 Subject: [PATCH] Update check_permissions.sh --- lgsm/functions/check_permissions.sh | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/lgsm/functions/check_permissions.sh b/lgsm/functions/check_permissions.sh index 09eae2f67..f9ba9d7ba 100644 --- a/lgsm/functions/check_permissions.sh +++ b/lgsm/functions/check_permissions.sh @@ -15,12 +15,25 @@ permissionerror="0" fn_check_ownership(){ if [ "${currentuser}" != "$(stat -c %U "${scriptfullpath}")" ] && [ "${currentuser}" != "$(stat -c %G "${scriptfullpath}")" ]; then permissionerror="1" - fn_scriptlog "Attempted to run as ${currentuser}" fn_print_fail_nl "Permission denied" echo " * To check allowed user and group run ls -l ${selfname}" fi } +fn_check_permissions(){ +if [ -n "${functionsdir}" ]; then + for f in $(find "${functionsdir}" -name "*.sh"); do perm="$(stat -c %a "$f")"; + find "${functionsdir}" -name "*.sh" | while read filename; do perm="$(stat -c %a "${filename}")"; shortperm="$(echo ${perms:0:1})"; + if [ "${shortperm}" != "7" ]; then + permissionerror="1" + echo "Found permission error on $filename" + fn_print_warn_n1 "Warning, permission issues found in ${functionsdir}" + echo " * Easy fix : chmod -R 755 ${functionsdir}" + fi + done +fi +} + fn_check_permissions_summary(){ if [ "${permissionerror}" == "1" ]; then exit 1 @@ -28,4 +41,5 @@ fi } fn_check_ownership +fn_check_permissions fn_check_permissions_summary