LDP/LDP/guide/docbook/abs-guide/restricted.sh

48 lines
770 B
Bash
Raw Permalink Normal View History

2001-07-10 14:25:50 +00:00
#!/bin/bash
2005-06-05 14:39:50 +00:00
# Starting the script with "#!/bin/bash -r"
#+ runs entire script in restricted mode.
2001-07-10 14:25:50 +00:00
echo
echo "Changing directory."
cd /usr/local
echo "Now in `pwd`"
echo "Coming back home."
cd
echo "Now in `pwd`"
echo
# Everything up to here in normal, unrestricted mode.
set -r
# set --restricted has same effect.
echo "==> Now in restricted mode. <=="
2001-07-10 14:25:50 +00:00
echo
echo
echo "Attempting directory change in restricted mode."
cd ..
echo "Still in `pwd`"
echo
echo
echo "\$SHELL = $SHELL"
echo "Attempting to change shell in restricted mode."
SHELL="/bin/ash"
echo
echo "\$SHELL= $SHELL"
echo
echo
echo "Attempting to redirect output in restricted mode."
ls -l /usr/bin > bin.files
2001-09-04 13:27:31 +00:00
ls -l bin.files # Try to list attempted file creation effort.
2001-07-10 14:25:50 +00:00
echo
exit 0