#! /bin/sh

PASSWDFILE=./passwd

# Announce duplicate logins
dup_logins=`cut -d: -f1 $PASSWDFILE | sort | uniq -d`
if test "$dup_logins"
then
  echo "Duplicate logins: $dup_logins"
fi

# Announce duplicate uids
dup_uids=`cut -d: -f3 $PASSWDFILE | sort -n | uniq -d`
if test "$dup_uids"
then
  echo "Duplicate uids: $dup_uids"
fi

# Announce accounts with no password
no_passwd=`awk -F: '$2 == "" { print $1 }' $PASSWDFILE`
if test "$no_passwd"
then
  echo "Accounts with no passwords: $no_passwd"
fi

# Check that home directories all exist
cut -d: -f1,6 $PASSWDFILE | sed -e 's/:/ /' |
while read login dir 
do
  if test ! -d "$dir"
  then
    echo "Login $login has no home directory (should be \"$dir\")"
  fi
done

# Check that shells all exist
cut -d: -f1,7 $PASSWDFILE | sed -e 's/:/ /' |
while read login shell
do
  if test ! -f "$shell"
  then
    echo "Login $login has no shell (should be \"$shell\")"
  fi
done

