#!/bin/sh -eu
#
# $Id: frgenshmackey,v 1.1 2000/07/24 22:25:37 bill Exp $
#
# Generate the MAC key shared by the nym server and the
# mail system.
#
# We expect this script to be on a floppy disk containing
# an ext2 file system.  The user will run it to generate
# the MAC key, which will be written to the floppy.  The
# script will also write a second small script to install
# the MAC key on the destination machine.
#

PATH=/bin:/usr/bin

. ./.fns.sh

if [ `id -u` -ne $uid ] ; then
  error "you must be root to run this script."
fi

if [ "$0" != "./${prog}" ] ; then
  error "you *must* run the script as ./${prog}, from the directory containing it"
fi

cat <<EOF

               Nymserver/Mail System Shared MAC Key Generation


  This script reads from /dev/random.  If it appears to hang, then type
  randomly or wiggle the mouse.

EOF

# Generate the secret

umask 0077
rm -f $mkfile
dd if=/dev/random bs=1 count=20 of=$mkfile 2>/dev/null
chown root $mkfile
chmod 000 $mkfile

cat <<EOF | fmt -c -u

  The shared, secret MAC key is stored in $mkfile on the floppy disk.  It
  is stored in the clear, so *do not* copy it to any place other than its
  final destinations on the nym server and mail system machines.

  Use the script frcpyshmackey, also on this floppy, to copy the MAC key
  to both the nym server and the mail system host.

EOF

exit 0
