diff --git a/bin/hardening/9.2.10_pam_maxclassrepeat_cracklib.sh b/bin/hardening/9.2.10_pam_maxclassrepeat_cracklib.sh index a167ce2..65c3ae5 100755 --- a/bin/hardening/9.2.10_pam_maxclassrepeat_cracklib.sh +++ b/bin/hardening/9.2.10_pam_maxclassrepeat_cracklib.sh @@ -1,7 +1,7 @@ #!/bin/bash # -# harbian audit 7/8/9 Hardening +# harbian audit 7/8/9/10 or CentOS Hardening # # @@ -19,13 +19,15 @@ PAMLIBNAME='pam_cracklib.so' PATTERN='^password.*pam_cracklib.so' FILE='/etc/pam.d/common-password' +# Redhat/CentOS default use pam_pwquality +FILE_REDHAT='/etc/security/pwquality.conf' + OPTIONNAME='maxclassrepeat' # condition CONDT_VAL=4 -# This function will be called if the script status is on enabled / audit mode -audit () { +audit_debian () { is_pkg_installed $PACKAGE if [ $FNRET != 0 ]; then crit "$PACKAGE is not installed!" @@ -49,8 +51,32 @@ audit () { fi } -# This function will be called if the script status is on enabled mode -apply () { +audit_redhat () { + check_param_pair_by_value $FILE_REDHAT $OPTIONNAME le $CONDT_VAL + if [ $FNRET = 0 ]; then + ok "Option $OPTIONNAME set condition is $CONDT_VAL in $FILE_REDHAT" + elif [ $FNRET = 1 ]; then + crit "Option $OPTIONNAME set condition is not set $CONDT_VAL in $FILE_REDHAT" + elif [ $FNRET = 2 ]; then + crit "Option $OPTIONNAME is not conf in $FILE_REDHAT" + elif [ $FNRET = 3 ]; then + crit "Config file $FILE_REDHAT is not exist!" + fi +} + +# This function will be called if the script status is on enabled / audit mode +audit () { + if [ $OS_RELEASE -eq 1 ]; then + audit_debian + elif [ $OS_RELEASE -eq 2 ]; then + audit_redhat + else + crit "Current OS is not support!" + FNRET=44 + fi +} + +apply_debian () { if [ $FNRET = 0 ]; then ok "$PACKAGE is installed" elif [ $FNRET = 1 ]; then @@ -70,6 +96,31 @@ apply () { fi } +apply_redhat () { + if [ $FNRET = 0 ]; then + ok "$OPTIONNAME set condition is $CONDT_VAL in $FILE_REDHAT" + elif [ $FNRET = 1 ]; then + warn "Set option $OPTIONNAME to $CONDT_VAL in $FILE_REDHAT" + replace_in_file $FILE_REDHAT "^$OPTIONNAME.*" "$OPTIONNAME = $CONDT_VAL" + elif [ $FNRET = 2 ]; then + warn "$OPTIONNAME is not conf, add to $FILE_REDHAT" + add_end_of_file $FILE_REDHAT "$OPTIONNAME = $CONDT_VAL" + elif [ $FNRET = 3 ]; then + crit "Config file $FILE_REDHAT is not exist!" + fi +} + +# This function will be called if the script status is on enabled mode +apply () { + if [ $OS_RELEASE -eq 1 ]; then + apply_debian + elif [ $OS_RELEASE -eq 2 ]; then + apply_redhat + else + crit "Current OS is not support!" + fi +} + # This function will check config parameters required check_config() { : diff --git a/bin/hardening/9.2.3_pam_dcredit_cracklib.sh b/bin/hardening/9.2.3_pam_dcredit_cracklib.sh index 896cf9a..1e7abdb 100755 --- a/bin/hardening/9.2.3_pam_dcredit_cracklib.sh +++ b/bin/hardening/9.2.3_pam_dcredit_cracklib.sh @@ -1,7 +1,7 @@ #!/bin/bash # -# harbian audit 9 Hardening +# harbian audit 9/10 or CentOS Hardening # # @@ -19,13 +19,15 @@ PAMLIBNAME='pam_cracklib.so' PATTERN='^password.*pam_cracklib.so' FILE='/etc/pam.d/common-password' +# Redhat/CentOS default use pam_pwquality +FILE_REDHAT='/etc/security/pwquality.conf' + OPTIONNAME='dcredit' # condition CONDT_VAL=-1 -# This function will be called if the script status is on enabled / audit mode -audit () { +audit_debian () { is_pkg_installed $PACKAGE if [ $FNRET != 0 ]; then crit "$PACKAGE is not installed!" @@ -49,8 +51,32 @@ audit () { fi } -# This function will be called if the script status is on enabled mode -apply () { +audit_redhat () { + check_param_pair_by_value $FILE_REDHAT $OPTIONNAME le $CONDT_VAL + if [ $FNRET = 0 ]; then + ok "Option $OPTIONNAME set condition is $CONDT_VAL in $FILE_REDHAT" + elif [ $FNRET = 1 ]; then + crit "Option $OPTIONNAME set condition is not set $CONDT_VAL in $FILE_REDHAT" + elif [ $FNRET = 2 ]; then + crit "Option $OPTIONNAME is not conf in $FILE_REDHAT" + elif [ $FNRET = 3 ]; then + crit "Config file $FILE_REDHAT is not exist!" + fi +} + +# This function will be called if the script status is on enabled / audit mode +audit () { + if [ $OS_RELEASE -eq 1 ]; then + audit_debian + elif [ $OS_RELEASE -eq 2 ]; then + audit_redhat + else + crit "Current OS is not support!" + FNRET=44 + fi +} + +apply_debian () { if [ $FNRET = 0 ]; then ok "$PACKAGE is installed" elif [ $FNRET = 1 ]; then @@ -70,6 +96,31 @@ apply () { fi } +apply_redhat () { + if [ $FNRET = 0 ]; then + ok "$OPTIONNAME set condition is $CONDT_VAL in $FILE_REDHAT" + elif [ $FNRET = 1 ]; then + warn "Set option $OPTIONNAME to $CONDT_VAL in $FILE_REDHAT" + replace_in_file $FILE_REDHAT "^$OPTIONNAME.*" "$OPTIONNAME = $CONDT_VAL" + elif [ $FNRET = 2 ]; then + warn "$OPTIONNAME is not conf, add to $FILE_REDHAT" + add_end_of_file $FILE_REDHAT "$OPTIONNAME = $CONDT_VAL" + elif [ $FNRET = 3 ]; then + crit "Config file $FILE_REDHAT is not exist!" + fi +} + +# This function will be called if the script status is on enabled mode +apply () { + if [ $OS_RELEASE -eq 1 ]; then + apply_debian + elif [ $OS_RELEASE -eq 2 ]; then + apply_redhat + else + crit "Current OS is not support!" + fi +} + # This function will check config parameters required check_config() { : diff --git a/bin/hardening/9.2.4_pam_ucredit_cracklib.sh b/bin/hardening/9.2.4_pam_ucredit_cracklib.sh index 7b451b8..59eed23 100755 --- a/bin/hardening/9.2.4_pam_ucredit_cracklib.sh +++ b/bin/hardening/9.2.4_pam_ucredit_cracklib.sh @@ -1,7 +1,7 @@ #!/bin/bash # -# harbian audit 9 Hardening +# harbian audit 9/10 or CentOS Hardening # # @@ -19,13 +19,15 @@ PAMLIBNAME='pam_cracklib.so' PATTERN='^password.*pam_cracklib.so' FILE='/etc/pam.d/common-password' +# Redhat/CentOS default use pam_pwquality +FILE_REDHAT='/etc/security/pwquality.conf' + OPTIONNAME='ucredit' # condition CONDT_VAL=-1 -# This function will be called if the script status is on enabled / audit mode -audit () { +audit_debian () { is_pkg_installed $PACKAGE if [ $FNRET != 0 ]; then crit "$PACKAGE is not installed!" @@ -49,8 +51,33 @@ audit () { fi } -# This function will be called if the script status is on enabled mode -apply () { +audit_redhat () { + check_param_pair_by_value $FILE_REDHAT $OPTIONNAME le $CONDT_VAL + if [ $FNRET = 0 ]; then + ok "Option $OPTIONNAME set condition is $CONDT_VAL in $FILE_REDHAT" + elif [ $FNRET = 1 ]; then + crit "Option $OPTIONNAME set condition is not set $CONDT_VAL in $FILE_REDHAT" + elif [ $FNRET = 2 ]; then + crit "Option $OPTIONNAME is not conf in $FILE_REDHAT" + elif [ $FNRET = 3 ]; then + crit "Config file $FILE_REDHAT is not exist!" + fi +} + +# This function will be called if the script status is on enabled / audit mode +audit () { + if [ $OS_RELEASE -eq 1 ]; then + audit_debian + elif [ $OS_RELEASE -eq 2 ]; then + audit_redhat + else + crit "Current OS is not support!" + FNRET=44 + fi +} + + +apply_debian () { if [ $FNRET = 0 ]; then ok "$PACKAGE is installed" elif [ $FNRET = 1 ]; then @@ -70,6 +97,31 @@ apply () { fi } +apply_redhat () { + if [ $FNRET = 0 ]; then + ok "$OPTIONNAME set condition is $CONDT_VAL in $FILE_REDHAT" + elif [ $FNRET = 1 ]; then + warn "Set option $OPTIONNAME to $CONDT_VAL in $FILE_REDHAT" + replace_in_file $FILE_REDHAT "^$OPTIONNAME.*" "$OPTIONNAME = $CONDT_VAL" + elif [ $FNRET = 2 ]; then + warn "$OPTIONNAME is not conf, add to $FILE_REDHAT" + add_end_of_file $FILE_REDHAT "$OPTIONNAME = $CONDT_VAL" + elif [ $FNRET = 3 ]; then + crit "Config file $FILE_REDHAT is not exist!" + fi +} + +# This function will be called if the script status is on enabled mode +apply () { + if [ $OS_RELEASE -eq 1 ]; then + apply_debian + elif [ $OS_RELEASE -eq 2 ]; then + apply_redhat + else + crit "Current OS is not support!" + fi +} + # This function will check config parameters required check_config() { : diff --git a/bin/hardening/9.2.5_pam_ocredit_cracklib.sh b/bin/hardening/9.2.5_pam_ocredit_cracklib.sh index 56bbc6b..1f9124d 100755 --- a/bin/hardening/9.2.5_pam_ocredit_cracklib.sh +++ b/bin/hardening/9.2.5_pam_ocredit_cracklib.sh @@ -1,7 +1,7 @@ #!/bin/bash # -# harbian audit 9 Hardening +# harbian audit 9/10 or CentOS Hardening # # @@ -19,13 +19,15 @@ PAMLIBNAME='pam_cracklib.so' PATTERN='^password.*pam_cracklib.so' FILE='/etc/pam.d/common-password' +# Redhat/CentOS default use pam_pwquality +FILE_REDHAT='/etc/security/pwquality.conf' + OPTIONNAME='ocredit' # condition CONDT_VAL=-1 -# This function will be called if the script status is on enabled / audit mode -audit () { +audit_debian () { is_pkg_installed $PACKAGE if [ $FNRET != 0 ]; then crit "$PACKAGE is not installed!" @@ -49,8 +51,32 @@ audit () { fi } -# This function will be called if the script status is on enabled mode -apply () { +audit_redhat () { + check_param_pair_by_value $FILE_REDHAT $OPTIONNAME le $CONDT_VAL + if [ $FNRET = 0 ]; then + ok "Option $OPTIONNAME set condition is $CONDT_VAL in $FILE_REDHAT" + elif [ $FNRET = 1 ]; then + crit "Option $OPTIONNAME set condition is not set $CONDT_VAL in $FILE_REDHAT" + elif [ $FNRET = 2 ]; then + crit "Option $OPTIONNAME is not conf in $FILE_REDHAT" + elif [ $FNRET = 3 ]; then + crit "Config file $FILE_REDHAT is not exist!" + fi +} + +# This function will be called if the script status is on enabled / audit mode +audit () { + if [ $OS_RELEASE -eq 1 ]; then + audit_debian + elif [ $OS_RELEASE -eq 2 ]; then + audit_redhat + else + crit "Current OS is not support!" + FNRET=44 + fi +} + +apply_debian () { if [ $FNRET = 0 ]; then ok "$PACKAGE is installed" elif [ $FNRET = 1 ]; then @@ -70,6 +96,32 @@ apply () { fi } +apply_redhat () { + if [ $FNRET = 0 ]; then + ok "$OPTIONNAME set condition is $CONDT_VAL in $FILE_REDHAT" + elif [ $FNRET = 1 ]; then + warn "Set option $OPTIONNAME to $CONDT_VAL in $FILE_REDHAT" + replace_in_file $FILE_REDHAT "^$OPTIONNAME.*" "$OPTIONNAME = $CONDT_VAL" + elif [ $FNRET = 2 ]; then + warn "$OPTIONNAME is not conf, add to $FILE_REDHAT" + add_end_of_file $FILE_REDHAT "$OPTIONNAME = $CONDT_VAL" + elif [ $FNRET = 3 ]; then + crit "Config file $FILE_REDHAT is not exist!" + fi +} + +# This function will be called if the script status is on enabled mode +apply () { + if [ $OS_RELEASE -eq 1 ]; then + apply_debian + elif [ $OS_RELEASE -eq 2 ]; then + apply_redhat + else + crit "Current OS is not support!" + fi +} + + # This function will check config parameters required check_config() { : diff --git a/bin/hardening/9.2.6_pam_lcredit_cracklib.sh b/bin/hardening/9.2.6_pam_lcredit_cracklib.sh index fb56c7b..91ccf42 100755 --- a/bin/hardening/9.2.6_pam_lcredit_cracklib.sh +++ b/bin/hardening/9.2.6_pam_lcredit_cracklib.sh @@ -1,7 +1,7 @@ #!/bin/bash # -# harbian audit 9 Hardening +# harbian audit 9/10 or CentOS Hardening # # @@ -19,13 +19,15 @@ PAMLIBNAME='pam_cracklib.so' PATTERN='^password.*pam_cracklib.so' FILE='/etc/pam.d/common-password' +# Redhat/CentOS default use pam_pwquality +FILE_REDHAT='/etc/security/pwquality.conf' + OPTIONNAME='lcredit' # condition CONDT_VAL=-1 -# This function will be called if the script status is on enabled / audit mode -audit () { +audit_debian () { is_pkg_installed $PACKAGE if [ $FNRET != 0 ]; then crit "$PACKAGE is not installed!" @@ -49,8 +51,32 @@ audit () { fi } -# This function will be called if the script status is on enabled mode -apply () { +audit_redhat () { + check_param_pair_by_value $FILE_REDHAT $OPTIONNAME le $CONDT_VAL + if [ $FNRET = 0 ]; then + ok "Option $OPTIONNAME set condition is $CONDT_VAL in $FILE_REDHAT" + elif [ $FNRET = 1 ]; then + crit "Option $OPTIONNAME set condition is not set $CONDT_VAL in $FILE_REDHAT" + elif [ $FNRET = 2 ]; then + crit "Option $OPTIONNAME is not conf in $FILE_REDHAT" + elif [ $FNRET = 3 ]; then + crit "Config file $FILE_REDHAT is not exist!" + fi +} + +# This function will be called if the script status is on enabled / audit mode +audit () { + if [ $OS_RELEASE -eq 1 ]; then + audit_debian + elif [ $OS_RELEASE -eq 2 ]; then + audit_redhat + else + crit "Current OS is not support!" + FNRET=44 + fi +} + +apply_debian () { if [ $FNRET = 0 ]; then ok "$PACKAGE is installed" elif [ $FNRET = 1 ]; then @@ -70,6 +96,31 @@ apply () { fi } +apply_redhat () { + if [ $FNRET = 0 ]; then + ok "$OPTIONNAME set condition is $CONDT_VAL in $FILE_REDHAT" + elif [ $FNRET = 1 ]; then + warn "Set option $OPTIONNAME to $CONDT_VAL in $FILE_REDHAT" + replace_in_file $FILE_REDHAT "^$OPTIONNAME.*" "$OPTIONNAME = $CONDT_VAL" + elif [ $FNRET = 2 ]; then + warn "$OPTIONNAME is not conf, add to $FILE_REDHAT" + add_end_of_file $FILE_REDHAT "$OPTIONNAME = $CONDT_VAL" + elif [ $FNRET = 3 ]; then + crit "Config file $FILE_REDHAT is not exist!" + fi +} + +# This function will be called if the script status is on enabled mode +apply () { + if [ $OS_RELEASE -eq 1 ]; then + apply_debian + elif [ $OS_RELEASE -eq 2 ]; then + apply_redhat + else + crit "Current OS is not support!" + fi +} + # This function will check config parameters required check_config() { : diff --git a/bin/hardening/9.2.7_pam_difok_cracklib.sh b/bin/hardening/9.2.7_pam_difok_cracklib.sh index ad95398..8f82b18 100755 --- a/bin/hardening/9.2.7_pam_difok_cracklib.sh +++ b/bin/hardening/9.2.7_pam_difok_cracklib.sh @@ -1,7 +1,7 @@ #!/bin/bash # -# harbian audit 7/8/9 Hardening +# harbian audit 7/8/9/10 or CentOS Hardening # # @@ -19,13 +19,15 @@ PAMLIBNAME='pam_cracklib.so' PATTERN='^password.*pam_cracklib.so' FILE='/etc/pam.d/common-password' +# Redhat/CentOS default use pam_pwquality +FILE_REDHAT='/etc/security/pwquality.conf' + OPTIONNAME='difok' # condition CONDT_VAL=8 -# This function will be called if the script status is on enabled / audit mode -audit () { +audit_debian () { is_pkg_installed $PACKAGE if [ $FNRET != 0 ]; then crit "$PACKAGE is not installed!" @@ -49,8 +51,32 @@ audit () { fi } -# This function will be called if the script status is on enabled mode -apply () { +audit_redhat () { + check_param_pair_by_value $FILE_REDHAT $OPTIONNAME ge $CONDT_VAL + if [ $FNRET = 0 ]; then + ok "Option $OPTIONNAME set condition is $CONDT_VAL in $FILE_REDHAT" + elif [ $FNRET = 1 ]; then + crit "Option $OPTIONNAME set condition is not set $CONDT_VAL in $FILE_REDHAT" + elif [ $FNRET = 2 ]; then + crit "Option $OPTIONNAME is not conf in $FILE_REDHAT" + elif [ $FNRET = 3 ]; then + crit "Config file $FILE_REDHAT is not exist!" + fi +} + +# This function will be called if the script status is on enabled / audit mode +audit () { + if [ $OS_RELEASE -eq 1 ]; then + audit_debian + elif [ $OS_RELEASE -eq 2 ]; then + audit_redhat + else + crit "Current OS is not support!" + FNRET=44 + fi +} + +apply_debian () { if [ $FNRET = 0 ]; then ok "$PACKAGE is installed" elif [ $FNRET = 1 ]; then @@ -70,6 +96,31 @@ apply () { fi } +apply_redhat () { + if [ $FNRET = 0 ]; then + ok "$OPTIONNAME set condition is $CONDT_VAL in $FILE_REDHAT" + elif [ $FNRET = 1 ]; then + warn "Set option $OPTIONNAME to $CONDT_VAL in $FILE_REDHAT" + replace_in_file $FILE_REDHAT "^$OPTIONNAME.*" "$OPTIONNAME = $CONDT_VAL" + elif [ $FNRET = 2 ]; then + warn "$OPTIONNAME is not conf, add to $FILE_REDHAT" + add_end_of_file $FILE_REDHAT "$OPTIONNAME = $CONDT_VAL" + elif [ $FNRET = 3 ]; then + crit "Config file $FILE_REDHAT is not exist!" + fi +} + +# This function will be called if the script status is on enabled mode +apply () { + if [ $OS_RELEASE -eq 1 ]; then + apply_debian + elif [ $OS_RELEASE -eq 2 ]; then + apply_redhat + else + crit "Current OS is not support!" + fi +} + # This function will check config parameters required check_config() { : diff --git a/bin/hardening/9.2.8_pam_minclass_cracklib.sh b/bin/hardening/9.2.8_pam_minclass_cracklib.sh index 1ec456a..7302373 100755 --- a/bin/hardening/9.2.8_pam_minclass_cracklib.sh +++ b/bin/hardening/9.2.8_pam_minclass_cracklib.sh @@ -1,7 +1,7 @@ #!/bin/bash # -# harbian audit 7/8/9 Hardening +# harbian audit 7/8/9/10 or CentOS Hardening # # @@ -19,13 +19,15 @@ PAMLIBNAME='pam_cracklib.so' PATTERN='^password.*pam_cracklib.so' FILE='/etc/pam.d/common-password' +# Redhat/CentOS default use pam_pwquality +FILE_REDHAT='/etc/security/pwquality.conf' + OPTIONNAME='minclass' # condition CONDT_VAL=4 -# This function will be called if the script status is on enabled / audit mode -audit () { +audit_debian () { is_pkg_installed $PACKAGE if [ $FNRET != 0 ]; then crit "$PACKAGE is not installed!" @@ -49,8 +51,32 @@ audit () { fi } -# This function will be called if the script status is on enabled mode -apply () { +audit_redhat () { + check_param_pair_by_value $FILE_REDHAT $OPTIONNAME ge $CONDT_VAL + if [ $FNRET = 0 ]; then + ok "Option $OPTIONNAME set condition is $CONDT_VAL in $FILE_REDHAT" + elif [ $FNRET = 1 ]; then + crit "Option $OPTIONNAME set condition is not set $CONDT_VAL in $FILE_REDHAT" + elif [ $FNRET = 2 ]; then + crit "Option $OPTIONNAME is not conf in $FILE_REDHAT" + elif [ $FNRET = 3 ]; then + crit "Config file $FILE_REDHAT is not exist!" + fi +} + +# This function will be called if the script status is on enabled / audit mode +audit () { + if [ $OS_RELEASE -eq 1 ]; then + audit_debian + elif [ $OS_RELEASE -eq 2 ]; then + audit_redhat + else + crit "Current OS is not support!" + FNRET=44 + fi +} + +apply_debian () { if [ $FNRET = 0 ]; then ok "$PACKAGE is installed" elif [ $FNRET = 1 ]; then @@ -70,6 +96,31 @@ apply () { fi } +apply_redhat () { + if [ $FNRET = 0 ]; then + ok "$OPTIONNAME set condition is $CONDT_VAL in $FILE_REDHAT" + elif [ $FNRET = 1 ]; then + warn "Set option $OPTIONNAME to $CONDT_VAL in $FILE_REDHAT" + replace_in_file $FILE_REDHAT "^$OPTIONNAME.*" "$OPTIONNAME = $CONDT_VAL" + elif [ $FNRET = 2 ]; then + warn "$OPTIONNAME is not conf, add to $FILE_REDHAT" + add_end_of_file $FILE_REDHAT "$OPTIONNAME = $CONDT_VAL" + elif [ $FNRET = 3 ]; then + crit "Config file $FILE_REDHAT is not exist!" + fi +} + +# This function will be called if the script status is on enabled mode +apply () { + if [ $OS_RELEASE -eq 1 ]; then + apply_debian + elif [ $OS_RELEASE -eq 2 ]; then + apply_redhat + else + crit "Current OS is not support!" + fi +} + # This function will check config parameters required check_config() { : diff --git a/bin/hardening/9.2.9_pam_maxrepeat_cracklib.sh b/bin/hardening/9.2.9_pam_maxrepeat_cracklib.sh index 46b0031..9fba742 100755 --- a/bin/hardening/9.2.9_pam_maxrepeat_cracklib.sh +++ b/bin/hardening/9.2.9_pam_maxrepeat_cracklib.sh @@ -1,7 +1,7 @@ #!/bin/bash # -# harbian audit 7/8/9 Hardening +# harbian audit 7/8/9/10 or CentOS Hardening # # @@ -19,13 +19,15 @@ PAMLIBNAME='pam_cracklib.so' PATTERN='^password.*pam_cracklib.so' FILE='/etc/pam.d/common-password' +# Redhat/CentOS default use pam_pwquality +FILE_REDHAT='/etc/security/pwquality.conf' + OPTIONNAME='maxrepeat' # condition CONDT_VAL=3 -# This function will be called if the script status is on enabled / audit mode -audit () { +audit_debian () { is_pkg_installed $PACKAGE if [ $FNRET != 0 ]; then crit "$PACKAGE is not installed!" @@ -49,8 +51,32 @@ audit () { fi } -# This function will be called if the script status is on enabled mode -apply () { +audit_redhat () { + check_param_pair_by_value $FILE_REDHAT $OPTIONNAME le $CONDT_VAL + if [ $FNRET = 0 ]; then + ok "Option $OPTIONNAME set condition is $CONDT_VAL in $FILE_REDHAT" + elif [ $FNRET = 1 ]; then + crit "Option $OPTIONNAME set condition is not set $CONDT_VAL in $FILE_REDHAT" + elif [ $FNRET = 2 ]; then + crit "Option $OPTIONNAME is not conf in $FILE_REDHAT" + elif [ $FNRET = 3 ]; then + crit "Config file $FILE_REDHAT is not exist!" + fi +} + +# This function will be called if the script status is on enabled / audit mode +audit () { + if [ $OS_RELEASE -eq 1 ]; then + audit_debian + elif [ $OS_RELEASE -eq 2 ]; then + audit_redhat + else + crit "Current OS is not support!" + FNRET=44 + fi +} + +apply_debian () { if [ $FNRET = 0 ]; then ok "$PACKAGE is installed" elif [ $FNRET = 1 ]; then @@ -70,6 +96,31 @@ apply () { fi } +apply_redhat () { + if [ $FNRET = 0 ]; then + ok "$OPTIONNAME set condition is $CONDT_VAL in $FILE_REDHAT" + elif [ $FNRET = 1 ]; then + warn "Set option $OPTIONNAME to $CONDT_VAL in $FILE_REDHAT" + replace_in_file $FILE_REDHAT "^$OPTIONNAME.*" "$OPTIONNAME = $CONDT_VAL" + elif [ $FNRET = 2 ]; then + warn "$OPTIONNAME is not conf, add to $FILE_REDHAT" + add_end_of_file $FILE_REDHAT "$OPTIONNAME = $CONDT_VAL" + elif [ $FNRET = 3 ]; then + crit "Config file $FILE_REDHAT is not exist!" + fi +} + +# This function will be called if the script status is on enabled mode +apply () { + if [ $OS_RELEASE -eq 1 ]; then + apply_debian + elif [ $OS_RELEASE -eq 2 ]; then + apply_redhat + else + crit "Current OS is not support!" + fi +} + # This function will check config parameters required check_config() { :