Add functions utils

I added two functions in utils that checks perms and ownership for file
resulting for a certain find. It takes parameters to filter the results
if needed.
This commit is contained in:
Thibault Ayanides
2020-10-05 17:01:13 +02:00
parent d6e5803252
commit a37c5bdc4e
2 changed files with 33 additions and 5 deletions

View File

@ -16,10 +16,12 @@ DESCRIPTION="Check permissions on logs (other has no permissions on any files an
DIR='/var/log'
PERMISSIONS='640'
OPTIONS=(-type f)
# This function will be called if the script status is on enabled / audit mode
audit () {
have_files_in_dir_correct_permissions $DIR $PERMISSIONS
have_files_in_dir_correct_permissions $DIR $PERMISSIONS OPTIONS
if [ $FNRET = 0 ]; then
ok "Logs in $DIR have correct permissions"
else
@ -29,9 +31,9 @@ audit () {
# This function will be called if the script status is on enabled mode
apply () {
have_files_in_dir_correct_permissions $DIR $PERMISSIONS
have_files_in_dir_correct_permissions $DIR $PERMISSIONS OPTIONS
if [ $FNRET = 0 ]; then
ok "$FILE has correct permissions"
ok "Logs in $DIR have correct permissions"
else
info "fixing $DIR logs permissions to $PERMISSIONS"
find $DIR -type f -exec chmod 0$PERMISSIONS {} \;