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:
authorStéphane BARBARAY <stephane@compodata.com>2017-07-31 13:51:19 +0300
committerMichael Boelen <michael.boelen@cisofy.com>2017-07-31 13:51:19 +0300
commit9ca2d640b8879454c1ae8e26b5429522682d7e7f (patch)
tree75cb06330786a01629a5bc1877c8c026d7b61a20
parent22d76b0d018a02d0455e14cd2e8a579b7e660658 (diff)
Enhanced detection for LXC and LXC over VM (#426)
* Update functions * Update functions * Update tests_shells * Update tests_shells * Update IsVirtualMachine extra check on /proc/1/environ existence + Log result
-rw-r--r--include/functions22
1 files changed, 21 insertions, 1 deletions
diff --git a/include/functions b/include/functions
index 82d8fa68..615abf32 100644
--- a/include/functions
+++ b/include/functions
@@ -1165,6 +1165,14 @@
EXITCODE=0
fi
fi
+ if [ -e /proc/1/environ ]; then
+ FIND=$(grep -qa 'container=lxc' /proc/1/environ)
+ if [ $? -eq 0 ]; then
+ LogText "Result: found LXC in environnement (/proc/1/environ), so we are running in LXC container"
+ CONTAINER_TYPE="LXC"; FOUND=1
+ EXITCODE=0
+ fi
+ fi
if [ ${FOUND} -eq 0 ]; then
CONTAINER_TYPE=""
EXITCODE=1
@@ -1331,6 +1339,18 @@
ISVIRTUALMACHINE=2; VMTYPE="unknown"; VMFULLTYPE="Unknown"
SHORT=""
+ # lxc environ detection
+ if [ "${SHORT}" = "" ]; then
+ if [ -f /proc/1/environ ]; then
+ if grep -qa 'container=lxc' /proc/1/environ; then
+ SHORT=lxc
+ LogText "Result: found ${SHORT}"
+ fi
+ fi
+ else
+ LogText "Result: skipped lxc environ detection test, as we already found machine type"
+ fi
+
# facter
if [ "${SHORT}" = "" ]; then
if [ -x /usr/bin/facter ] || [ -x /usr/local/bin/facter ]; then
@@ -1371,7 +1391,7 @@
if [ "${SHORT}" = "" ]; then
if [ -x /usr/bin/lscpu ]; then
LogText "Test: trying to guess virtualization with lscpu"
- FIND=$(lscpu | grep "^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
LogText "Result: found ${FIND}"
SHORT="${FIND}"