Fix some bugs.
This commit is contained in:
parent
d45ddb82f7
commit
7433811fa0
|
@ -19,51 +19,62 @@ GROUP='adm'
|
|||
|
||||
# This function will be called if the script status is on enabled / audit mode
|
||||
audit () {
|
||||
FILES=$(grep "file(" $SYSLOG_BASEDIR/syslog-ng.conf | grep '"' | cut -d'"' -f 2)
|
||||
for FILE in $FILES; do
|
||||
does_file_exist $FILE
|
||||
if [ $FNRET != 0 ]; then
|
||||
crit "$FILE does not exist"
|
||||
else
|
||||
has_file_correct_ownership $FILE $USER $GROUP
|
||||
if [ $FNRET = 0 ]; then
|
||||
ok "$FILE has correct ownership"
|
||||
else
|
||||
crit "$FILE ownership was not set to $USER:$GROUP"
|
||||
fi
|
||||
has_file_correct_permissions $FILE $PERMISSIONS
|
||||
if [ $FNRET = 0 ]; then
|
||||
ok "$FILE has correct permissions"
|
||||
else
|
||||
crit "$FILE permissions were not set to $PERMISSIONS"
|
||||
fi
|
||||
fi
|
||||
done
|
||||
does_file_exist "$SYSLOG_BASEDIR/syslog-ng.conf"
|
||||
if [ $FNRET != 0 ]; then
|
||||
warn "$SYSLOG_BASEDIR/syslog-ng.conf is not exist! "
|
||||
FNRET=1
|
||||
else
|
||||
FILES=$(grep "file(" $SYSLOG_BASEDIR/syslog-ng.conf | grep '"' | cut -d'"' -f 2)
|
||||
for FILE in $FILES; do
|
||||
does_file_exist $FILE
|
||||
if [ $FNRET != 0 ]; then
|
||||
crit "$FILE does not exist"
|
||||
else
|
||||
has_file_correct_ownership $FILE $USER $GROUP
|
||||
if [ $FNRET = 0 ]; then
|
||||
ok "$FILE has correct ownership"
|
||||
else
|
||||
crit "$FILE ownership was not set to $USER:$GROUP"
|
||||
fi
|
||||
has_file_correct_permissions $FILE $PERMISSIONS
|
||||
if [ $FNRET = 0 ]; then
|
||||
ok "$FILE has correct permissions"
|
||||
else
|
||||
crit "$FILE permissions were not set to $PERMISSIONS"
|
||||
fi
|
||||
fi
|
||||
done
|
||||
fi
|
||||
}
|
||||
|
||||
# This function will be called if the script status is on enabled mode
|
||||
apply () {
|
||||
for FILE in $FILES; do
|
||||
does_file_exist $FILE
|
||||
if [ $FNRET != 0 ]; then
|
||||
info "$FILE does not exist"
|
||||
touch $FILE
|
||||
fi
|
||||
has_file_correct_ownership $FILE $USER $GROUP
|
||||
if [ $FNRET = 0 ]; then
|
||||
ok "$FILE has correct ownership"
|
||||
else
|
||||
warn "fixing $FILE ownership to $USER:$GROUP"
|
||||
chown $USER:$GROUP $FILE
|
||||
fi
|
||||
has_file_correct_permissions $FILE $PERMISSIONS
|
||||
if [ $FNRET = 0 ]; then
|
||||
ok "$FILE has correct permissions"
|
||||
else
|
||||
info "fixing $FILE permissions to $PERMISSIONS"
|
||||
chmod 0$PERMISSIONS $FILE
|
||||
fi
|
||||
done
|
||||
if [ $FNRET = 1 ]; then
|
||||
warn "$SYSLOG_BASEDIR/syslog-ng.conf is not exist! "
|
||||
else
|
||||
FILES=$(grep "file(" $SYSLOG_BASEDIR/syslog-ng.conf | grep '"' | cut -d'"' -f 2)
|
||||
for FILE in $FILES; do
|
||||
does_file_exist $FILE
|
||||
if [ $FNRET != 0 ]; then
|
||||
info "$FILE does not exist"
|
||||
touch $FILE
|
||||
fi
|
||||
has_file_correct_ownership $FILE $USER $GROUP
|
||||
if [ $FNRET = 0 ]; then
|
||||
ok "$FILE has correct ownership"
|
||||
else
|
||||
warn "fixing $FILE ownership to $USER:$GROUP"
|
||||
chown $USER:$GROUP $FILE
|
||||
fi
|
||||
has_file_correct_permissions $FILE $PERMISSIONS
|
||||
if [ $FNRET = 0 ]; then
|
||||
ok "$FILE has correct permissions"
|
||||
else
|
||||
info "fixing $FILE permissions to $PERMISSIONS"
|
||||
chmod 0$PERMISSIONS $FILE
|
||||
fi
|
||||
done
|
||||
fi
|
||||
}
|
||||
|
||||
# This function will create the config file for this check with default values
|
||||
|
|
|
@ -17,24 +17,33 @@ PATTERN='^destination.*(tcp|udp)[[:space:]]*\([[:space:]]*\".*\"[[:space:]]*\)'
|
|||
|
||||
# This function will be called if the script status is on enabled / audit mode
|
||||
audit () {
|
||||
FILES="$SYSLOG_BASEDIR/syslog-ng.conf $SYSLOG_BASEDIR/conf.d/*"
|
||||
does_pattern_exist_in_file "$FILES" "$PATTERN"
|
||||
if [ $FNRET != 0 ]; then
|
||||
crit "$PATTERN is not present in $FILES"
|
||||
else
|
||||
ok "$PATTERN is present in $FILES"
|
||||
fi
|
||||
if [ -d "$SYSLOG_BASEDIR" ]; then
|
||||
FILES="$SYSLOG_BASEDIR/syslog-ng.conf $SYSLOG_BASEDIR/conf.d/*"
|
||||
does_pattern_exist_in_file "$FILES" "$PATTERN"
|
||||
if [ $FNRET != 0 ]; then
|
||||
crit "$PATTERN is not present in $FILES"
|
||||
else
|
||||
ok "$PATTERN is present in $FILES"
|
||||
fi
|
||||
else
|
||||
warn "$SYSLOG_BASEDIR is not exist!"
|
||||
FNRET=1
|
||||
fi
|
||||
}
|
||||
|
||||
# This function will be called if the script status is on enabled mode
|
||||
apply () {
|
||||
FILES="$SYSLOG_BASEDIR/syslog-ng.conf $SYSLOG_BASEDIR/conf.d/*"
|
||||
does_pattern_exist_in_file "$FILES" "$PATTERN"
|
||||
if [ $FNRET != 0 ]; then
|
||||
crit "$PATTERN is not present in $FILES, please set a remote host to send your logs"
|
||||
else
|
||||
ok "$PATTERN is present in $FILES"
|
||||
fi
|
||||
if [ $FNRET = 1 ]; then
|
||||
warn "$SYSLOG_BASEDIR is not exist!"
|
||||
else
|
||||
FILES="$SYSLOG_BASEDIR/syslog-ng.conf $SYSLOG_BASEDIR/conf.d/*"
|
||||
does_pattern_exist_in_file "$FILES" "$PATTERN"
|
||||
if [ $FNRET != 0 ]; then
|
||||
crit "$PATTERN is not present in $FILES, please set a remote host to send your logs"
|
||||
else
|
||||
ok "$PATTERN is present in $FILES"
|
||||
fi
|
||||
fi
|
||||
}
|
||||
|
||||
# This function will create the config file for this check with default values
|
||||
|
|
Loading…
Reference in New Issue