Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve no-root-password with more knowledge from the manpages #739

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 22 additions & 1 deletion test/tests/no-root-password/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,28 @@
set -e

pass="$(docker run --rm --entrypoint awk "$1" -F ':' '$1 == "root" { print $2 }' /etc/passwd)"

if [ "$pass" = 'x' ]; then
# 'x' means password is in /etc/shadow instead
pass="$(docker run --rm --entrypoint awk --user root "$1" -F ':' '$1 == "root" { print $2 }' /etc/shadow)"
fi
[ -z "$pass" -o "$pass" = '*' ]

if [ -z "$pass" -o "$pass" = '*' ]; then
# '*' and '' mean no password
exit 0
fi

if [ "${pass:0:1}" = '!' ]; then
# '!anything' means "locked" password
echo >&2 "warning: locked password detected for root: '$pass'"
exit 0
fi

if [ "${pass:0:1}" = '$' ]; then
# gotta be crypt ($id$salt$encrypted), must be a fail
echo >&2 "error: crypt password detected for root: '$pass'"
exit 1
fi

echo >&2 "warning: garbage password detected for root: '$pass'"
exit 0