mirror of
https://github.com/ovh/debian-cis.git
synced 2025-06-23 02:54:35 +02:00
3.1_bootloader_ownership.sh
This commit is contained in:
49
lib/utils.sh
49
lib/utils.sh
@ -1,5 +1,54 @@
|
||||
# CIS Debian 7 Hardening Utility functions
|
||||
|
||||
#
|
||||
# File manipulation
|
||||
#
|
||||
|
||||
does_file_exist() {
|
||||
local FILE=$1
|
||||
if [ -e $FILE ]; then
|
||||
FNRET=0
|
||||
else
|
||||
FNRET=1
|
||||
fi
|
||||
}
|
||||
|
||||
has_file_correct_ownership() {
|
||||
local FILE=$1
|
||||
local USER=$2
|
||||
local GROUP=$3
|
||||
local USERID=$(id -u $USER)
|
||||
local GROUPID=$(id -u $GROUP)
|
||||
|
||||
if [ "$(stat -c "%u %g" /boot/grub/grub.cfg)" = "$USERID $GROUPID" ]; then
|
||||
FNRET=0
|
||||
else
|
||||
FNRET=1
|
||||
fi
|
||||
}
|
||||
|
||||
#
|
||||
# User manipulation
|
||||
#
|
||||
|
||||
does_user_exist() {
|
||||
local USER=$1
|
||||
if $(getent passwd $USER >/dev/null 2>&1); then
|
||||
FNRET=0
|
||||
else
|
||||
FNRET=1
|
||||
fi
|
||||
}
|
||||
|
||||
does_group_exist() {
|
||||
local GROUP=$1
|
||||
if $(getent group $GROUP >/dev/null 2>&1); then
|
||||
FNRET=0
|
||||
else
|
||||
FNRET=1
|
||||
fi
|
||||
}
|
||||
|
||||
#
|
||||
# Service Boot Checks
|
||||
#
|
||||
|
Reference in New Issue
Block a user