mirror of
https://github.com/hardenedlinux/harbian-audit.git
synced 2025-07-28 16:14:42 +02:00
Add check ownership methods for 9.3.23
This commit is contained in:
parent
977b32a801
commit
9c93e6955a
@ -14,25 +14,38 @@ set -u # One variable unset, it's over
|
|||||||
|
|
||||||
HARDENING_LEVEL=2
|
HARDENING_LEVEL=2
|
||||||
|
|
||||||
|
USER='root'
|
||||||
|
GROUP='root'
|
||||||
|
PERMISSIONS='0644'
|
||||||
|
|
||||||
|
|
||||||
# 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 () {
|
||||||
|
if [ $(find /etc/ssh/ -name "*ssh_host*key" ! -uid 0 -o ! -gid 0 | wc -l) -gt 0 ]; then
|
||||||
|
crit "There are file ownership was not set to $USER:$GROUP"
|
||||||
|
else
|
||||||
|
ok "There are file has correct ownership"
|
||||||
|
fi
|
||||||
if [ $(find /etc/ssh/ -name "*.pub" -perm /133 | wc -l) -gt 0 ]; then
|
if [ $(find /etc/ssh/ -name "*.pub" -perm /133 | wc -l) -gt 0 ]; then
|
||||||
crit "There are file file has a mode more permissive than "0644""
|
crit "There are file file has a mode more permissive than $PERMISSIONS"
|
||||||
FNRET=1
|
|
||||||
else
|
else
|
||||||
ok "Not any file has a mode more permissive than "0644""
|
ok "Not any file has a mode more permissive than $PERMISSIONS"
|
||||||
FNRET=0
|
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
# This function will be called if the script status is on enabled mode
|
# This function will be called if the script status is on enabled mode
|
||||||
apply () {
|
apply () {
|
||||||
if [ $FNRET = 0 ]; then
|
if [ $(find /etc/ssh/ -name "*ssh_host*key" ! -uid 0 -o ! -gid 0 | wc -l) -gt 0 ]; then
|
||||||
ok "any file has a mode more permissive than "0644""
|
warn "There are file ownership was not set to $USER:$GROUP"
|
||||||
|
find /etc/ssh/ -name "*ssh_host*key" ! -uid 0 -o ! -gid 0 -exec chown $USER:$GROUP {} \;
|
||||||
|
else
|
||||||
|
ok "There are file has correct ownership"
|
||||||
|
fi
|
||||||
|
if [ $(find /etc/ssh/ -name "*.pub" -perm /133 | wc -l) -gt 0 ]; then
|
||||||
|
warn "Set ssh public host key permission to $PERMISSIONS"
|
||||||
|
find /etc/ssh/ -name "*.pub" -perm /133 -exec chmod $PERMISSIONS {} \;
|
||||||
else
|
else
|
||||||
warn "Set ssh public host key permission to 0644"
|
ok "Any file has a mode more permissive than $PERMISSIONS"
|
||||||
find /etc/ssh/ -name "*.pub" -perm /133 -exec chmod 0644 {} \;
|
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user