#!/bin/sh
#
# Copyright (c) 1999 by Sun Microsystems, Inc.
# All rights reserved.
#
#pragma ident  "@(#)preremove 1.2     99/07/22 SMI"
#

PATH="/usr/bin:/usr/sbin:${PATH}"
export PATH

	# Remove nfssec.conf entry for privacy
	NFSSEC_CONF="$BASEDIR/etc/nfssec.conf"
	grep -s "^[#	 ]*krb5p[	 ]" $NFSSEC_CONF >/dev/null 2>&1
	if [ $? -eq 0 ]
	then
		grep -vs "^[#	 ]*krb5p[	 ]" $NFSSEC_CONF >/tmp/pr.$$
		cp /tmp/pr.$$ $NFSSEC_CONF
		rm /tmp/pr.$$
	fi

	# Remove privacy line from qop file
	QOP="$BASEDIR/etc/gss/qop"
	grep -s "^[#	 ]*GSS_KRB5_CONF_C_QOP_DES[	 ]" $QOP >/dev/null 2>&1
	if [ $? -eq 0 ]
	then
		grep -vs "^[#	 ]*GSS_KRB5_CONF_C_QOP_DES[	 ]" $QOP >/tmp/pr.$$
		cp /tmp/pr.$$ $QOP
		rm /tmp/pr.$$
	fi

	# Remove kerberos V5 privacy mechanism from list and uncomment the
	# global mechanism.
	MECH="$BASEDIR/etc/gss/mech"
	grep -s "do_kmech_krb5" $MECH >/dev/null 2>&1
	if [ $? -eq 0 ]
	then
		grep -vs "do_kmech_krb5" $MECH >/tmp/pr.$$

		# Uncomment or re-add the non-privacy mechanism
		grep -s "gl_kmech_krb5" /tmp/pr.$$ >/tmp/gl.$$ 2>&1
		if [ $? -eq 0 ]
		then
			grep -s "^#" /tmp/gl.$$ >/dev/null 2>&1
			if [ $? -eq 0 ]
			then
				# Uncomment gl_kmech_krb5
				sed "s/^#[ 	]kerberos_v5/kerberos_v5/" \
					< /tmp/pr.$$ > $MECH
			else
				# gl_kmech_krb5 present and uncommented
				cp /tmp/pr.$$ $MECH
			fi
		else
			# gl_mech_krb5 not present, add new one
			echo "kerberos_v5		1.2.840.113554.1.2.2	gl/mech_krb5.so gl_kmech_krb5	# $PKGINST" >> /tmp/pr.$$
			cp /tmp/pr.$$ $MECH
		fi

		rm /tmp/pr.$$
		rm /tmp/gl.$$
	fi

exit 0
