mirror of
https://github.com/ovh/debian-cis.git
synced 2025-06-22 02:33:42 +02:00
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:
@ -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 {} \;
|
||||
|
Reference in New Issue
Block a user