blob: 6d5a2a36cb78d6cffd200d9f2476d11deb75100d [file] [log] [blame] [raw]
#!/bin/sh
are_all_executable_regular_files() {
#local f
for f in "$@"; do
[ -f "$f" ] && [ -x "$f" ] || return
done
}
export SHELL=/bin/sh
LOG_FILE="/var/log/noshell/$USER.`date -u +%F.%H-%M-%S`"
[ -d /tmp/playground ] || mkdir /tmp/playground
cd /tmp/playground
export HOME=/tmp/playground
if [ "$1" = -t ] || { [ ! -f /etc/rshrc ] && ! are_all_executable_regular_files /usr/games/dungeon /opt/dungeon/dungeon; }; then
exec script -c "export SHELL=/usr/bin/telnet; exec /usr/bin/telnet" -fqt $LOG_FILE 2> $LOG_FILE.time
fi
if [ -f /etc/rshrc ]; then
UESLESS_SHELL="/bin/bash --restricted --noprofile --rcfile /etc/rshrc"
else
UESLESS_SHELL="/usr/games/dungeon"
fi
exec script -c "export SHELL=/bin/noshellhere; export PATH=/dev/pts; exec $UESLESS_SHELL" -fqt $LOG_FILE 2> $LOG_FILE.time