mirror of https://github.com/CISOfy/lynis.git
Code enhancements
This commit is contained in:
parent
25b3c4f1eb
commit
8934042473
|
@ -1383,7 +1383,7 @@
|
|||
SHORT=""
|
||||
|
||||
# lxc environ detection
|
||||
if [ "${SHORT}" = "" ]; then
|
||||
if [ -z "${SHORT}" ]; then
|
||||
if [ -f /proc/1/environ ]; then
|
||||
FIND=$(grep -qa 'container=lxc' /proc/1/environ 2> /dev/null)
|
||||
if [ $? -eq 0 ]; then
|
||||
|
@ -1396,7 +1396,7 @@
|
|||
fi
|
||||
|
||||
# facter
|
||||
if [ "${SHORT}" = "" ]; then
|
||||
if [ -z "${SHORT}" ]; then
|
||||
if [ -x /usr/bin/facter ] || [ -x /usr/local/bin/facter ]; then
|
||||
case "$(facter is_virtual)" in
|
||||
"true")
|
||||
|
@ -1415,11 +1415,11 @@
|
|||
fi
|
||||
|
||||
# systemd
|
||||
if [ "${SHORT}" = "" ]; then
|
||||
if [ -z "${SHORT}" ]; then
|
||||
if [ -x /usr/bin/systemd-detect-virt ]; then
|
||||
LogText "Test: trying to guess virtualization technology with systemd-detect-virt"
|
||||
FIND=$(/usr/bin/systemd-detect-virt)
|
||||
if [ ! "${FIND}" = "" ]; then
|
||||
if [ ! -z "${FIND}" ]; then
|
||||
LogText "Result: found ${FIND}"
|
||||
SHORT="${FIND}"
|
||||
fi
|
||||
|
@ -1432,11 +1432,11 @@
|
|||
|
||||
# lscpu
|
||||
# Values: VMware
|
||||
if [ "${SHORT}" = "" ]; then
|
||||
if [ -z "${SHORT}" ]; then
|
||||
if [ -x /usr/bin/lscpu ]; then
|
||||
LogText "Test: trying to guess virtualization with lscpu"
|
||||
FIND=$(lscpu | grep -i "^Hypervisor Vendor" | awk -F: '{ print $2 }' | sed 's/ //g')
|
||||
if [ ! "${FIND}" = "" ]; then
|
||||
if [ ! -z "${FIND}" ]; then
|
||||
LogText "Result: found ${FIND}"
|
||||
SHORT="${FIND}"
|
||||
else
|
||||
|
@ -1451,7 +1451,7 @@
|
|||
|
||||
# dmidecode
|
||||
# Values: VMware Virtual Platform / VirtualBox
|
||||
if [ "${SHORT}" = "" ]; then
|
||||
if [ -z "${SHORT}" ]; then
|
||||
if [ -x /usr/bin/dmidecode ]; then DMIDECODE_BINARY="/usr/bin/dmidecode"
|
||||
elif [ -x /usr/sbin/dmidecode ]; then DMIDECODE_BINARY="/usr/sbin/dmidecode"
|
||||
else
|
||||
|
@ -1460,7 +1460,7 @@
|
|||
if [ ! "${DMIDECODE_BINARY}" = "" -a ${PRIVILEGED} -eq 1 ]; then
|
||||
LogText "Test: trying to guess virtualization with dmidecode"
|
||||
FIND=$(/usr/sbin/dmidecode -s system-product-name | awk '{ print $1 }')
|
||||
if [ ! "${FIND}" = "" ]; then
|
||||
if [ ! -z "${FIND}" ]; then
|
||||
LogText "Result: found ${FIND}"
|
||||
SHORT="${FIND}"
|
||||
else
|
||||
|
@ -1477,28 +1477,25 @@
|
|||
# < needs snippet >
|
||||
|
||||
# Try common guest processes
|
||||
if [ "${SHORT}" = "" ]; then
|
||||
if [ -z "${SHORT}" ]; then
|
||||
LogText "Test: trying to guess virtual machine type by running processes"
|
||||
|
||||
# VMware
|
||||
IsRunning vmware-guestd
|
||||
if [ ${RUNNING} -eq 1 ]; then SHORT="vmware"; fi
|
||||
IsRunning vmtoolsd
|
||||
if [ ${RUNNING} -eq 1 ]; then SHORT="vmware"; fi
|
||||
if IsRunning vmware-guestd; then SHORT="vmware"
|
||||
elif IsRunning vmtoolsd; then SHORT="vmware"
|
||||
fi
|
||||
|
||||
# VirtualBox based on guest services
|
||||
IsRunning vboxguest-service
|
||||
if [ ${RUNNING} -eq 1 ]; then SHORT="virtualbox"; fi
|
||||
IsRunning VBoxClient
|
||||
if [ ${RUNNING} -eq 1 ]; then SHORT="virtualbox"; fi
|
||||
IsRunning VBoxService
|
||||
if [ ${RUNNING} -eq 1 ]; then SHORT="virtualbox"; fi
|
||||
if IsRunning vboxguest-service; then SHORT="virtualbox"
|
||||
elif IsRunning VBoxClient; then SHORT="virtualbox"
|
||||
elif IsRunning VBoxService; then SHORT="virtualbox"
|
||||
fi
|
||||
else
|
||||
LogText "Result: skipped processes test, as we already found platform"
|
||||
fi
|
||||
|
||||
# Amazon EC2
|
||||
if [ "${SHORT}" = "" ]; then
|
||||
if [ -z "${SHORT}" ]; then
|
||||
LogText "Test: checking specific files for Amazon"
|
||||
if [ -f /etc/ec2_version -a -s /etc/ec2_version ]; then
|
||||
SHORT="amazon-ec2"
|
||||
|
@ -1510,7 +1507,7 @@
|
|||
fi
|
||||
|
||||
# sysctl values
|
||||
if [ "${SHORT}" = "" ]; then
|
||||
if [ -z "${SHORT}" ]; then
|
||||
LogText "Test: trying to guess virtual machine type by sysctl keys"
|
||||
|
||||
# FreeBSD: hw.hv_vendor (remains empty for VirtualBox)
|
||||
|
@ -1525,7 +1522,7 @@
|
|||
fi
|
||||
|
||||
# lshw
|
||||
if [ "${SHORT}" = "" ]; then
|
||||
if [ -z "${SHORT}" ]; then
|
||||
if [ ${PRIVILEGED} -eq 1 ]; then
|
||||
if [ -x /usr/bin/lshw ]; then
|
||||
LogText "Test: trying to guess virtualization with lshw"
|
||||
|
|
Loading…
Reference in New Issue