mirror of
https://github.com/CISOfy/lynis.git
synced 2026-03-11 08:55:28 +00:00
Merge 61061471fe into 52ed89ce35
This commit is contained in:
commit
2d90ee2bfb
2 changed files with 22 additions and 11 deletions
|
|
@ -69,7 +69,8 @@
|
|||
LogText "Result: hostnamed is defined and not longer than 63 characters"
|
||||
fi
|
||||
# Test valid characters (normally a dot should not be in the name, but we can't be 100% sure we have short name)
|
||||
FIND=$(echo "${HOSTNAME}" | ${TRBINARY} -d '[:alnum:]\.\-')
|
||||
# (we are NOT using [:alnum:] to support BusyBox's tr on devices with limited resources)
|
||||
FIND=$(echo "${HOSTNAME}" | ${TRBINARY} -d '[a-zA-Z0-9]\.\-')
|
||||
if [ -z "${FIND}" ]; then
|
||||
LogText "Result: good, no unexpected characters discovered in hostname"
|
||||
if IsVerbose; then Display --indent 2 --text "- Hostname (allowed characters)" --result "${STATUS_OK}" --color GREEN; fi
|
||||
|
|
|
|||
30
lynis
30
lynis
|
|
@ -514,22 +514,32 @@ ${NORMAL}
|
|||
. ${INCLUDEDIR}/osdetection
|
||||
Display --indent 2 --text "- Detecting OS... " --result "${STATUS_DONE}" --color GREEN
|
||||
|
||||
# Check hostname and get timestamp
|
||||
# Detect hostname and domain
|
||||
FQDN=$(hostname 2> /dev/null)
|
||||
case ${OS} in
|
||||
HP-UX)
|
||||
HOSTNAME=$(hostname) ;;
|
||||
HOSTNAME=$(hostname) ;;
|
||||
Linux)
|
||||
if [ "${LINUX_VERSION}" = "OpenWrt" ]; then
|
||||
HOSTNAME=$(uname -n)
|
||||
FQDN="${HOSTNAME:+$HOSTNAME.}$(uci -q get dhcp.@dnsmasq[0].domain)"
|
||||
else
|
||||
HOSTNAME=$(hostname -s 2> /dev/null)
|
||||
if [ -z "${HOSTNAME}" ]; then
|
||||
HOSTNAME="${FQDN:-no-hostname}"
|
||||
fi
|
||||
if [ "${HOSTNAME}" = "${FQDN}" ]; then
|
||||
FQDN=$(hostname -f 2> /dev/null)
|
||||
fi
|
||||
fi
|
||||
;;
|
||||
Solaris)
|
||||
HOSTNAME=$(uname -n) ;;
|
||||
HOSTNAME=$(uname -n) ;;
|
||||
*)
|
||||
HOSTNAME=$(hostname -s 2> /dev/null) ;;
|
||||
HOSTNAME=$(hostname -s 2> /dev/null) ;;
|
||||
esac
|
||||
if [ -z "${HOSTNAME}" ]; then
|
||||
HOSTNAME=$(hostname 2> /dev/null)
|
||||
if [ -z "${HOSTNAME}" ]; then HOSTNAME="no-hostname"; fi
|
||||
fi
|
||||
FQDN=$(hostname 2> /dev/null)
|
||||
if [ "${OS}" = "Linux" -a "${HOSTNAME}" = "${FQDN}" ]; then
|
||||
FQDN=$(hostname -f 2> /dev/null)
|
||||
HOSTNAME="${FQDN:-no-hostname}"
|
||||
fi
|
||||
#
|
||||
#################################################################################
|
||||
|
|
|
|||
Loading…
Reference in a new issue