diff options
author | Simon Biewald <simon@fam-biewald.de> | 2020-11-05 02:50:21 +0300 |
---|---|---|
committer | Simon Biewald <simon@fam-biewald.de> | 2020-11-10 02:25:33 +0300 |
commit | d388e5d26921a1a8fb0f445e00c58d152c5c4f63 (patch) | |
tree | 6a531e796833759c3bc816b488cdb0d940f33017 /include/osdetection | |
parent | f8178767374219a534513d447563b3cbdab5566b (diff) |
Add OpenSolaris and distribution detection
New variable OPENSOLARIS to distringuish between Oracle Solaris and
OpenSolaris derivates. The edge case of OpenSolaris itself is not yet
solved, but OpenSolaris itself should be very rare these days.
Currently detected and distinguished Solaris variants are:
- Oracle Solaris >= 11 (exluding Solaris Express and OpenSolaris)
- Solaris < 11 (as "Sun Solaris")
- OmniosCE (but not old Omnios)
- OpenIndiana
- Shillix
- SmartOS
- Tribblix
- "Unknown Illumos" for unknown distributions based on Illumos
Lynis will fall back to "Sun Solaris" with "SunOS 5.X" for unknown
distributions.
Diffstat (limited to 'include/osdetection')
-rw-r--r-- | include/osdetection | 85 |
1 files changed, 81 insertions, 4 deletions
diff --git a/include/osdetection b/include/osdetection index b52ab188..793ae448 100644 --- a/include/osdetection +++ b/include/osdetection @@ -556,12 +556,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 |