restricted.sh revision 7c2fbfb345896881c631598ee3852ce9ce33fb07
########################################################################
# #
# This software is part of the ast package #
# Copyright (c) 1982-2008 AT&T Intellectual Property #
# and is licensed under the #
# Common Public License, Version 1.0 #
# by AT&T Intellectual Property #
# #
# A copy of the License is available at #
# (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) #
# #
# Information and Software Systems Research #
# AT&T Research #
# Florham Park NJ #
# #
# David Korn <dgk@research.att.com> #
# #
########################################################################
function err_exit
{
print -u2 -n "\t"
let Errors+=1
}
alias err_exit='err_exit $LINENO'
# test restricted shell
integer Errors=0
pwd=$PWD
/*) ;;
esac
function check_restricted
{
grep restricted out > /dev/null 2>&1
}
> empty
print 'echo hello' > script
print 'echo hello> file' > script
! check_restricted script || err_exit 'script with output redirection should run in restricted mode'
print 'PATH=/bin' > script
#! $SHELL
print hello
!
! check_restricted 'script' || err_exit 'script with #! pathname should run in restricted mode even if last command in script'