make_passwd_file.sh

This script is designed to isolate relevant fields from the /etc/passwd and /etc/shadow files to build up enough data to provide password comparisons for the password change checking script.

Access to /etc/shadow is required. Therefore this script has to be run as root.

#!/bin/sh
#
# Isolate relevant password details from 
# /etc/shadow and /etc/passwd

PWFILE=$1
SHFILE=$2

cat $PWFILE | awk -F: '{print $1}' | while read LINE
do
   username=$LINE
   password=`grep "^${username}:" $SHFILE | awk -F: '{print $2}'`
   realname=`grep "^${username}:" $PWFILE | awk -F: '{print $5}'`
   echo ${username}:${password}:${realname}
done

#echo "Done isolating password details"