@@ -4,6 +4,7 @@ set -e
globalTests=(
utc
cve-2014--shellshock
+ no-root-password
)
declare -A testAlias=(
@@ -110,6 +111,9 @@ declare -A globalExcludeTests=(
# single-binary images
[hello-world_utc]=1
[swarm_utc]=1
+
+ [hello-world_no-root-password]=1
+ [swarm_no-root-password]=1
# no "native" dependencies
[ruby:slim_ruby-bundler]=1
@@ -0,0 +1,8 @@
+#!/bin/bash
+set -e
+pass="$(docker run --rm --entrypoint awk "$1" -F ':' '$1 == "root" { print $2 }' /etc/passwd)"
+if [ "$pass" = 'x' ]; then
+ pass="$(docker run --rm --entrypoint awk --user root "$1" -F ':' '$1 == "root" { print $2 }' /etc/shadow)"
+fi
+[ -z "$pass" -o "$pass" = '*' ]