CodeLibary.com - code examples
  Home  Submit  Free Hosting  Link To Us  Contacts

Bash Run in restricted mode

Bash Run in restricted mode Bash Bash Run in restricted mode Download (.zip)

#!/bin/bash
# Starting the script with "#!/bin/bash -r"
# runs entire script in restricted mode.

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. <=="

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
ls -l bin.files    # Try to list attempted file creation effort.

echo

exit 0


  Sponsored Links

  Partners
My Linux Space




Home | Bookmark Us | Terms of Use | Link to us | Contact Us

Programming sites at Top100.ws Tatet 

Copyright 2007 © CodeLibary.com, All rights reserved.

Bash Run in restricted mode