#!/sbin/sh
#@(#)HP Netstation Admin Scripts
#
# lmrootlogin	 Disable root login from xdm
#

echo ""

if [ $OS = "sco" ]
then
  # xdm admin not supported on SCO Unix
  exit 1
fi

if [ ! -f $XSTARTUP ]
then
	echo "The file $XSTARTUP doesn't exist."
	echo "$XSTARTUP is needed to add root login control."
	exit 10
fi

egrep '^NoRoot #' $XSTARTUP > /dev/null 2>&1
if [ $? = 0 ]
then
	echo ""
	echo "The ability to login as root through xdm is currently disabled."
	echo ""
	$ECHO "Re-enable root login? [y|n] (y): $NL"
	read SEL
	echo ""

	case $SEL in
	    y|Y|yes|YES|Yes|"")
		;;
	    *)
		exit 100
		;;
	esac

	sed 's/^NoRoot #/#NoRoot #/g' $XSTARTUP > $TMP/Xstartup
	cp $TMP/Xstartup $XSTARTUP
	rm $TMP/Xstartup
	chmod u+x $XSTARTUP
	echo "Commented out \"NoRoot\" line in $XSTARTUP."
	echo "root login enabled."
	echo ""
	exit 10
fi

egrep '^#NoRoot #' $XSTARTUP > /dev/null 2>&1
if [ $? -ne 0 ]
then
	echo "Can't find proper NoRoot line in $XSTARTUP, ..did nothing."
	echo ""
	exit 10
fi

echo ""
echo "The ability to login as root through xdm is currently enabled."
echo ""
$ECHO "Disable root login? [y|n] (y): $NL"
read SEL
echo ""

case $SEL in
    y|Y|yes|YES|Yes|"")
	;;
    *)
	exit 100
	;;
esac

sed 's/^#NoRoot #/NoRoot #/g' $XSTARTUP > $TMP/Xstartup
cp $TMP/Xstartup $XSTARTUP
rm $TMP/Xstartup
chmod u+x $XSTARTUP
echo "Uncommented \"NoRoot\" line in $XSTARTUP"	
echo "root login through xdm now disabled."
echo ""
exit 10

