Cover V02, I06
Article
Listing 1
Listing 2

nov93.tar


Listing 2: key shell function

#
# key() shell function (for inclusion in your .profile)
# Interactive crypt key assignment function.
# Usage: key
#

CRYPT_KEY_VAR=CrYpTkEy              # SCO Unix
export CRYPT_KEY_VAR

key()
{
trap 'stty echo >/dev/null; echo "User interrupt. \c" >&2; \
TRAPPED=Y; return' 1 2 3 14 15

eval "oldkey=\$$CRYPT_KEY_VAR"

echo "Enter CRYPT key: \c">&2
stty -echo
read newkey
stty echo
case "$newkey" in
"$oldkey"|"")
if [ "$TRAPPED" = "" ]; then
if [ -n "$newkey" ]; then
echo "\n(Same as existing key)"
else
echo "\nNull key not allowed."
fi
return
fi
unset TRAPPED
if [ -n "$oldkey" ]; then
echo "\nKey unchanged."
else
echo "No key currently defined."
fi
return;;

"\n")
echo "Null key not allowed.";;

*)

eval "$CRYPT_KEY_VAR=$newkey; export $CRYPT_KEY_VAR"
echo "\nNew Crypt Key set.">&2;;
esac
}