#!/bin/sh
# @vasm : vpasswd1
# @level: user
# @description: setup password for user
# 
# (c) Eko M. Budi, 2003
# (c) Vector Linux, 2003
#
# Released under GNU GPL

if [ ! "$VASM_FUNCTIONS" ]; then
  . /sbin/vasm-functions
fi

pfile="/etc/passwd"

###############################################################
# MAIN
USERNAME="$USER"

while [ 1 ]; do
  passwordbox "Old password of user $USERNAME" "CHANGE USER PASSWORD"
  OLDPASS="`cat $freply`"
  clean_tmp

  passwordbox "New password" "CHANGE USER PASSWORD"
  USERPASS1="`cat $freply`"
  clean_tmp

  passwordbox "Re-enter new password" "CHANGE USER PASSWORD"
  USERPASS2="`cat $freply`"
  clean_tmp
  
  if [ ! "$USERPASS1" = "$USERPASS2" ]; then
     msgbox "Sorry. The new passwords did not match. Please repeat"
     continue
  fi

  /sbin/passwdx1 $OLDPASS $USERPASS1

  case "$?" in
       0) 
          infobox "Changing password DONE " 
          sleep 1
	  clean_exit
	  ;;
       1)
          msgbox "Wrong old password. Please remember it"
	  ;;
       2)
          msgbox "The New password is not strong enough. Please think harder"
	  ;;
   esac
done

clean_exit

