evocheck : update (version 19.09) from upstream

This commit is contained in:
Jérémy Lecour 2019-09-22 22:41:03 +02:00
parent b31159c9d2
commit 1a647d0546
2 changed files with 237 additions and 153 deletions

View file

@ -15,6 +15,7 @@ The **patch** part changes incrementally at each release.
### Changed ### Changed
* elasticsearch: listen on local interface only by default * elasticsearch: listen on local interface only by default
* evocheck : update (version 19.09) from upstream
* evolinux-base: use "evolinux_internal_group" for SSH authentication * evolinux-base: use "evolinux_internal_group" for SSH authentication
* squid: split systemd tasks into own file * squid: split systemd tasks into own file

View file

@ -59,6 +59,7 @@ detect_os() {
7) DEBIAN_RELEASE="wheezy";; 7) DEBIAN_RELEASE="wheezy";;
8) DEBIAN_RELEASE="jessie";; 8) DEBIAN_RELEASE="jessie";;
9) DEBIAN_RELEASE="stretch";; 9) DEBIAN_RELEASE="stretch";;
10) DEBIAN_RELEASE="buster";;
esac esac
fi fi
elif [ "$(uname -s)" = "OpenBSD" ]; then elif [ "$(uname -s)" = "OpenBSD" ]; then
@ -85,6 +86,9 @@ is_debian_jessie() {
is_debian_stretch() { is_debian_stretch() {
test "${DEBIAN_RELEASE}" = "stretch" test "${DEBIAN_RELEASE}" = "stretch"
} }
is_debian_buster() {
test "${DEBIAN_RELEASE}" = "buster"
}
debian_release() { debian_release() {
printf "%s" "${DEBIAN_RELEASE}" printf "%s" "${DEBIAN_RELEASE}"
} }
@ -159,7 +163,7 @@ check_dpkgwarning() {
test -e /etc/apt/apt.conf \ test -e /etc/apt/apt.conf \
&& failed "IS_DPKGWARNING" "/etc/apt/apt.conf is missing" && failed "IS_DPKGWARNING" "/etc/apt/apt.conf is missing"
fi fi
elif is_debian_stretch; then elif is_debian_stretch || is_debian_buster; then
test -e /etc/apt/apt.conf.d/z-evolinux.conf \ test -e /etc/apt/apt.conf.d/z-evolinux.conf \
|| failed "IS_DPKGWARNING" "/etc/apt/apt.conf.d/z-evolinux.conf is missing" || failed "IS_DPKGWARNING" "/etc/apt/apt.conf.d/z-evolinux.conf is missing"
fi fi
@ -196,7 +200,7 @@ check_modsecurity() {
fi fi
} }
check_customsudoers() { check_customsudoers() {
grep -E -qr "umask=0077" /etc/sudoers* || failed "IS_CUSTOMSUDOERS" grep -E -qr "umask=0077" /etc/sudoers* || failed "IS_CUSTOMSUDOERS" "missing umask=0077 in sudoers file"
} }
check_vartmpfs() { check_vartmpfs() {
df /var/tmp | grep -q tmpfs || failed "IS_VARTMPFS" "/var/tmp is not a tmpfs" df /var/tmp | grep -q tmpfs || failed "IS_VARTMPFS" "/var/tmp is not a tmpfs"
@ -208,29 +212,30 @@ check_serveurbase() {
is_installed serveur-base || failed "IS_SERVEURBASE" "serveur-base package is not installed" is_installed serveur-base || failed "IS_SERVEURBASE" "serveur-base package is not installed"
} }
check_logrotateconf() { check_logrotateconf() {
test -e /etc/logrotate.d/zsyslog || failed "IS_LOGROTATECONF" test -e /etc/logrotate.d/zsyslog || failed "IS_LOGROTATECONF" "missing zsyslog in logrotate.d"
} }
check_syslogconf() { check_syslogconf() {
grep -q "^# Syslog for Pack Evolix serveur" /etc/*syslog.conf \ grep -q "^# Syslog for Pack Evolix serveur" /etc/*syslog.conf \
|| failed "IS_SYSLOGCONF" || failed "IS_SYSLOGCONF" "syslog evolix config file missing"
} }
check_debiansecurity() { check_debiansecurity() {
grep -q "^deb.*security" /etc/apt/sources.list \ grep -q "^deb.*security" /etc/apt/sources.list \
|| failed "IS_DEBIANSECURITY" || failed "IS_DEBIANSECURITY" "missing debian security repository"
} }
check_aptitudeonly() { check_aptitudeonly() {
if is_debian_squeeze || is_debian_wheezy; then if is_debian_squeeze || is_debian_wheezy; then
test -e /usr/bin/apt-get && failed "IS_APTITUDEONLY" test -e /usr/bin/apt-get && failed "IS_APTITUDEONLY" \
"only aptitude may be enabled on Debian <=7, apt-get should be disabled"
fi fi
} }
check_aptitude() { check_aptitude() {
if is_debian_jessie || is_debian_stretch; then if is_debian_jessie || is_debian_stretch || is_debian_buster; then
test -e /usr/bin/aptitude && failed "IS_APTITUDE" test -e /usr/bin/aptitude && failed "IS_APTITUDE" "aptitude may not be installed on Debian >=8"
fi fi
} }
check_aptgetbak() { check_aptgetbak() {
if is_debian_jessie || is_debian_stretch; then if is_debian_jessie || is_debian_stretch || is_debian_buster; then
test -e /usr/bin/apt-get.bak && failed "IS_APTGETBAK" test -e /usr/bin/apt-get.bak && failed "IS_APTGETBAK" "missing dpkg-divert apt-get.bak"
fi fi
} }
check_apticron() { check_apticron() {
@ -240,28 +245,29 @@ check_apticron() {
test "$status" = "fail" || test -e /usr/bin/apt-get.bak || status="fail" test "$status" = "fail" || test -e /usr/bin/apt-get.bak || status="fail"
if is_debian_squeeze || is_debian_wheezy; then if is_debian_squeeze || is_debian_wheezy; then
test "$status" = "fail" && failed "IS_APTICRON" test "$status" = "fail" && failed "IS_APTICRON" "apticron must be in cron.d not cron.daily"
fi fi
} }
check_usrro() { check_usrro() {
grep /usr /etc/fstab | grep -q ro || failed "IS_USRRO" grep /usr /etc/fstab | grep -q ro || failed "IS_USRRO" "missing ro directive on fstab for /usr"
} }
check_tmpnoexec() { check_tmpnoexec() {
mount | grep "on /tmp" | grep -q noexec || failed "IS_TMPNOEXEC" mount | grep "on /tmp" | grep -q noexec || failed "IS_TMPNOEXEC" "/tmp is mounted with exec, should be noexec"
} }
check_mountfstab() { check_mountfstab() {
# Test if lsblk available, if not skip this test... # Test if lsblk available, if not skip this test...
LSBLK_BIN=$(command -v lsblk) LSBLK_BIN=$(command -v lsblk)
if test -x "${LSBLK_BIN}"; then if test -x "${LSBLK_BIN}"; then
for mountPoint in $(${LSBLK_BIN} -o MOUNTPOINT -l -n | grep '/'); do for mountPoint in $(${LSBLK_BIN} -o MOUNTPOINT -l -n | grep '/'); do
grep -Eq "$mountPoint\W" /etc/fstab || failed "IS_MOUNT_FSTAB" grep -Eq "$mountPoint\W" /etc/fstab \
|| failed "IS_MOUNT_FSTAB" "partition(s) detected mounted but no presence in fstab"
done done
fi fi
} }
check_listchangesconf() { check_listchangesconf() {
if is_debian_stretch; then if is_debian_stretch || is_debian_buster; then
if is_installed apt-listchanges; then if is_installed apt-listchanges; then
failed "IS_LISTCHANGESCONF" "apt-listchanges must not be installed on Stretch" failed "IS_LISTCHANGESCONF" "apt-listchanges must not be installed on Debian >=9"
fi fi
else else
if [ -e "/etc/apt/listchanges.conf" ]; then if [ -e "/etc/apt/listchanges.conf" ]; then
@ -276,72 +282,86 @@ check_listchangesconf() {
} }
check_customcrontab() { check_customcrontab() {
found_lines=$(grep -c -E "^(17 \*|25 6|47 6|52 6)" /etc/crontab) found_lines=$(grep -c -E "^(17 \*|25 6|47 6|52 6)" /etc/crontab)
test "$found_lines" = 4 && failed "IS_CUSTOMCRONTAB" test "$found_lines" = 4 && failed "IS_CUSTOMCRONTAB" "missing custom field in crontab"
} }
check_sshallowusers() { check_sshallowusers() {
grep -E -qi "(AllowUsers|AllowGroups)" /etc/ssh/sshd_config || failed "IS_SSHALLOWUSERS" grep -E -qi "(AllowUsers|AllowGroups)" /etc/ssh/sshd_config \
|| failed "IS_SSHALLOWUSERS" "missing AllowUsers or AllowGroups directive in sshd_config"
} }
check_diskperf() { check_diskperf() {
test -e /root/disk-perf.txt || failed "IS_DISKPERF" perfFile="/root/disk-perf.txt"
test -e $perfFile || failed "IS_DISKPERF" "missing ${perfFile}"
} }
check_tmoutprofile() { check_tmoutprofile() {
grep -sq "TMOUT=" /etc/profile /etc/profile.d/evolinux.sh || failed "IS_TMOUTPROFILE" "TMOUT is not set" grep -sq "TMOUT=" /etc/profile /etc/profile.d/evolinux.sh || failed "IS_TMOUTPROFILE" "TMOUT is not set"
} }
check_alert5boot() { check_alert5boot() {
if [ -n "$(find /etc/rc2.d/ -name 'S*alert5')" ]; then if is_debian_buster; then
grep -q "^date" /etc/rc2.d/S*alert5 || failed "IS_ALERT5BOOT" "boot mail is not sent by alert5 init script" grep -qs "^date" /usr/share/scripts/alert5.sh || failed "IS_ALERT5BOOT" "boot mail is not sent by alert5 init script"
test -f /etc/systemd/system/alert5.service || failed "IS_ALERT5BOOT" "alert5 unit file is missing"
systemctl is-enabled alert5 -q || failed "IS_ALERT5BOOT" "alert5 unit is not enabled"
else else
failed "IS_ALERT5BOOT" "alert5 init script is missing" if [ -n "$(find /etc/rc2.d/ -name 'S*alert5')" ]; then
grep -q "^date" /etc/rc2.d/S*alert5 || failed "IS_ALERT5BOOT" "boot mail is not sent by alert5 init script"
else
failed "IS_ALERT5BOOT" "alert5 init script is missing"
fi
fi fi
} }
check_alert5minifw() { check_alert5minifw() {
if [ -n "$(find /etc/rc2.d/ -name 'S*alert5')" ]; then if is_debian_buster; then
grep -q "^/etc/init.d/minifirewall" /etc/rc2.d/S*alert5 \ grep -qs "^/etc/init.d/minifirewall" /usr/share/scripts/alert5.sh \
|| failed "IS_ALERT5MINIFW" "Minifirewall is not started by alert5 init script" || failed "IS_ALERT5MINIFW" "Minifirewall is not started by alert5 script or script is missing"
else else
failed "IS_ALERT5MINIFW" "alert5 init script is missing" if [ -n "$(find /etc/rc2.d/ -name 'S*alert5')" ]; then
grep -q "^/etc/init.d/minifirewall" /etc/rc2.d/S*alert5 \
|| failed "IS_ALERT5MINIFW" "Minifirewall is not started by alert5 init script"
else
failed "IS_ALERT5MINIFW" "alert5 init script is missing"
fi
fi fi
} }
check_minifw() { check_minifw() {
/sbin/iptables -L -n | grep -q -E "^ACCEPT\s*all\s*--\s*31\.170\.8\.4\s*0\.0\.0\.0/0\s*$" \ /sbin/iptables -L -n | grep -q -E "^ACCEPT\s*all\s*--\s*31\.170\.8\.4\s*0\.0\.0\.0/0\s*$" \
|| failed "IS_MINIFW" || failed "IS_MINIFW" "minifirewall seems not starded"
} }
check_nrpeperms() { check_nrpeperms() {
if [ -d /etc/nagios ]; then if [ -d /etc/nagios ]; then
actual=$(stat --format "%a" /etc/nagios) nagiosDir="/etc/nagios"
actual=$(stat --format "%a" $nagiosDir)
expected="750" expected="750"
test "$expected" = "$actual" || failed "IS_NRPEPERMS" test "$expected" = "$actual" || failed "IS_NRPEPERMS" "${nagiosDir} must be ${expected}"
fi fi
} }
check_minifwperms() { check_minifwperms() {
if [ -f "$MINIFW_FILE" ]; then if [ -f "$MINIFW_FILE" ]; then
actual=$(stat --format "%a" "$MINIFW_FILE") actual=$(stat --format "%a" "$MINIFW_FILE")
expected="600" expected="600"
test "$expected" = "$actual" || failed "IS_MINIFWPERMS" test "$expected" = "$actual" || failed "IS_MINIFWPERMS" "${MINIFW_FILE} must be ${expected}"
fi fi
} }
check_nrpedisks() { check_nrpedisks() {
NRPEDISKS=$(grep command.check_disk /etc/nagios/nrpe.cfg | grep "^command.check_disk[0-9]" | sed -e "s/^command.check_disk\([0-9]\+\).*/\1/" | sort -n | tail -1) NRPEDISKS=$(grep command.check_disk /etc/nagios/nrpe.cfg | grep "^command.check_disk[0-9]" | sed -e "s/^command.check_disk\([0-9]\+\).*/\1/" | sort -n | tail -1)
DFDISKS=$(df -Pl | grep -c -E -v "(^Filesystem|/lib/init/rw|/dev/shm|udev|rpc_pipefs)") DFDISKS=$(df -Pl | grep -c -E -v "(^Filesystem|/lib/init/rw|/dev/shm|udev|rpc_pipefs)")
test "$NRPEDISKS" = "$DFDISKS" || failed "IS_NRPEDISKS" test "$NRPEDISKS" = "$DFDISKS" || failed "IS_NRPEDISKS" "there must be $DFDISKS check_disk in nrpe.cfg"
} }
check_nrpepid() { check_nrpepid() {
if ! is_debian_squeeze; then if ! is_debian_squeeze; then
{ test -e /etc/nagios/nrpe.cfg \ { test -e /etc/nagios/nrpe.cfg \
&& grep -q "^pid_file=/var/run/nagios/nrpe.pid" /etc/nagios/nrpe.cfg; && grep -q "^pid_file=/var/run/nagios/nrpe.pid" /etc/nagios/nrpe.cfg;
} || failed "IS_NRPEPID" } || failed "IS_NRPEPID" "missing or wrong pid_file directive in nrpe.cfg"
fi fi
} }
check_grsecprocs() { check_grsecprocs() {
if uname -a | grep -q grsec; then if uname -a | grep -q grsec; then
{ grep -q "^command.check_total_procs..sudo" /etc/nagios/nrpe.cfg \ { grep -q "^command.check_total_procs..sudo" /etc/nagios/nrpe.cfg \
&& grep -A1 "^\[processes\]" /etc/munin/plugin-conf.d/munin-node | grep -q "^user root"; && grep -A1 "^\[processes\]" /etc/munin/plugin-conf.d/munin-node | grep -q "^user root";
} || failed "IS_GRSECPROCS" } || failed "IS_GRSECPROCS" "missing munin's plugin processes directive for grsec"
fi fi
} }
check_apachemunin() { check_apachemunin() {
if test -e /etc/apache2/apache2.conf; then if test -e /etc/apache2/apache2.conf; then
if is_debian_stretch; then if is_debian_stretch || is_debian_buster; then
{ test -h /etc/apache2/mods-enabled/status.load \ { test -h /etc/apache2/mods-enabled/status.load \
&& test -h /etc/munin/plugins/apache_accesses \ && test -h /etc/munin/plugins/apache_accesses \
&& test -h /etc/munin/plugins/apache_processes \ && test -h /etc/munin/plugins/apache_processes \
@ -381,25 +401,26 @@ check_raidsoft() {
{ grep -q "^AUTOCHECK=true" /etc/default/mdadm \ { grep -q "^AUTOCHECK=true" /etc/default/mdadm \
&& grep -q "^START_DAEMON=true" /etc/default/mdadm \ && grep -q "^START_DAEMON=true" /etc/default/mdadm \
&& grep -qv "^MAILADDR ___MAIL___" /etc/mdadm/mdadm.conf; && grep -qv "^MAILADDR ___MAIL___" /etc/mdadm/mdadm.conf;
} || failed "IS_RAIDSOFT" } || failed "IS_RAIDSOFT" "missing or wrong config for mdadm"
fi fi
} }
# Verification du LogFormat de AWStats # Verification du LogFormat de AWStats
check_awstatslogformat() { check_awstatslogformat() {
if is_installed apache2 awstats; then if is_installed apache2 awstats; then
grep -qE '^LogFormat=1' /etc/awstats/awstats.conf.local \ awstatsFile="/etc/awstats/awstats.conf.local"
|| failed "IS_AWSTATSLOGFORMAT" grep -qE '^LogFormat=1' $awstatsFile \
|| failed "IS_AWSTATSLOGFORMAT" "missing or wrong LogFormat directive in $awstatsFile"
fi fi
} }
# Verification de la présence de la config logrotate pour Munin # Verification de la présence de la config logrotate pour Munin
check_muninlogrotate() { check_muninlogrotate() {
{ test -e /etc/logrotate.d/munin-node \ { test -e /etc/logrotate.d/munin-node \
&& test -e /etc/logrotate.d/munin; && test -e /etc/logrotate.d/munin;
} || failed "IS_MUNINLOGROTATE" } || failed "IS_MUNINLOGROTATE" "missing lorotate file for munin"
} }
# Verification de l'activation de Squid dans le cas d'un pack mail # Verification de l'activation de Squid dans le cas d'un pack mail
check_squid() { check_squid() {
if is_debian_stretch; then if is_debian_stretch || is_debian_buster; then
squidconffile="/etc/squid/evolinux-custom.conf" squidconffile="/etc/squid/evolinux-custom.conf"
else else
squidconffile="/etc/squid*/squid.conf" squidconffile="/etc/squid*/squid.conf"
@ -407,19 +428,19 @@ check_squid() {
if is_pack_web && (is_installed squid || is_installed squid3); then if is_pack_web && (is_installed squid || is_installed squid3); then
host=$(hostname -i) host=$(hostname -i)
# shellcheck disable=SC2086 # shellcheck disable=SC2086
http_port=$(grep "http_port" $squidconffile | cut -f 2 -d " ") http_port=$(grep -E "^http_port\s+[0-9]+" $squidconffile | awk '{ print $2 }')
{ grep -qE "^[^#]*iptables -t nat -A OUTPUT -p tcp --dport 80 -m owner --uid-owner proxy -j ACCEPT" "$MINIFW_FILE" \ { grep -qE "^[^#]*iptables -t nat -A OUTPUT -p tcp --dport 80 -m owner --uid-owner proxy -j ACCEPT" "$MINIFW_FILE" \
&& grep -qE "^[^#]*iptables -t nat -A OUTPUT -p tcp --dport 80 -d $host -j ACCEPT" "$MINIFW_FILE" \ && grep -qE "^[^#]*iptables -t nat -A OUTPUT -p tcp --dport 80 -d $host -j ACCEPT" "$MINIFW_FILE" \
&& grep -qE "^[^#]*iptables -t nat -A OUTPUT -p tcp --dport 80 -d 127.0.0.(1|0/8) -j ACCEPT" "$MINIFW_FILE" \ && grep -qE "^[^#]*iptables -t nat -A OUTPUT -p tcp --dport 80 -d 127.0.0.(1|0/8) -j ACCEPT" "$MINIFW_FILE" \
&& grep -qE "^[^#]*iptables -t nat -A OUTPUT -p tcp --dport 80 -j REDIRECT --to-port.* $http_port" "$MINIFW_FILE"; && grep -qE "^[^#]*iptables -t nat -A OUTPUT -p tcp --dport 80 -j REDIRECT --to-port.* $http_port" "$MINIFW_FILE";
} || failed "IS_SQUID" } || failed "IS_SQUID" "missing squid rules in minifirewall"
fi fi
} }
check_evomaintenance_fw() { check_evomaintenance_fw() {
if [ -f "$MINIFW_FILE" ]; then if [ -f "$MINIFW_FILE" ]; then
rulesNumber=$(grep -c "/sbin/iptables -A INPUT -p tcp --sport 5432 --dport 1024:65535 -s .* -m state --state ESTABLISHED,RELATED -j ACCEPT" "$MINIFW_FILE") rulesNumber=$(grep -c "/sbin/iptables -A INPUT -p tcp --sport 5432 --dport 1024:65535 -s .* -m state --state ESTABLISHED,RELATED -j ACCEPT" "$MINIFW_FILE")
if [ "$rulesNumber" -lt 2 ]; then if [ "$rulesNumber" -lt 2 ]; then
failed "IS_EVOMAINTENANCE_FW" failed "IS_EVOMAINTENANCE_FW" "missing evomaintenance rules in minifirewall"
fi fi
fi fi
} }
@ -430,36 +451,36 @@ check_moddeflate() {
{ test -e $f && grep -q "AddOutputFilterByType DEFLATE text/html text/plain text/xml" $f \ { test -e $f && grep -q "AddOutputFilterByType DEFLATE text/html text/plain text/xml" $f \
&& grep -q "AddOutputFilterByType DEFLATE text/css" $f \ && grep -q "AddOutputFilterByType DEFLATE text/css" $f \
&& grep -q "AddOutputFilterByType DEFLATE application/x-javascript application/javascript" $f; && grep -q "AddOutputFilterByType DEFLATE application/x-javascript application/javascript" $f;
} || failed "IS_MODDEFLATE" } || failed "IS_MODDEFLATE" "missing AddOutputFilterByType directive for apache mod deflate"
fi fi
} }
# Verification de la conf log2mail # Verification de la conf log2mail
check_log2mailrunning() { check_log2mailrunning() {
if is_pack_web && is_installed log2mail; then if is_pack_web && is_installed log2mail; then
pgrep log2mail >/dev/null || failed 'IS_LOG2MAILRUNNING' pgrep log2mail >/dev/null || failed "IS_LOG2MAILRUNNING" "log2mail is not running"
fi fi
} }
check_log2mailapache() { check_log2mailapache() {
if is_debian_stretch; then if is_debian_stretch || is_debian_buster; then
conf=/etc/log2mail/config/apache conf=/etc/log2mail/config/apache
else else
conf=/etc/log2mail/config/default conf=/etc/log2mail/config/default
fi fi
if is_pack_web && is_installed log2mail; then if is_pack_web && is_installed log2mail; then
grep -s -q "^file = /var/log/apache2/error.log" $conf \ grep -s -q "^file = /var/log/apache2/error.log" $conf \
|| failed "IS_LOG2MAILAPACHE" || failed "IS_LOG2MAILAPACHE" "missing log2mail directive for apache"
fi fi
} }
check_log2mailmysql() { check_log2mailmysql() {
if is_pack_web && is_installed log2mail; then if is_pack_web && is_installed log2mail; then
grep -s -q "^file = /var/log/syslog" /etc/log2mail/config/{default,mysql,mysql.conf} \ grep -s -q "^file = /var/log/syslog" /etc/log2mail/config/{default,mysql,mysql.conf} \
|| failed "IS_LOG2MAILMYSQL" || failed "IS_LOG2MAILMYSQL" "missing log2mail directive for mysql"
fi fi
} }
check_log2mailsquid() { check_log2mailsquid() {
if is_pack_web && is_installed log2mail; then if is_pack_web && is_installed log2mail; then
grep -s -q "^file = /var/log/squid.*/access.log" /etc/log2mail/config/* \ grep -s -q "^file = /var/log/squid.*/access.log" /etc/log2mail/config/* \
|| failed "IS_LOG2MAILSQUID" || failed "IS_LOG2MAILSQUID" "missing log2mail directive for squid"
fi fi
} }
# Verification si bind est chroote # Verification si bind est chroote
@ -470,7 +491,7 @@ check_bindchroot() {
md5_original=$(md5sum /usr/sbin/named | cut -f 1 -d ' ') md5_original=$(md5sum /usr/sbin/named | cut -f 1 -d ' ')
md5_chrooted=$(md5sum /var/chroot-bind/usr/sbin/named | cut -f 1 -d ' ') md5_chrooted=$(md5sum /var/chroot-bind/usr/sbin/named | cut -f 1 -d ' ')
if [ "$md5_original" != "$md5_chrooted" ]; then if [ "$md5_original" != "$md5_chrooted" ]; then
failed "IS_BINDCHROOT" "The chrooted bind binary is differet than the original binary" failed "IS_BINDCHROOT" "the chrooted bind binary is different than the original binary"
fi fi
else else
failed "IS_BINDCHROOT" "bind process is not chrooted" failed "IS_BINDCHROOT" "bind process is not chrooted"
@ -482,11 +503,11 @@ check_bindchroot() {
check_repvolatile() { check_repvolatile() {
if is_debian_lenny; then if is_debian_lenny; then
grep -qE "^deb http://volatile.debian.org/debian-volatile" /etc/apt/sources.list \ grep -qE "^deb http://volatile.debian.org/debian-volatile" /etc/apt/sources.list \
|| failed "IS_REPVOLATILE" || failed "IS_REPVOLATILE" "missing debian-volatile repository"
fi fi
if is_debian_squeeze; then if is_debian_squeeze; then
grep -qE "^deb.*squeeze-updates" /etc/apt/sources.list \ grep -qE "^deb.*squeeze-updates" /etc/apt/sources.list \
|| failed "IS_REPVOLATILE" || failed "IS_REPVOLATILE" "missing squeeze-updates repository"
fi fi
} }
# /etc/network/interfaces should be present, we don't manage systemd-network yet # /etc/network/interfaces should be present, we don't manage systemd-network yet
@ -499,7 +520,7 @@ check_network_interfaces() {
} }
# Verify if all if are in auto # Verify if all if are in auto
check_autoif() { check_autoif() {
if is_debian_stretch; then if is_debian_stretch || is_debian_buster; then
interfaces=$(/sbin/ip address show up | grep "^[0-9]*:" | grep -E -v "(lo|vnet|docker|veth|tun|tap|macvtap)" | cut -d " " -f 2 | tr -d : | cut -d@ -f1 | tr "\n" " ") interfaces=$(/sbin/ip address show up | grep "^[0-9]*:" | grep -E -v "(lo|vnet|docker|veth|tun|tap|macvtap)" | cut -d " " -f 2 | tr -d : | cut -d@ -f1 | tr "\n" " ")
else else
interfaces=$(/sbin/ifconfig -s | tail -n +2 | grep -E -v "^(lo|vnet|docker|veth|tun|tap|macvtap)" | cut -d " " -f 1 |tr "\n" " ") interfaces=$(/sbin/ifconfig -s | tail -n +2 | grep -E -v "^(lo|vnet|docker|veth|tun|tap|macvtap)" | cut -d " " -f 1 |tr "\n" " ")
@ -521,18 +542,19 @@ check_interfacesgw() {
# Verification de la mise en place d'evobackup # Verification de la mise en place d'evobackup
check_evobackup() { check_evobackup() {
evobackup_found=$(find /etc/cron* -name '*evobackup*' | wc -l) evobackup_found=$(find /etc/cron* -name '*evobackup*' | wc -l)
test "$evobackup_found" -gt 0 || failed "IS_EVOBACKUP" test "$evobackup_found" -gt 0 || failed "IS_EVOBACKUP" "missing evobackup cron"
} }
# Verification de la presence du userlogrotate # Verification de la presence du userlogrotate
check_userlogrotate() { check_userlogrotate() {
if is_pack_web; then if is_pack_web; then
test -x /etc/cron.weekly/userlogrotate || failed "IS_USERLOGROTATE" test -x /etc/cron.weekly/userlogrotate || failed "IS_USERLOGROTATE" "missing userlogrotate cron"
fi fi
} }
# Verification de la syntaxe de la conf d'Apache # Verification de la syntaxe de la conf d'Apache
check_apachectl() { check_apachectl() {
if is_installed apache2; then if is_installed apache2; then
/usr/sbin/apache2ctl configtest 2>&1 | grep -q "^Syntax OK$" || failed "IS_APACHECTL" /usr/sbin/apache2ctl configtest 2>&1 | grep -q "^Syntax OK$" \
|| failed "IS_APACHECTL" "apache errors detected, run a configtest"
fi fi
} }
# Check if there is regular files in Apache sites-enabled. # Check if there is regular files in Apache sites-enabled.
@ -559,7 +581,7 @@ check_apacheipinallow() {
| grep -iv "from all" \ | grep -iv "from all" \
| grep -iv "env=" \ | grep -iv "env=" \
| perl -ne 'exit 1 unless (/from( [\da-f:.\/]+)+$/i)' \ | perl -ne 'exit 1 unless (/from( [\da-f:.\/]+)+$/i)' \
|| failed "IS_APACHEIPINALLOW" || failed "IS_APACHEIPINALLOW" "bad (Allow|Deny) directives in apache"
fi fi
} }
# Check if default Apache configuration file for munin is absent (or empty or commented). # Check if default Apache configuration file for munin is absent (or empty or commented).
@ -570,7 +592,8 @@ check_muninapacheconf() {
muninconf="/etc/apache2/conf-available/munin.conf" muninconf="/etc/apache2/conf-available/munin.conf"
fi fi
if is_installed apache2; then if is_installed apache2; then
test -e $muninconf && grep -vEq "^( |\t)*#" "$muninconf" && failed "IS_MUNINAPACHECONF" test -e $muninconf && grep -vEq "^( |\t)*#" "$muninconf" \
&& failed "IS_MUNINAPACHECONF" "default munin configuration may be commented or disabled"
fi fi
} }
# Verification de la priorité du package samba si les backports sont utilisés # Verification de la priorité du package samba si les backports sont utilisés
@ -578,7 +601,7 @@ check_sambainpriority() {
if is_debian_lenny && is_pack_samba; then if is_debian_lenny && is_pack_samba; then
if grep -qrE "^[^#].*backport" /etc/apt/sources.list{,.d}; then if grep -qrE "^[^#].*backport" /etc/apt/sources.list{,.d}; then
priority=$(grep -E -A2 "^Package:.*samba" /etc/apt/preferences | grep -A1 "^Pin: release a=lenny-backports" | grep "^Pin-Priority:" | cut -f2 -d" ") priority=$(grep -E -A2 "^Package:.*samba" /etc/apt/preferences | grep -A1 "^Pin: release a=lenny-backports" | grep "^Pin-Priority:" | cut -f2 -d" ")
test "$priority" -gt 500 || failed "IS_SAMBAPINPRIORITY" test "$priority" -gt 500 || failed "IS_SAMBAPINPRIORITY" "bad pinning priority for samba"
fi fi
fi fi
} }
@ -589,7 +612,7 @@ check_kerneluptodate() {
kernel_installed_at=$(date -d "$(ls --full-time -lcrt /boot | tail -n1 | awk '{print $6}')" +%s) kernel_installed_at=$(date -d "$(ls --full-time -lcrt /boot | tail -n1 | awk '{print $6}')" +%s)
last_reboot_at=$(($(date +%s) - $(cut -f1 -d '.' /proc/uptime))) last_reboot_at=$(($(date +%s) - $(cut -f1 -d '.' /proc/uptime)))
if [ "$kernel_installed_at" -gt "$last_reboot_at" ]; then if [ "$kernel_installed_at" -gt "$last_reboot_at" ]; then
failed "IS_KERNELUPTODATE" failed "IS_KERNELUPTODATE" "machine is running an outdated kernel, reboot advised"
fi fi
fi fi
} }
@ -599,7 +622,7 @@ check_uptime() {
limit=$(date -d "now - 2 year" +%s) limit=$(date -d "now - 2 year" +%s)
last_reboot_at=$(($(date +%s) - $(cut -f1 -d '.' /proc/uptime))) last_reboot_at=$(($(date +%s) - $(cut -f1 -d '.' /proc/uptime)))
if [ "$limit" -gt "$last_reboot_at" ]; then if [ "$limit" -gt "$last_reboot_at" ]; then
failed "IS_UPTIME" failed "IS_UPTIME" "machine has an uptime of more thant 2 years, reboot on new kernel advised"
fi fi
fi fi
} }
@ -648,14 +671,17 @@ check_backupuptodate() {
fi fi
} }
check_etcgit() { check_etcgit() {
(cd /etc; git rev-parse --is-inside-work-tree > /dev/null 2>&1) || failed "IS_ETCGIT" "/etc is not a Git repository" export GIT_DIR="/etc/.git" GIT_WORK_TREE="/etc"
git rev-parse --is-inside-work-tree > /dev/null 2>&1 \
|| failed "IS_ETCGIT" "/etc is not a git repository"
} }
# Check if /etc/.git/ has read/write permissions for root only. # Check if /etc/.git/ has read/write permissions for root only.
check_gitperms() { check_gitperms() {
if test -d /etc/.git; then GIT_DIR="/etc/.git"
if test -d $GIT_DIR; then
expected="700" expected="700"
actual=$(stat -c "%a" /etc/.git/) actual=$(stat -c "%a" $GIT_DIR)
[ "$expected" = "$actual" ] || failed "IS_GITPERMS" [ "$expected" = "$actual" ] || failed "IS_GITPERMS" "$GIT_DIR must be $expected"
fi fi
} }
# Check if no package has been upgraded since $limit. # Check if no package has been upgraded since $limit.
@ -712,15 +738,15 @@ check_tune2fs_m5() {
done done
} }
check_evolinuxsudogroup() { check_evolinuxsudogroup() {
if is_debian_stretch; then if is_debian_stretch || is_debian_buster; then
if grep -q "^evolinux-sudo:" /etc/group; then if grep -q "^evolinux-sudo:" /etc/group; then
grep -q '^%evolinux-sudo ALL=(ALL:ALL) ALL' /etc/sudoers.d/evolinux \ grep -q '^%evolinux-sudo ALL=(ALL:ALL) ALL' /etc/sudoers.d/evolinux \
|| failed "IS_EVOLINUXSUDOGROUP" || failed "IS_EVOLINUXSUDOGROUP" "missing evolinux-sudo directive in sudoers file"
fi fi
fi fi
} }
check_userinadmgroup() { check_userinadmgroup() {
if is_debian_stretch; then if is_debian_stretch || is_debian_buster; then
users=$(grep "^evolinux-sudo:" /etc/group | awk -F: '{print $4}' | tr ',' ' ') users=$(grep "^evolinux-sudo:" /etc/group | awk -F: '{print $4}' | tr ',' ' ')
for user in $users; do for user in $users; do
if ! groups "$user" | grep -q adm; then if ! groups "$user" | grep -q adm; then
@ -731,15 +757,17 @@ check_userinadmgroup() {
fi fi
} }
check_apache2evolinuxconf() { check_apache2evolinuxconf() {
if is_debian_stretch && test -d /etc/apache2; then if is_debian_stretch || is_debian_buster; then
{ test -L /etc/apache2/conf-enabled/z-evolinux-defaults.conf \ if test -d /etc/apache2; then
&& test -L /etc/apache2/conf-enabled/zzz-evolinux-custom.conf \ { test -L /etc/apache2/conf-enabled/z-evolinux-defaults.conf \
&& test -f /etc/apache2/ipaddr_whitelist.conf; && test -L /etc/apache2/conf-enabled/zzz-evolinux-custom.conf \
} || failed "IS_APACHE2EVOLINUXCONF" && test -f /etc/apache2/ipaddr_whitelist.conf;
} || failed "IS_APACHE2EVOLINUXCONF" "missing custom evolinux apache config"
fi
fi fi
} }
check_backportsconf() { check_backportsconf() {
if is_debian_stretch; then if is_debian_stretch || is_debian_buster; then
grep -qsE "^[^#].*backports" /etc/apt/sources.list \ grep -qsE "^[^#].*backports" /etc/apt/sources.list \
&& failed "IS_BACKPORTSCONF" "backports can't be in main sources list" && failed "IS_BACKPORTSCONF" "backports can't be in main sources list"
if grep -qsE "^[^#].*backports" /etc/apt/sources.list.d/*.list; then if grep -qsE "^[^#].*backports" /etc/apt/sources.list.d/*.list; then
@ -749,15 +777,19 @@ check_backportsconf() {
fi fi
} }
check_bind9munin() { check_bind9munin() {
if is_debian_stretch && is_installed bind9; then if is_debian_stretch || is_debian_buster; then
{ test -L /etc/munin/plugins/bind9 \ if is_installed bind9; then
&& test -e /etc/munin/plugin-conf.d/bind9; { test -L /etc/munin/plugins/bind9 \
} || failed "IS_BIND9MUNIN" && test -e /etc/munin/plugin-conf.d/bind9;
} || failed "IS_BIND9MUNIN" "missing bind plugin for munin"
fi
fi fi
} }
check_bind9logrotate() { check_bind9logrotate() {
if is_debian_stretch && is_installed bind9; then if is_debian_stretch || is_debian_buster; then
test -e /etc/logrotate.d/bind9 || failed "IS_BIND9LOGROTATE" if is_installed bind9; then
test -e /etc/logrotate.d/bind9 || failed "IS_BIND9LOGROTATE" "missing bind logrotate file"
fi
fi fi
} }
check_broadcomfirmware() { check_broadcomfirmware() {
@ -766,10 +798,10 @@ check_broadcomfirmware() {
if ${LSPCI_BIN} | grep -q 'NetXtreme II'; then if ${LSPCI_BIN} | grep -q 'NetXtreme II'; then
{ is_installed firmware-bnx2 \ { is_installed firmware-bnx2 \
&& grep -q "^deb http://mirror.evolix.org/debian.* non-free" /etc/apt/sources.list; && grep -q "^deb http://mirror.evolix.org/debian.* non-free" /etc/apt/sources.list;
} || failed "IS_BROADCOMFIRMWARE" } || failed "IS_BROADCOMFIRMWARE" "missing non-free repository"
fi fi
else else
failed "IS_BROADCOMFIRMWARE" "lspci is missing" failed "IS_BROADCOMFIRMWARE" "lspci not found in ${PATH}"
fi fi
} }
check_hardwareraidtool() { check_hardwareraidtool() {
@ -784,28 +816,31 @@ check_hardwareraidtool() {
is_installed cciss-vol-status || failed "IS_HARDWARERAIDTOOL" "cciss-vol-status not installed" is_installed cciss-vol-status || failed "IS_HARDWARERAIDTOOL" "cciss-vol-status not installed"
fi fi
else else
failed "IS_HARDWARERAIDTOOL" "lspci is missing" failed "IS_HARDWARERAIDTOOL" "lspci not found in ${PATH}"
fi fi
} }
check_log2mailsystemdunit() { check_log2mailsystemdunit() {
if is_debian_stretch; then if is_debian_stretch || is_debian_buster; then
{ systemctl -q is-active log2mail.service \ systemctl -q is-active log2mail.service \
&& test -f /etc/systemd/system/log2mail.service \ || failed "IS_LOG2MAILSYSTEMDUNIT" "log2mail unit not running"
&& ! test -f /etc/init.d/log2mail; test -f /etc/systemd/system/log2mail.service \
} || failed "IS_LOG2MAILSYSTEMDUNIT" || failed "IS_LOG2MAILSYSTEMDUNIT" "missing log2mail unit file"
test -f /etc/init.d/log2mail \
&& failed "IS_LOG2MAILSYSTEMDUNIT" "/etc/init.d/log2mail may be deleted (use systemd unit)"
fi fi
} }
check_listupgrade() { check_listupgrade() {
{ test -f /etc/cron.d/listupgrade \ test -f /etc/cron.d/listupgrade \
&& test -x /usr/share/scripts/listupgrade.sh; || failed "IS_LISTUPGRADE" "missing listupgrade cron"
} || failed "IS_LISTUPGRADE" test -x /usr/share/scripts/listupgrade.sh \
|| failed "IS_LISTUPGRADE" "missing listupgrade script or not executable"
} }
check_mariadbevolinuxconf() { check_mariadbevolinuxconf() {
if is_debian_stretch; then if is_debian_stretch || is_debian_buster; then
if is_installed mariadb-server; then if is_installed mariadb-server; then
{ test -f /etc/mysql/mariadb.conf.d/z-evolinux-defaults.cnf \ { test -f /etc/mysql/mariadb.conf.d/z-evolinux-defaults.cnf \
&& test -f /etc/mysql/mariadb.conf.d/zzz-evolinux-custom.cnf; && test -f /etc/mysql/mariadb.conf.d/zzz-evolinux-custom.cnf;
} || failed "IS_MARIADBEVOLINUXCONF" } || failed "IS_MARIADBEVOLINUXCONF" "missing mariadb custom config"
fi fi
fi fi
} }
@ -862,70 +897,85 @@ check_redis_backup() {
check_elastic_backup() { check_elastic_backup() {
if is_installed elasticsearch; then if is_installed elasticsearch; then
# You could change the default path in /etc/evocheck.cf # You could change the default path in /etc/evocheck.cf
ELASTIC_BACKUP_PATH=${ELASTIC_BACKUP_PATH:-"/home/backup/elasticsearch"} ELASTIC_BACKUP_PATH=${ELASTIC_BACKUP_PATH:-"/home/backup-elasticsearch"}
test -d "$ELASTIC_BACKUP_PATH" || failed "IS_ELASTIC_BACKUP" "Elastic snapshot is missing (${ELASTIC_BACKUP_PATH})" test -d "$ELASTIC_BACKUP_PATH" || failed "IS_ELASTIC_BACKUP" "Elastic snapshot is missing (${ELASTIC_BACKUP_PATH})"
fi fi
} }
check_mariadbsystemdunit() { check_mariadbsystemdunit() {
if is_debian_stretch && is_installed mariadb-server; then if is_debian_stretch || is_debian_buster; then
{ systemctl -q is-active mariadb.service \ if is_installed mariadb-server; then
&& test -f /etc/systemd/system/mariadb.service.d/evolinux.conf; if systemctl -q is-active mariadb.service; then
} || failed "IS_MARIADBSYSTEMDUNIT" test -f /etc/systemd/system/mariadb.service.d/evolinux.conf \
|| failed "IS_MARIADBSYSTEMDUNIT" "missing systemd override for mariadb unit"
fi
fi
fi fi
} }
check_mysqlmunin() { check_mysqlmunin() {
if is_debian_stretch && is_installed mariadb-server; then if is_debian_stretch || is_debian_buster; then
for file in mysql_bytes mysql_queries mysql_slowqueries \ if is_installed mariadb-server; then
mysql_threads mysql_connections mysql_files_tables \ for file in mysql_bytes mysql_queries mysql_slowqueries \
mysql_innodb_bpool mysql_innodb_bpool_act mysql_innodb_io \ mysql_threads mysql_connections mysql_files_tables \
mysql_innodb_log mysql_innodb_rows mysql_innodb_semaphores \ mysql_innodb_bpool mysql_innodb_bpool_act mysql_innodb_io \
mysql_myisam_indexes mysql_qcache mysql_qcache_mem \ mysql_innodb_log mysql_innodb_rows mysql_innodb_semaphores \
mysql_sorts mysql_tmp_tables; do mysql_myisam_indexes mysql_qcache mysql_qcache_mem \
mysql_sorts mysql_tmp_tables; do
if [[ ! -L /etc/munin/plugins/$file ]]; then if [[ ! -L /etc/munin/plugins/$file ]]; then
failed "IS_MYSQLMUNIN" "Munin plugin '$file' is missing" failed "IS_MYSQLMUNIN" "missing munin plugin '$file'"
test "${VERBOSE}" = 1 || break test "${VERBOSE}" = 1 || break
fi fi
done done
fi
fi fi
} }
check_mysqlnrpe() { check_mysqlnrpe() {
if is_debian_stretch && is_installed mariadb-server; then if is_debian_stretch || is_debian_buster; then
nagios_file=~nagios/.my.cnf if is_installed mariadb-server; then
nagios_file=~nagios/.my.cnf
if ! test -f ${nagios_file}; then if ! test -f ${nagios_file}; then
failed "IS_MYSQLNRPE" "${nagios_file} is missing" failed "IS_MYSQLNRPE" "${nagios_file} is missing"
elif [ "$(stat -c %U ${nagios_file})" != "nagios" ] \ elif [ "$(stat -c %U ${nagios_file})" != "nagios" ] \
|| [ "$(stat -c %a ${nagios_file})" != "600" ]; then || [ "$(stat -c %a ${nagios_file})" != "600" ]; then
failed "IS_MYSQLNRPE" "${nagios_file} has wrong permissions" failed "IS_MYSQLNRPE" "${nagios_file} has wrong permissions"
else else
grep -q -F "command[check_mysql]=/usr/lib/nagios/plugins/check_mysql" /etc/nagios/nrpe.d/evolix.cfg \ grep -q -F "command[check_mysql]=/usr/lib/nagios/plugins/check_mysql" /etc/nagios/nrpe.d/evolix.cfg \
|| failed "IS_MYSQLNRPE" "check_mysql is missing" || failed "IS_MYSQLNRPE" "check_mysql is missing"
fi
fi fi
fi fi
} }
check_phpevolinuxconf() { check_phpevolinuxconf() {
if is_debian_stretch && is_installed php; then if is_debian_stretch || is_debian_buster; then
{ test -f /etc/php/7.0/cli/conf.d/z-evolinux-defaults.ini \ is_debian_stretch && phpVersion="7.0"
&& test -f /etc/php/7.0/cli/conf.d/zzz-evolinux-custom.ini; is_debian_buster && phpVersion="7.3"
} || failed "IS_PHPEVOLINUXCONF" if is_installed php; then
{ test -f /etc/php/${phpVersion}/cli/conf.d/z-evolinux-defaults.ini \
&& test -f /etc/php/${phpVersion}/cli/conf.d/zzz-evolinux-custom.ini
} || failed "IS_PHPEVOLINUXCONF" "missing php evolinux config"
fi
fi fi
} }
check_squidlogrotate() { check_squidlogrotate() {
if is_debian_stretch && is_installed squid; then if is_debian_stretch || is_debian_buster; then
grep -q monthly /etc/logrotate.d/squid || failed "IS_SQUIDLOGROTATE" if is_installed squid; then
grep -q monthly /etc/logrotate.d/squid \
|| failed "IS_SQUIDLOGROTATE" "missing squid logrotate file"
fi
fi fi
} }
check_squidevolinuxconf() { check_squidevolinuxconf() {
if is_debian_stretch && is_installed squid; then if is_debian_stretch || is_debian_buster; then
{ grep -qs "^CONFIG=/etc/squid/evolinux-defaults.conf$" /etc/default/squid \ if is_installed squid; then
&& test -f /etc/squid/evolinux-defaults.conf \ { grep -qs "^CONFIG=/etc/squid/evolinux-defaults.conf$" /etc/default/squid \
&& test -f /etc/squid/evolinux-whitelist-defaults.conf \ && test -f /etc/squid/evolinux-defaults.conf \
&& test -f /etc/squid/evolinux-whitelist-custom.conf \ && test -f /etc/squid/evolinux-whitelist-defaults.conf \
&& test -f /etc/squid/evolinux-acl.conf \ && test -f /etc/squid/evolinux-whitelist-custom.conf \
&& test -f /etc/squid/evolinux-httpaccess.conf \ && test -f /etc/squid/evolinux-acl.conf \
&& test -f /etc/squid/evolinux-custom.conf; && test -f /etc/squid/evolinux-httpaccess.conf \
} || failed "IS_SQUIDEVOLINUXCONF" && test -f /etc/squid/evolinux-custom.conf;
} || failed "IS_SQUIDEVOLINUXCONF" "missing squid evolinux config"
fi
fi fi
} }
check_duplicate_fs_label() { check_duplicate_fs_label() {
@ -947,11 +997,12 @@ check_duplicate_fs_label() {
fi fi
rm "$tmpFile" rm "$tmpFile"
else else
failed "IS_DUPLICATE_FS_LABEL" "blkid not found" failed "IS_DUPLICATE_FS_LABEL" "blkid not found in ${PATH}"
fi fi
} }
check_evolix_user() { check_evolix_user() {
grep -q "evolix:" /etc/passwd && failed "IS_EVOLIX_USER" grep -q "evolix:" /etc/passwd \
&& failed "IS_EVOLIX_USER" "evolix user should be deleted, used only for install"
} }
check_evoacme_cron() { check_evoacme_cron() {
if [ -f "/usr/local/sbin/evoacme" ]; then if [ -f "/usr/local/sbin/evoacme" ]; then
@ -989,20 +1040,23 @@ check_apache_confenabled() {
# Starting from Jessie and Apache 2.4, /etc/apache2/conf.d/ # Starting from Jessie and Apache 2.4, /etc/apache2/conf.d/
# must be replaced by conf-available/ and config files symlinked # must be replaced by conf-available/ and config files symlinked
# to conf-enabled/ # to conf-enabled/
if is_debian_jessie || is_debian_stretch; then if is_debian_jessie || is_debian_stretch || is_debian_buster; then
if [ -f /etc/apache2/apache2.conf ]; then if [ -f /etc/apache2/apache2.conf ]; then
test -d /etc/apache2/conf.d/ && failed "IS_APACHE_CONFENABLED" test -d /etc/apache2/conf.d/ \
grep -q 'Include conf.d' /etc/apache2/apache2.conf && failed "IS_APACHE_CONFENABLED" && failed "IS_APACHE_CONFENABLED" "apache's conf.d directory must not exists"
grep -q 'Include conf.d' /etc/apache2/apache2.conf \
&& failed "IS_APACHE_CONFENABLED" "apache2.conf must not Include conf.d"
fi fi
fi fi
} }
check_meltdown_spectre() { check_meltdown_spectre() {
# For Stretch, detection is easy as the kernel use # For Stretch, detection is easy as the kernel use
# /sys/devices/system/cpu/vulnerabilities/ # /sys/devices/system/cpu/vulnerabilities/
if is_debian_stretch; then if is_debian_stretch || is_debian_buster; then
for vuln in meltdown spectre_v1 spectre_v2; do for vuln in meltdown spectre_v1 spectre_v2; do
test -f "/sys/devices/system/cpu/vulnerabilities/$vuln" \ test -f "/sys/devices/system/cpu/vulnerabilities/$vuln" \
|| failed "IS_MELTDOWN_SPECTRE" || failed "IS_MELTDOWN_SPECTRE" "vulnerable to $vuln"
test "${VERBOSE}" = 1 || break
done done
# For Jessie this is quite complicated to verify and we need to use kernel config file # For Jessie this is quite complicated to verify and we need to use kernel config file
elif is_debian_jessie; then elif is_debian_jessie; then
@ -1013,9 +1067,11 @@ check_meltdown_spectre() {
# Sometimes autodetection of kernel config file fail, so we test if the file really exists. # Sometimes autodetection of kernel config file fail, so we test if the file really exists.
if [ -f "/boot/${kernelConfig}" ]; then if [ -f "/boot/${kernelConfig}" ]; then
grep -Eq '^CONFIG_PAGE_TABLE_ISOLATION=y' "/boot/$kernelConfig" \ grep -Eq '^CONFIG_PAGE_TABLE_ISOLATION=y' "/boot/$kernelConfig" \
|| failed "IS_MELTDOWN_SPECTRE" "PAGE_TABLE_ISOLATION vulnerability is not patched" || failed "IS_MELTDOWN_SPECTRE" \
"PAGE_TABLE_ISOLATION must be enabled in kernel, outdated kernel?"
grep -Eq '^CONFIG_RETPOLINE=y' "/boot/$kernelConfig" \ grep -Eq '^CONFIG_RETPOLINE=y' "/boot/$kernelConfig" \
|| failed "IS_MELTDOWN_SPECTRE" "RETPOLINE vulnerability is not patched" || failed "IS_MELTDOWN_SPECTRE" \
"RETPOLINE must be enabled in kernel, outdated kernel?"
fi fi
fi fi
fi fi
@ -1036,29 +1092,31 @@ check_old_home_dir() {
check_tmp_1777() { check_tmp_1777() {
actual=$(stat --format "%a" /tmp) actual=$(stat --format "%a" /tmp)
expected="1777" expected="1777"
test "$expected" = "$actual" || failed "IS_TMP_1777" test "$expected" = "$actual" || failed "IS_TMP_1777" "/tmp must be $expected"
} }
check_root_0700() { check_root_0700() {
actual=$(stat --format "%a" /root) actual=$(stat --format "%a" /root)
expected="700" expected="700"
test "$expected" = "$actual" || failed "IS_ROOT_0700" test "$expected" = "$actual" || failed "IS_ROOT_0700" "/root must be $expected"
} }
check_usrsharescripts() { check_usrsharescripts() {
actual=$(stat --format "%a" /usr/share/scripts) actual=$(stat --format "%a" /usr/share/scripts)
expected="700" expected="700"
test "$expected" = "$actual" || failed "IS_USRSHARESCRIPTS" test "$expected" = "$actual" || failed "IS_USRSHARESCRIPTS" "/usr/share/scripts must be $expected"
} }
check_sshpermitrootno() { check_sshpermitrootno() {
if is_debian_stretch; then if is_debian_stretch || is_debian_buster; then
if grep -q "^PermitRoot" /etc/ssh/sshd_config; then if grep -q "^PermitRoot" /etc/ssh/sshd_config; then
grep -E -qi "PermitRoot.*no" /etc/ssh/sshd_config || failed "IS_SSHPERMITROOTNO" grep -E -qi "PermitRoot.*no" /etc/ssh/sshd_config \
|| failed "IS_SSHPERMITROOTNO" "PermitRoot should be set at no"
fi fi
else else
grep -E -qi "PermitRoot.*no" /etc/ssh/sshd_config || failed "IS_SSHPERMITROOTNO" grep -E -qi "PermitRoot.*no" /etc/ssh/sshd_config \
|| failed "IS_SSHPERMITROOTNO" "PermitRoot should be set at no"
fi fi
} }
check_evomaintenanceusers() { check_evomaintenanceusers() {
if is_debian_stretch; then if is_debian_stretch || is_debian_buster; then
users=$(getent group evolinux-sudo | cut -d':' -f4 | tr ',' ' ') users=$(getent group evolinux-sudo | cut -d':' -f4 | tr ',' ' ')
else else
if [ -f /etc/sudoers.d/evolinux ]; then if [ -f /etc/sudoers.d/evolinux ]; then
@ -1126,7 +1184,30 @@ check_evobackup_incs() {
check_osprober() { check_osprober() {
if is_installed os-prober qemu-kvm; then if is_installed os-prober qemu-kvm; then
failed "IS_OSPROBER" "Removal of os-prober package is recommended as it can cause serious issue on KVM server" failed "IS_OSPROBER" \
"Removal of os-prober package is recommended as it can cause serious issue on KVM server"
fi
}
check_jessie_backports() {
if is_debian_jessie; then
jessieBackports=$(grep -hs "jessie-backports" /etc/apt/sources.list /etc/apt/sources.list.d/*)
if test -n "$jessieBackports"; then
if ! grep -q "archive.debian.org" <<< "$jessieBackports"; then
failed "IS_JESSIE_BACKPORTS" "You must use deb http://archive.debian.org/debian/ jessie-backports main"
fi
fi
fi
}
check_apt_valid_until() {
aptvalidFile="/etc/apt/apt.conf.d/99no-check-valid-until"
aptvalidText="Acquire::Check-Valid-Until no;"
if grep -qs "archive.debian.org" /etc/apt/sources.list /etc/apt/sources.list.d/*; then
if ! grep -qs "$aptvalidText" /etc/apt/apt.conf.d/*; then
failed "IS_APT_VALID_UNTIL" \
"As you use archive.mirror.org you need ${aptvalidFile}: ${aptvalidText}"
fi
fi fi
} }
@ -1251,6 +1332,8 @@ main() {
test "${IS_OLD_HOME_DIR:=1}" = 1 && check_old_home_dir test "${IS_OLD_HOME_DIR:=1}" = 1 && check_old_home_dir
test "${IS_EVOBACKUP_INCS:=1}" = 1 && check_evobackup_incs test "${IS_EVOBACKUP_INCS:=1}" = 1 && check_evobackup_incs
test "${IS_OSPROBER:=1}" = 1 && check_osprober test "${IS_OSPROBER:=1}" = 1 && check_osprober
test "${IS_JESSIE_BACKPORTS:=1}" = 1 && check_jessie_backports
test "${IS_APT_VALID_UNTIL:=1}" = 1 && check_apt_valid_until
fi fi
#----------------------------------------------------------- #-----------------------------------------------------------
@ -1363,7 +1446,7 @@ readonly PROGDIR=$(realpath -m "$(dirname "$0")")
# shellcheck disable=2124 # shellcheck disable=2124
readonly ARGS=$@ readonly ARGS=$@
readonly VERSION="19.06" readonly VERSION="19.09"
# Disable LANG* # Disable LANG*
export LANG=C export LANG=C