#!/bin/sh
#
#       This script checks for the revision of the patch 
#       installed and takes the necessary action to back out changes
#	made to the etc/default/login script
#
#

PATID=108993
NOUNDO_REV=14
rmv_all=1

INFO="$PKG_INSTALL_ROOT/var/sadm/pkg/SUNWcsr/pkginfo"
pids=`egrep '^PATCHLIST' $INFO | nawk -F= '{print $2}'`

undo_login() {

fname=login

cat<<EOF > /tmp/$fname.$$ 
#ident	"@(#)login.dfl	1.10	99/08/04 SMI"	/* SVr4.0 1.1.1.1	*/
EOF

cat $PKG_INSTALL_ROOT/etc/default/$fname |\
sed '{

/^# ident	"@(#)login.dfl	1.13	03\/01\/10 SMI"/d
/^# Copyright 1989-2002 Sun Microsystems, Inc.  All rights reserved./d
/^# Use is subject to license terms./d
/^# DISABLETIME  If present, and greater/d
/^# login will wait after RETRIES failed/d
/^# PAM_ABORT. Default is 20. Minimum is 0/d
/^DISABLETIME=/d
/^# *DISABLETIME/d
          } '  >> /tmp/$fname.$$ 

cp /tmp/$fname.$$ $PKG_INSTALL_ROOT/etc/default/$fname
rm /tmp/$fname.$$
return 0


}


for i in `echo $pids`; do
	echo $i | egrep -s $PATID || continue
	rev=`expr //$i : '.*-\(.*\)'`
	#No undo edits for rev-14 or higher
	[ $rev -ge $NOUNDO_REV ] && exit
done

[ $rmv_all ] && undo_login

exit 0
