Browse Source

Merge pull request #958 from marvinl97/master

Added directory check
pull/965/head
Daniel Gibbs 9 years ago
committed by GitHub
parent
commit
77afec4543
  1. 26
      lgsm/functions/check_permissions.sh

26
lgsm/functions/check_permissions.sh

@ -9,21 +9,23 @@ local commandname="CHECK"
local function_selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))" local function_selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))"
fn_check_ownership(){ fn_check_ownership(){
if [ $(find "${filesdir}" -not -user $(whoami)|wc -l) -ne "0" ]||[ $(find "${rootdir}/${selfname}" -not -user $(whoami)|wc -l) -ne "0" ]; then if [ -d "${filesdir}" ]; then
fn_print_fail_nl "Permissions issues found" if [ $(find "${filesdir}" -not -user $(whoami)|wc -l) -ne "0" ]||[ $(find "${rootdir}/${selfname}" -not -user $(whoami)|wc -l) -ne "0" ]; then
fn_script_log_fatal "Permissions issues found" fn_print_fail_nl "Permissions issues found"
fn_print_infomation_nl "The current user ($(whoami)) does not have ownership of the following files:" fn_script_log_fatal "Permissions issues found"
fn_script_log_info "The current user ($(whoami)) does not have ownership of the following files:" 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" echo -e "User\tGroup\tFile\n"
} | column -s $'\t' -t | tee -a "${scriptlog}" find "${filesdir}" -not -user $(whoami) -printf "%u\t\t%g\t%p\n"
core_exit.sh } | column -s $'\t' -t | tee -a "${scriptlog}"
core_exit.sh
fi
fi fi
} }
fn_check_permissions(){ fn_check_permissions(){
if [ -n "${functionsdir}" ]; then if [ -d "${functionsdir}" ]; then
if [ $(find "${functionsdir}" -type f -not -executable|wc -l) -ne "0" ]; then if [ $(find "${functionsdir}" -type f -not -executable|wc -l) -ne "0" ]; then
fn_print_fail_nl "Permissions issues found" fn_print_fail_nl "Permissions issues found"
fn_script_log_fatal "Permissions issues found" fn_script_log_fatal "Permissions issues found"
@ -56,4 +58,4 @@ fn_check_permissions(){
} }
fn_check_ownership fn_check_ownership
fn_check_permissions fn_check_permissions

Loading…
Cancel
Save