Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/CISOfy/lynis.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Boelen <michael.boelen@cisofy.com>2018-01-17 19:26:30 +0300
committerMichael Boelen <michael.boelen@cisofy.com>2018-01-17 19:26:30 +0300
commit893404247328e9fbf07fb67d74e0aa651ec1c3f7 (patch)
tree08d1445f9f1845719e2965c03c3256f289c63c22
parent25b3c4f1eb8977f73213dd2d8725b57ef7a5dd3e (diff)
Code enhancements
-rw-r--r--include/functions41
1 files changed, 19 insertions, 22 deletions
diff --git a/include/functions b/include/functions
index 3b69544f..9be236a6 100644
--- a/include/functions
+++ b/include/functions
@@ -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"