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>2020-11-13 18:01:00 +0300
committerGitHub <noreply@github.com>2020-11-13 18:01:00 +0300
commiteb759f4c132def90fd19644993aac14ca324e353 (patch)
tree6521466eefa239cf66209005c391d23fa391d990 /include/osdetection
parentba09fd9462507f7d4d843cb8b25b9bf852390321 (diff)
parent7cb84bf2a8521ab29193ca533388c7cc31864dba (diff)
Merge pull request #1071 from Varbin/opensolaris-detection
OpenSolaris distribution detection
Diffstat (limited to 'include/osdetection')
-rw-r--r--include/osdetection85
1 files changed, 81 insertions, 4 deletions
diff --git a/include/osdetection b/include/osdetection
index 26a95570..4b5c68e1 100644
--- a/include/osdetection
+++ b/include/osdetection
@@ -567,12 +567,89 @@
SYSCTL_READKEY=""
;;
- # Solaris / OpenSolaris
+ # Solaris / OpenSolaris / Ilumos ...
SunOS)
OS="Solaris"
- OS_NAME="Sun Solaris"
- OS_FULLNAME=$(uname -s -r)
- OS_VERSION=$(uname -r)
+ OS_KERNELVERSION=$(uname -v)
+ OPENSOLARIS=0
+
+ if [ -f /etc/os-release ]; then
+ OS_ID=$(grep "^ID=" /etc/os-release | awk -F= '{print $2}' | tr -d '"')
+ OS_VERSION=$(grep "^VERSION=" /etc/os-release | awk -F= '{print $2}' | tr -d '"')
+ OS_FULLNAME=$(awk -F= '/^PRETTY_NAME=/ {print substr($2,2,length($2)-2)}' /etc/os-release)
+ case "${OS_ID}" in
+ "solaris")
+ OS_NAME="Oracle Solaris"
+ ;;
+ "omnios")
+ OS_NAME="OmniOS"
+ OPENSOLARIS=1
+ ;;
+ "tribblix")
+ OS_NAME="Tribblix"
+ OS_FULLNAME="Tribblix ${OS_VERSION}"
+ OPENSOLARIS=1
+ ;;
+ "*")
+ ReportException "OS Detection" "Unknown OS found in /etc/os-release - Please create issue on GitHub project page: ${PROGRAM_SOURCE}"
+ ;;
+ esac
+ elif [ "$(uname -o 2> /dev/null)" == "illumos" ]; then
+ OPENSOLARIS=1
+
+ # Solaris has a free form text file with release information
+ if grep "OpenIndiana" /etc/release > /dev/null; then
+ OS_NAME="OpenIndiana"
+ if grep "Hipster" /etc/release > /dev/null; then
+ OS_VERSION="$(tr ' ' '\n' < /etc/release | grep '[[:digit:]]\.[[:digit:]]')"
+ OS_FULLNAME="OpenIndiana Hipster $OS_VERSION"
+ else
+ OS_VERSION="Unknown"
+ OS_FULLNAME="OpenIndiana (unknown edition)"
+ fi
+ elif grep "OmniOS" /etc/release > /dev/null; then
+ OS_NAME="OmniOS"
+ OS_VERSION="$(tr ' ' '\n' < /etc/release | grep 'r[[:digit:]]')"
+ if grep "Community Edition" /etc/release > /dev/null; then
+ OS_FULLNAME="OmniOS Community Edition v11 $OS_VERSION"
+ fi
+ elif grep "SmartOS" /etc/release > /dev/null; then
+ OS_NAME="SmartOS"
+ OS_VERSION="-"
+ OS_FULLNAME="SmartOS"
+ else
+ OS_NAME="Unknown Illumos"
+ fi
+ elif grep "SchilliX" /etc/release > /dev/null; then
+ OS_NAME="SchilliX"
+ OS_FULLNAME="$(head -n 1 /etc/release | xargs)"
+ OS_VERSION="$(echo "$OS_FULLNAME" | cut -d '-' -f 2)"
+
+ OPENSOLARIS=1
+ elif head -n 1 < /etc/release | grep "Oracle Solaris" > /dev/null; then
+ OS_NAME="Oracle Solaris"
+ OS_FULLNAME="$(head -n 1 /etc/release | xargs)"
+ OS_VERSION="$(head -n 1 < /etc/release | xargs | cut -d ' ' -f 3)"
+ elif head -n 1 < /etc/release | xargs | grep "^Solaris " > /dev/null; then
+ OS_NAME="Sun Solaris"
+ # Example of /etc/release:
+ # Solaris 10 5/08
+ # ...
+ # Solaris 10 10/09 (Update 8)
+ # The first line does not contain the "Update" number,
+ # only if present.
+ if tail -1 < /etc/release | xargs | grep "^Solaris " > /dev/null; then
+ OS_FULLNAME=$(tail -1 < /etc/release | xargs)
+ else
+ OS_FULLNAME=$(head -1 < /etc/release | xargs)
+ fi
+ OS_VERSION=$(echo "$OS_FULLNAME" | cut -d ' ' -f 2,3)
+ else # Old behaviour
+ OS_NAME="Sun Solaris"
+ OS_FULLNAME=$(uname -s -r)
+ OS_VERSION=$(uname -r)
+ fi
+
HARDWARE=$(uname -m)
if [ -x /usr/bin/isainfo ]; then
# Returns 32, 64