Fix some bugs.

This commit is contained in:
samson 2018-12-02 21:11:10 +08:00
parent a3a0c25d1a
commit 5f9346486d
4 changed files with 5 additions and 4 deletions

View File

@ -16,7 +16,7 @@ HARDENING_LEVEL=2
# Quick factoring as many script use the same logic
PARTITION="/tmp"
OPTION="nodev"
SERVICEPATH="/etc/systemd/system/tmp.mount"
SERVICEPATH="/usr/share/systemd/tmp.mount"
SERVICENAME="tmp.mount"
# This function will be called if the script status is on enabled / audit mode

View File

@ -61,7 +61,7 @@ apply () {
done
elif [ $FNRET = 2 ]; then
warn "Set ${SETSTRING} to ${GRUBFILE} in ${GRUBFILE}, need to reboot the system and enable AppArmor profiles after setting it."
sed -ie "s;\(${KEYWORD}=\)\(\".*\)\(\"\);\1\2 ${SETSTRING}\3;" ${GRUBFILE}
sed -i "s;\(${KEYWORD}=\)\(\".*\)\(\"\);\1\2 ${SETSTRING}\3;" ${GRUBFILE}
/usr/sbin/update-grub2
elif [ $FNRET = 3 ]; then
warn "Enable AppArmor profiles in the system "

View File

@ -53,11 +53,11 @@ apply () {
touch $FILE
elif [ $FNRET = 2 ]; then
warn "$OPTION is not present in $FILE, add it to $KEYWORD line, need to reboot the system after setting it"
sed -ie "s;\(${KEYWORD}=\)\(\".*\)\(\"\);\1\2 ${OPTION}=${SETVAL}\3;" $FILE
sed -i "s;\(${KEYWORD}=\)\(\".*\)\(\"\);\1\2 ${OPTION}=${SETVAL}\3;" $FILE
/usr/sbin/update-grub2
elif [ $FNRET = 3 ]; then
warn "Parameter $OPTION is present but with the wrong value -- Fixing, need to reboot the system after setting it"
sed -ie "s/${OPTION}=./${OPTION}=${SETVAL}/" $FILE
sed -i "s/${OPTION}=./${OPTION}=${SETVAL}/" $FILE
/usr/sbin/update-grub2
fi
}

View File

@ -382,6 +382,7 @@ add_option_to_systemd() {
#debug "Sed command : sed -ie "s;\(^Options.*=mode=[1,2,4,7][1,2,4,7][1,2,4,7][1,2,4,7].*\);\1,$OPTION;\" $SERVICEPATH"
sed -ie "s;\(^Options.*=mode=[1,2,4,7][1,2,4,7][1,2,4,7][1,2,4,7].*\);\1,$OPTION;" $SERVICEPATH
systemctl daemon-reload
systemctl start $SERVICENAME
}
remount_partition_by_systemd() {