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