How do I edit my script so that it checks that there is only one root ID?
Expected Output
Audit criteria: There is only one root id
Vulnerability: Yes
Details: See below
root:!:0:0::/:/usr/bin/bash
jdoe:*:0:1:John Doe:/home/jdoe:/usr/bin/bash
The Script
#!/bin/bash
isVulnerable="No"
isVulnerable="Yes"
cat /etc/passwd | cut -f3 -d":" | sort -n | /usr/bin/uniq -c | while read x ;
do
[ -z "${x}" ] && break
set - $x
if [ "$1" -gt 1 ]; then
users=`/bin/gawk -F: '($3 == n) { print $1 }' n=$2 /etc/passwd | /usr/bin/xargs`
echo "Audit Criteria: Duplicate UID ($2): ${users}"
echo "Vulnerability: ${isVulnerable}"
echo "Details: see below"
echo
grep "x:0:" /etc/passwd
else
echo "All user id are unique"
fi
done