#!/bin/sh

. /etc/control.d/functions

BINARY_RSH=/usr/bin/rsh
BINARY_RCP=/usr/bin/rcp
BINARY_RLOGIN=/usr/bin/rlogin
BINARIES="$BINARY_RSH $BINARY_RCP $BINARY_RLOGIN"

new_fmode public 4711 root root
new_fmode netadmin 4710 root netadmin
new_fmode restricted 700 root root

new_help public "Any user can execute $BINARIES"
new_help netadmin "Only \"netadmin\" group members can execute $BINARIES"
new_help restricted "Only root can execute $BINARIES"

if is_builtin_mode "$*"; then
	case "$*" in
	status|'')	# if there's more than a line it's a question...
		for f in $BINARIES; do
			control_fmode "$f" status || exit 1
		done | sort -u | sed 'N; { s/.*\n.*/unknown/; }'
		;;
	*)
		control_fmode "$BINARY_RSH" "$*"
		;;
	esac
else
	for f in $BINARIES; do
		control_fmode "$f" "$*" || exit 1
	done
fi
