| 1 | #!/bin/sh |
| 2 | |
| 3 | # Copyright (C) 2002 Andres Salomon <[email protected]> |
| 4 | # |
| 5 | # Create a chroot environment for allowing users to rsync. |
| 6 | # This script is placed in the public domain. Do with it what |
| 7 | # you will. |
| 8 | |
| 9 | PATH="/usr/local/sbin:/usr/sbin:/sbin:/usr/local/bin:/bin:/usr/bin" |
| 10 | DIRECTORIES="bin dev lib usr/bin usr/lib" |
| 11 | FILES="bin/false lib/libc.so.6 lib/ld-linux.so.2 |
| 12 | bin/bash lib/libncurses.so.5 lib/libdl.so.2 |
| 13 | usr/bin/rsync lib/libpopt.so.0 lib/libresolv.so.2" |
| 14 | |
| 15 | if test -z "$1"; then |
| 16 | echo "Usage: $0 <directory>" 1>&2 |
| 17 | exit 1 |
| 18 | fi |
| 19 | |
| 20 | id=`id -u` |
| 21 | if test "$id" -gt 0; then |
| 22 | echo "Error: this script requires root (for mknod)!" 1>&2 |
| 23 | exit 1 |
| 24 | fi |
| 25 | |
| 26 | dir=$1 |
| 27 | curdir=`pwd` |
| 28 | |
| 29 | # Create directory structure |
| 30 | mkdir -p $dir |
| 31 | cd $dir |
| 32 | for d in $DIRECTORIES; do |
| 33 | mkdir -p $d |
| 34 | done |
| 35 | |
| 36 | # Add files |
| 37 | for f in $FILES; do |
| 38 | cp /$f $f |
| 39 | done |
| 40 | |
| 41 | # And devices.. |
| 42 | if test -d dev; then |
| 43 | cp /dev/MAKEDEV dev |
| 44 | cd dev && ./MAKEDEV std && rm -f MAKEDEV |
| 45 | fi |
| 46 | |
| 47 | |
| 48 | cd $curdir |
| 49 | |
| 50 | exit 0 |