mirror of https://github.com/CISOfy/lynis.git
Verify the linux OS supports nanoseconds
Add extra check to verify the linux OS supports nanoseconds. This might not be the case with certain busybox implementations.
This commit is contained in:
parent
490d39f580
commit
98ac5a562a
|
@ -2562,15 +2562,17 @@
|
|||
|
||||
GetTimestamp() {
|
||||
ts=0
|
||||
case "${OS}" in
|
||||
"Linux")
|
||||
ts=$(date "+%s%N")
|
||||
;;
|
||||
*)
|
||||
ts=$(date "+%s")
|
||||
;;
|
||||
esac
|
||||
echo $ts
|
||||
# Detect if the implementation of date supports nanoseconds,
|
||||
if [ "${OS}" = "Linux" ]; then
|
||||
current_nanoseconds=$(date "+%N")
|
||||
# Verify if the result of the command is a number
|
||||
if [ -n "$current_nanoseconds" ] && [ "$current_nanoseconds" -eq "$current_nanoseconds" ] 2>/dev/null; then
|
||||
ts=$(date "+%s%N")
|
||||
else
|
||||
ts=$(date "+%s")
|
||||
fi
|
||||
fi
|
||||
echo $ts
|
||||
}
|
||||
|
||||
Register() {
|
||||
|
|
Loading…
Reference in New Issue