#!/bin/sh

# Generate the Permissions file from the Systems file
#   Add any machines which do not have obvious log-in names.
#   Obvious names are those which consist of the remote machine name
#   prefixed with "U", and limited to 8 characters.

# Let anyone use nuucp, provided there is no password on the account.
# This is needed for UUCP over TCP.

# "$Revision: 1.6 $"


CURPERM=/etc/uucp/Permissions
NEWPERM=$CURPERM.new
OLDPERM=$CURPERM.old
MARK='# generated entries'

exec > $NEWPERM
sed -e "/^$MARK/,\$d" $CURPERM
echo "$MARK"

chown uucp $NEWPERM
chmod og-rw $NEWPERM

(echo nuucp; uuname) | sed  -e '/^nuucp$/s/.*/& &/'		\
		-e '/^bettysue$/s/.*/& Udallas/'		\
		-e '/^nsg$/s/.*/& Unsg/'			\
	    -e 's/^[^ ]*$/& U&/'				\
	    -e 's/^\(.* .\{1,8\}\).*/\1/'			\
	    -e 's@\(.*\) \(.*\)@LOGNAME=\2 MACHINE=\1 SENDFILES=yes REQUEST=yes COMMANDS=/bin/rmail:/usr/bin/rnews:/usr/lib/news/cunbatch READ=/var/spool/uucppublic:/usr/lib/mail:/usr/people/ftp@' \
	    -e '/LOGNAME=nuucp/s/MACHINE=nuucp //'		\
	>> $NEWPERM

ln $CURPERM $OLDPERM
mv $NEWPERM $CURPERM
