#    Copyright (c) 1996-2001 Brocade Communications Systems, Inc.
#    All rights reserved.
#
#    profile for the maintenance user of Fabric OS services and interfaces
#

# FOS-834168
complete -X '*' -D

if [ $setup_standby_profile -eq 0 ]; then
#changed the path to point to abin
PATH="/fabos/link_abin:/fabos/link_sbin:/fabos/link_bin:/fabos/dbin"
# Set the control-C handler back to default
# This trap was turned off in /etc/profile.
# Note that this trap statement should be BEFORE chkdefaultpasswds
# otherwise control-C cannot be used to quit changing default passwords.
trap - INT
#
# Defect 22765: Login during CP becoming active could hit a timing
# window that the active PATH hasn't been setup, use full path
#
#Adding check to avoid default passwd check for dedicated account
#login in Kestrel3
swbd=`/sbin/sin | /bin/awk ' {print $2} ' | /bin/grep SWBD | /bin/sed 's@,@@'`
if [ $swbd == "SWBD149" ]; then
	if [ x$SSO != "x1" ]; then
		/fabos/cliexec/chkdefaultpasswds
	fi
else
if [ $LOGIN_ID == "maintenance" ]; then
	# check default password only for local switch account
	if [[ $AUTH_TYPE -eq 0 ]]; then	
		/fabos/cliexec/chkdefaultpasswds
		ret=$?
		if [[ $ret -eq 2 || $ret -eq 1 ]]; then
			exit $ret
		fi
	fi
fi
fi
else
if [[ $LOGIN_ID == "maintenance" ]]; then
    # check default password only for local switch acct
	if [[ $AUTH_TYPE -eq 0 ]]; then
		/fabos/cliexec/chkpasswd $LOGIN_ID
		stat=$?
		if [ $stat -eq 1 ]; then
			echo "Password for maintenance is at default. Kindly login to Active CP and change the password to non-default value before proceeding."
			exit 1
		fi
	fi
fi
PATH="/fabos/link_abin:/fabos/link_sbin:/fabos/link_bin:/fabos/dbin"
# Set trap for SIGINT back to default. See comments above.
trap - INT
fi
#Check for password hash enforcement
if [[ $AUTH_TYPE -eq 0 ]]; then
	/fabos/cliexec/passwdhashchange
	stat=$?
	if [ $stat -eq 1 ]; then
		exit 1
	fi
fi
# we will disable hashing as it will defeat our PATH settings
# by hashing the original symbolic link values to the
# obsolute paths.
shopt -s checkhash > /dev/null
/bin/stty erase '^H'
EXECIGNORE=$(/fabos/cliexec/cmdlist)
FIGNORE='::'
readonly FIGNORE
readonly EXECIGNORE
readonly HISTFILE
readonly HISTFILESIZE
readonly HISTSIZE
readonly HISTCMD
readonly HISTCONTROL
readonly HISTIGNORE
readonly LFILE
readonly LESSHISTFILE
