Store host IDv2 and detect utilities when no binaries scan has been done

This commit is contained in:
Michael Boelen 2016-05-17 18:07:43 +02:00
parent d3c94c02f9
commit 0d62613388
1 changed files with 14 additions and 4 deletions

View File

@ -603,10 +603,21 @@
################################################################################ ################################################################################
GetHostID() { GetHostID() {
HOSTID="-" HOSTID=""
HOSTID2=""
FIND="" FIND=""
# Avoid some hashes (empty, only zeros) # Avoid some hashes (empty, only zeros)
BLACKLISTED_HASHES="6ef1338f520d075957424741d7ed35ab5966ae97 adc83b19e793491b1c6ea0fd8b46cd9f32e592fc" BLACKLISTED_HASHES="6ef1338f520d075957424741d7ed35ab5966ae97 adc83b19e793491b1c6ea0fd8b46cd9f32e592fc"
# Check which utilities we can use (e.g. lynis show hostids). Normally these are detected during binaries collecting.
if [ "${SHA1SUMBINARY}" = "" ]; then SHA1SUMBINARY=$(which sha1sum 2> /dev/null); fi
if [ "${SHA1SUMBINARY}" = "" ]; then SHA1SUMBINARY=$(which sha1 2> /dev/null); fi
if [ "${SHA256SUMBINARY}" = "" ]; then SHA256SUMBINARY=$(which sha256sum 2> /dev/null); fi
if [ "${SHA256SUMBINARY}" = "" ]; then SHA256SUMBINARY=$(which sha256 2> /dev/null); fi
if [ "${CSUMBINARY}" = "" ]; then CSUMBINARY=$(which csum 2> /dev/null); fi
if [ "${OPENSSLBINARY}" = "" ]; then OPENSSLBINARY=$(which openssl 2> /dev/null); fi
if [ "${IFCONFIGBINARY}" = "" ]; then IFCONFIGBINARY=$(which ifconfig 2> /dev/null); fi
if [ "${IPBINARY}" = "" ]; then IPBINARY=$(which ip 2> /dev/null); fi
if [ ! "${SHA1SUMBINARY}" = "" -o ! "${OPENSSLBINARY}" = "" -o ! "${CSUMBINARY}" = "" ]; then if [ ! "${SHA1SUMBINARY}" = "" -o ! "${OPENSSLBINARY}" = "" -o ! "${CSUMBINARY}" = "" ]; then
case "${OS}" in case "${OS}" in
@ -631,7 +642,6 @@
else else
ReportException "GetHostID" "No output from entstat on interfaces: en0, ent0" ReportException "GetHostID" "No output from entstat on interfaces: en0, ent0"
fi fi
;; ;;
"DragonFly" | "FreeBSD") "DragonFly" | "FreeBSD")
@ -805,7 +815,6 @@
# New style host ID # New style host ID
if [ "${HOSTID2}" = "" ]; then if [ "${HOSTID2}" = "" ]; then
LogText "Info: creating a HostID (version 2)" LogText "Info: creating a HostID (version 2)"
FOUND=0 FOUND=0
DATA_SSH="" DATA_SSH=""
@ -836,7 +845,8 @@
fi fi
LogText "Hash (hostname): ${HASH_HOSTNAME}" LogText "Hash (hostname): ${HASH_HOSTNAME}"
LogText "Hash (ssh): ${HASH_SSH}" LogText "Hash (ssh): ${HASH_SSH}"
Report "hostid2=${HASH_SSH}" HOSTID2="${HASH_SSH}"
Report "hostid2=${HOSTID2}"
fi fi
fi fi