:
#	@(#)authckrc.sh	1.3 91/02/15
#
#	Portions Copyright 1990 Altos Computer Systems
#	Portions Copyright 1988, 1989 The Santa Cruz Operation, Inc
#	Copyright (c) 1984, 1986, 1987, 1988 AT&T
#	All Rights Reserved

#	THIS IS UNPUBLISHED PROPRIETARY SOURCE CODE OF AT&T
#	The copyright notice above does not evidence any
#	actual or intended publication of such source code.

# Begin SCO_C2TCB

DEFAULT=/etc/default/boot

# Prompt for y or n answer
getyn( ) {
while 
   read ans rest
   do
       case "$ans" in
           [yY] ) return 0 ;;
           [nN] ) return 1 ;;
           *)     return 0 ;;
	esac
   done
}

echo "Checking tcb ..."

[ -x /etc/tcbck ] && /etc/tcbck || {
	echo "$0: Login on the OVERRIDE tty and restore
	the missing files from a backup or the distribution disks."
}	

# check subsystem database integrity

[ -x /tcb/bin/authck ] && {
	if [ "$1" = -a ] 
	then
		echo "Checking protected subsystem database ..."
		/bin/su root -c "/tcb/bin/authck -ns"
	else
		# start timeout daemon
		timeout=`sed -n "/^TIMEOUT=[0-9]*$/s/TIMEOUT=//p" $DEFAULT`
		if [ -z "$timeout" ]
		then
			timeout=30
		fi
		(sleep $timeout; kill -15 $$) >/dev/null 2>&1 &

		echo "Check protected subsystem databases (y/n)? \c"
		if getyn
		then
			# kill timeout daemon
			kill -15 $! >/dev/null 2>&1
			/bin/su root -c "/tcb/bin/authck -s"
		fi
	fi
}

# End SCO_C2TCB

