Kaynağa Gözat

Update check_permissions.sh

UltimateByte 10 yıl önce
ebeveyn
işleme
2e2158b47a
1 değiştirilmiş dosya ile 15 ekleme ve 1 silme
  1. 15 1
      lgsm/functions/check_permissions.sh

+ 15 - 1
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