Skip to content

Commit

Permalink
feat(permissions): Attempt to fix non executable files issue
Browse files Browse the repository at this point in the history
  • Loading branch information
dgibbs64 committed Sep 1, 2024
1 parent 02223a5 commit 047aaa0
Showing 1 changed file with 37 additions and 20 deletions.
57 changes: 37 additions & 20 deletions lgsm/modules/check_permissions.sh
Original file line number Diff line number Diff line change
Expand Up @@ -58,26 +58,43 @@ fn_check_ownership() {
}

fn_check_permissions() {
# Check modules files are executable.
if [ -d "${modulesdir}" ]; then
findnotexecutable="$(find "${modulesdir}" -type f -not -executable)"
findnotexecutablewc="$(find "${modulesdir}" -type f -not -executable | wc -l)"
if [ "${findnotexecutablewc}" -ne "0" ]; then
fn_print_fail_nl "Permissions issues found"
fn_script_log_fail "Permissions issues found"
fn_print_information_nl "The following files are not executable:"
fn_script_log_info "The following files are not executable:"
{
echo -en "File:"
echo -en "${findnotexecutable}"
} | column -s $'\t' -t | tee -a "${lgsmlog}"
if [ "${monitorflag}" == 1 ]; then
alert="permissions"
alert.sh
fi
core_exit.sh
fi
fi
# Check modules files are executable.
if [ -d "${modulesdir}" ]; then
findnotexecutable="$(find "${modulesdir}" -type f -not -executable)"
findnotexecutablewc="$(find "${modulesdir}" -type f -not -executable | wc -l)"
if [ "${findnotexecutablewc}" -ne "0" ]; then
fn_print_fail_nl "Permissions issues found"
fn_script_log_fail "Permissions issues found"
fn_print_information_nl "The following files are not executable:"
fn_script_log_info "The following files are not executable:"
{
echo -en "File:"
echo -en "${findnotexecutable}"
} | column -s $'\t' -t | tee -a "${lgsmlog}"

# Attempt to make the files executable
fn_print_information_nl "Attempting to fix permissions issues"
fn_script_log_info "Attempting to fix permissions issues"
echo "${findnotexecutable}" | xargs chmod +x

# Re-check if there are still non-executable files
findnotexecutable="$(find "${modulesdir}" -type f -not -executable)"
findnotexecutablewc="$(find "${modulesdir}" -type f -not -executable | wc -l)"
if [ "${findnotexecutablewc}" -ne "0" ]; then
fn_print_fail_nl "Failed to resolve permissions issues"
fn_script_log_fail "Failed to resolve permissions issues"
if [ "${monitorflag}" == 1 ]; then
alert="permissions"
alert.sh
fi
core_exit.sh
else
fn_print_ok_nl "Permissions issues resolved"
fn_script_log_pass "Permissions issues resolved"
fi
fi
fi
}

# Check rootdir permissions.
if [ -d "${rootdir}" ]; then
Expand Down

0 comments on commit 047aaa0

Please sign in to comment.