#!/usr/share/ucs-test/runner bash
# shellcheck shell=bash
## desc: Check root password is sha-512
## tags:
##  - basic
##  - apptest
## exposure: safe
## versions:
##  4.4-4: skip
##  4.4-5: fixed

# shellcheck source=../../lib/base.sh
. "$TESTLIBPATH/base.sh" || exit 137

# if updated from 4.3, ignore md5 in /etc/shadow
if [ "$(ucr get repository/online/component/4.3-5-errata/version)" = "4.3" ]; then
	exit 77
fi

# some tests with old systems still have older hashes, ignore
if [ "$(ucr get ucs/test/00_checks/04_check_root_password/ignore)" = "true" ]; then
	exit 77
fi

if [ "$(cat /etc/shadow | grep '^root:' | awk -F \$ '{print $2}')" -ne 6 ]; then
	cat /etc/shadow | grep '^root:'
	fail_fast 110 "root password is not sha-512"
fi
