#!/bin/sh
# $Id: pwchk,v 1.1 2000/03/31 22:56:33 dmetz Exp $
# $crtd:  by  Derald Metzger  on  990813 $
# $cmnt:  password status check for local passwd entries
#           Copyright (c) 1998 1999  Derald Metzger 
#  This file is part of the cfm pkg (GPL).
# $

echo=/bin/echo

usage="
NAME
  pwchk - password status check
SYNOPSIS
  pwchk { . | acct0 [ acct1 ... ] }
DESCR
  Check status of passwords in the local /etc/passwd file.
  Uses linux \`passwd -S' option.
OPTIONS
  .       - check all passwords in the file
  <acct?> - check the indicated acct
ALSO
  See passwd(1), pwck(1)
"

if [ $# -lt 1 ]; then $echo "### $0: insufficient args $usage"; exit 1; fi

# Get the options
accts=$*

if [ "$1" = . ]; then \
  while read; do
    acct=`echo $REPLY | grep -v '^#.*' | cut -d: -f1`
    [ -n "$acct" ] && 
      echo -e "$acct      \t `passwd -S $acct | grep -v '^Changing'`"
  done </etc/passwd
else
  for acct in $accts; do
    echo -e "$acct      \t `passwd -S $acct | grep -v '^Changing'`"
  done
fi
