From 2ae1c05f4780294f3acd809596da8a043f3f0547 Mon Sep 17 00:00:00 2001 From: UltimateByte Date: Wed, 24 Aug 2016 15:32:57 +0200 Subject: [PATCH] Message location & rework Added functions dir for ownership check And reworked the way checks occur. --- lgsm/functions/check_permissions.sh | 48 +++++++++++++++++++++-------- 1 file changed, 35 insertions(+), 13 deletions(-) diff --git a/lgsm/functions/check_permissions.sh b/lgsm/functions/check_permissions.sh index 64c3f535a..04cad1d8a 100644 --- a/lgsm/functions/check_permissions.sh +++ b/lgsm/functions/check_permissions.sh @@ -9,22 +9,44 @@ local commandname="CHECK" local function_selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))" fn_check_ownership(){ + if [ -f "${rootdir}/${selfname}" ]; then + if [ $(find "${rootdir}/${selfname}" -not -user $(whoami)|wc -l) -ne "0" ]; then + selfownissue=1 + fi + fi + if [ -d "${functionsdir}" ]; then + if [ $(find "${functionsdir}" -not -user $(whoami)|wc -l) -ne "0" ]; then + funcownissue=1 + fi + fi if [ -d "${filesdir}" ]; then - if [ $(find "${filesdir}" -not -user $(whoami)|wc -l) -ne "0" ]||[ $(find "${rootdir}/${selfname}" -not -user $(whoami)|wc -l) -ne "0" ]; then - fn_print_fail_nl "Ownership issues found" - fn_script_log_fatal "Ownership issues found" - fn_print_infomation_nl "The current user ($(whoami)) does not have ownership of the following files:" - fn_script_log_info "The current user ($(whoami)) does not have ownership of the following files:" - { - echo -e "User\tGroup\tFile\n" - find "${filesdir}" -not -user $(whoami) -printf "%u\t\t%g\t%p\n" - find "${rootdir}/${selfname}" -not -user $(whoami) -printf "%u\t\t%g\t%p\n" - } | column -s $'\t' -t | tee -a "${scriptlog}" - core_exit.sh - fn_print_infomation_nl "For more information, please see https://github.com/GameServerManagers/LinuxGSM/wiki/FAQ#-fail--starting-game-server-permissions-issues-found" - fn_script_log "For more information, please see https://github.com/GameServerManagers/LinuxGSM/wiki/FAQ#-fail--starting-game-server-permissions-issues-found" + if [ $(find "${filesdir}" -not -user $(whoami)|wc -l) -ne "0" ]; then + filesownissue=1 fi fi + if [ "${selfownissue}" == "1" ]||[ "${funcownissue}" == "1" ]||[ "${filesownissue}" == "1" ]; then + fn_print_fail_nl "Ownership issues found" + fn_script_log_fatal "Ownership issues found" + fn_print_infomation_nl "The current user ($(whoami)) does not have ownership of the following files:" + fn_script_log_info "The current user ($(whoami)) does not have ownership of the following files:" + { + echo -e "User\tGroup\tFile\n" + if [ "${selfownissue}" == "1" ]; then + find "${rootdir}/${selfname}" -not -user $(whoami) -printf "%u\t\t%g\t%p\n" + fi + if [ "${funcownissue}" == "1" ]; then + find "${functionsdir}" -not -user $(whoami) -printf "%u\t\t%g\t%p\n" + fi + if [ "${funcownissue}" == "1" ]; then + find "${filesdir}" -not -user $(whoami) -printf "%u\t\t%g\t%p\n" + fi + + } | column -s $'\t' -t | tee -a "${scriptlog}" + echo "" + fn_print_infomation_nl "For more information, please see https://github.com/GameServerManagers/LinuxGSM/wiki/FAQ#-fail--starting-game-server-permissions-issues-found" + fn_script_log "For more information, please see https://github.com/GameServerManagers/LinuxGSM/wiki/FAQ#-fail--starting-game-server-permissions-issues-found" + core_exit.sh + fi } fn_check_permissions(){