#!/bin/sh
# @(#)skey.cgi 1.6 99/01/05 Copyright (c) 1998 Sun Microsystems, Inc., All rights reserved.
PLATFORM_CONF=/etc/opt/SUNWstnr/platform.conf
inst_dir=`grep platformDir $PLATFORM_CONF | sed -e 's/platformDir=//'`
if [ "$inst_dir" = "" ]
then
inst_dir=/opt
fi
LD_LIBRARY_PATH=$inst_dir/SUNWstnr/platform/lib/solaris/sparc
export LD_LIBRARY_PATH
echo 'content-type: text/html'
echo ''
#echo user=$WWW_unix_userid
#echo password=$WWW_unix_password
buildname=`grep buildname $PLATFORM_CONF | sed -e 's/buildname=//'`
buildversion=`grep buildversion $PLATFORM_CONF | sed -e 's/buildversion=//'`
cat << EOM
Generate S/KEY Passwords
Generate S/KEY Passwords
EOM
if [ "$WWW_unix_userid" = "" ]
then
echo '
No userid provided'
exit
fi
if [ "$WWW_pin1" = "" ]
then
echo 'No PIN provided'
exit
fi
if [ "$WWW_nkeys" = "" ]
then
echo 'No number of keys specified'
exit
fi
if [ "$WWW_pin1" != "$WWW_pin2" ]
then
echo 'PINs do not match'
exit
fi
$inst_dir/SUNWstnr/bin/chk_isnum "$WWW_nkeys"
if [ "$?" != "0" ]
then
echo 'Invalid number of keys specified'
exit
fi
$inst_dir/SUNWstnr/bin/chk_isalnum "$WWW_pin1"
if [ "$?" != "0" ]
then
echo 'Invalid PIN specified'
exit
fi
maxkeys=`grep authd.skey.maxkeys $PLATFORM_CONF | sed -e 's/authd.skey.maxkeys=//'`
maxlimit=`grep authd.skey.maxlimit $PLATFORM_CONF | sed -e 's/authd.skey.maxlimit=//'`
if [ "$maxkeys" = "" ]
then
maxkeys=100 # if no maxkeys specified
fi
if [ "$maxlimit" = "" ]
then
maxlimit=400 # if no maxlimit specified
fi
overlim=`expr $maxkeys \> $maxlimit`
if [ "$overlim" = "1" ]
then
maxkeys=$maxlimit # maxkeys can not be bigger than uneditable maxlimit (400)
fi
toobig=`expr $WWW_nkeys \> $maxkeys`
if [ "$toobig" = "1" ]
then
echo ''
echo "Too many passwords ($WWW_nkeys is larger than $maxkeys) requested."
echo ''
exit
fi
toosmall=`expr $WWW_nkeys \< 1`
if [ "$toosmall" = "1" ]
then
echo 'Too few passwords requested.'
exit
fi
echo ""
echo "Create S/KEYs for user $WWW_unix_userid
"
echo '
'
$inst_dir/SUNWstnr/bin/create_skeys $WWW_nkeys $WWW_pin1 $WWW_unix_userid
echo '
'
cat << EOM
EOM
echo ''
echo '