| 1 | #!/bin/shscip-shell filesystem . . `/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/binscip-shell filesystem . . `/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 testscip-shell system . . test. -z "$1"; then |
| 16 | echoscip-shell system . . echo. "Usage: $0 <directory>" 1>&2 |
| 17 | exit 1 |
| 18 | fi |
| 19 | |
| 20 | id=`idscip-shell system . . id. -u` |
| 21 | if testscip-shell system . . test. "$id" -gt 0; then |
| 22 | echoscip-shell system . . echo. "Error: this script requires root (for mknod)!" 1>&2 |
| 23 | exit 1 |
| 24 | fi |
| 25 | |
| 26 | dir=$1 |
| 27 | curdir=`pwdscip-shell system . . pwd.` |
| 28 | |
| 29 | # Create directory structure |
| 30 | mkdirscip-shell system . . mkdir. -p $dir |
| 31 | cd $dir |
| 32 | for d in $DIRECTORIES; do |
| 33 | mkdirscip-shell system . . mkdir. -p $d |
| 34 | done |
| 35 | |
| 36 | # Add files |
| 37 | for f in $FILES; do |
| 38 | cpscip-shell system . . cp. /$f $f |
| 39 | done |
| 40 | |
| 41 | # And devices.. |
| 42 | if testscip-shell system . . test. -d dev; then |
| 43 | cpscip-shell system . . cp. /dev/MAKEDEVscip-shell filesystem . . `/dev/MAKEDEV`. dev |
| 44 | cd dev && ./MAKEDEV std && rmscip-shell system . . rm. -f MAKEDEV |
| 45 | fi |
| 46 | |
| 47 | |
| 48 | cd $curdir |
| 49 | |
| 50 | exit 0 |