Add audit and apply methods for redhat/CentOS to 2.2
This commit is contained in:
parent
1fa5bdd149
commit
674e034324
|
@ -1,7 +1,7 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
#
|
#
|
||||||
# harbian audit Debian 7/8/9 Hardening
|
# harbian audit Debian 7/8/9 or CentOS Hardening
|
||||||
# Modify by: Samson-W (sccxboy@gmail.com)
|
# Modify by: Samson-W (sccxboy@gmail.com)
|
||||||
#
|
#
|
||||||
|
|
||||||
|
@ -17,8 +17,9 @@ HARDENING_LEVEL=2
|
||||||
# Quick factoring as many script use the same logic
|
# Quick factoring as many script use the same logic
|
||||||
PARTITION="/tmp"
|
PARTITION="/tmp"
|
||||||
OPTION="nodev"
|
OPTION="nodev"
|
||||||
SERVICEPATH="/usr/share/systemd/tmp.mount"
|
|
||||||
SERVICENAME="tmp.mount"
|
SERVICENAME="tmp.mount"
|
||||||
|
SERVICEPATH="/usr/share/systemd/tmp.mount"
|
||||||
|
REDHAT_SERVICEPATH="/usr/lib/systemd/system/tmp.mount"
|
||||||
|
|
||||||
# This function will be called if the script status is on enabled / audit mode
|
# This function will be called if the script status is on enabled / audit mode
|
||||||
audit () {
|
audit () {
|
||||||
|
@ -45,8 +46,12 @@ audit () {
|
||||||
fi
|
fi
|
||||||
else
|
else
|
||||||
warn "$PARTITION is not partition in /etc/fstab, check tmp.mount service"
|
warn "$PARTITION is not partition in /etc/fstab, check tmp.mount service"
|
||||||
if [ -e $SERVICEPATH ]; then
|
if [ -e $SERVICEPATH -o -e $REDHAT_SERVICEPATH ]; then
|
||||||
has_mount_option_systemd $SERVICEPATH $OPTION
|
if [ $OS_RELEASE -eq 1 ]; then
|
||||||
|
has_mount_option_systemd $SERVICEPATH $OPTION
|
||||||
|
elif [ $OS_RELEASE -eq 2 ]; then
|
||||||
|
has_mount_option_systemd $REDHAT_SERVICEPATH $OPTION
|
||||||
|
fi
|
||||||
if [ $FNRET -gt 0 ]; then
|
if [ $FNRET -gt 0 ]; then
|
||||||
crit "$PARTITION has no option $OPTION in systemd service!"
|
crit "$PARTITION has no option $OPTION in systemd service!"
|
||||||
FNRET=3
|
FNRET=3
|
||||||
|
@ -62,7 +67,11 @@ audit () {
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
else
|
else
|
||||||
crit "$TMPMOUNTO is not exist!"
|
if [ $OS_RELEASE -eq 1 ]; then
|
||||||
|
crit "$SERVICEPATH is not exist!"
|
||||||
|
elif [ $OS_RELEASE -eq 2 ]; then
|
||||||
|
crit "$REDHAT_SERVICEPATH is not exist!"
|
||||||
|
fi
|
||||||
FNRET=2
|
FNRET=2
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
@ -86,7 +95,11 @@ apply () {
|
||||||
fi
|
fi
|
||||||
elif [ $FNRET = 3 ]; then
|
elif [ $FNRET = 3 ]; then
|
||||||
info "Adding $OPTION to systemd"
|
info "Adding $OPTION to systemd"
|
||||||
add_option_to_systemd $SERVICEPATH $OPTION $SERVICENAME
|
if [ $OS_RELEASE -eq 1 ]; then
|
||||||
|
add_option_to_systemd $SERVICEPATH $OPTION $SERVICENAME
|
||||||
|
elif [ $OS_RELEASE -eq 2 ]; then
|
||||||
|
add_option_to_systemd $REDHAT_SERVICEPATH $OPTION $SERVICENAME
|
||||||
|
fi
|
||||||
remount_partition_by_systemd $SERVICENAME $PARTITION
|
remount_partition_by_systemd $SERVICENAME $PARTITION
|
||||||
elif [ $FNRET = 4 ]; then
|
elif [ $FNRET = 4 ]; then
|
||||||
info "Remounting $PARTITION from fstab"
|
info "Remounting $PARTITION from fstab"
|
||||||
|
|
Loading…
Reference in New Issue