File: setup-chrootdir-rsync.sh

package info (click to toggle)
libpam-chroot 0.9-3
  • links: PTS
  • area: main
  • in suites: lenny, squeeze
  • size: 132 kB
  • ctags: 52
  • sloc: ansic: 740; sh: 104; makefile: 50
file content (50 lines) | stat: -rw-r--r-- 932 bytes parent folder | download | duplicates (8)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
#!/bin/sh

# Copyright (C) 2002  Andres Salomon <dilinger@voxel.net>
#
# Create a chroot environment for allowing users to rsync.
# This script is placed in the public domain.  Do with it what
# you will.

PATH="/usr/local/sbin:/usr/sbin:/sbin:/usr/local/bin:/bin:/usr/bin"
DIRECTORIES="bin dev lib usr/bin usr/lib"
FILES="bin/false lib/libc.so.6 lib/ld-linux.so.2
		bin/bash lib/libncurses.so.5 lib/libdl.so.2
		usr/bin/rsync lib/libpopt.so.0 lib/libresolv.so.2"

if test -z "$1"; then
	echo "Usage: $0 <directory>" 1>&2
	exit 1
fi

id=`id -u`
if test "$id" -gt 0; then
	echo "Error: this script requires root (for mknod)!" 1>&2
	exit 1
fi

dir=$1
curdir=`pwd`

# Create directory structure
mkdir -p $dir
cd $dir
for d in $DIRECTORIES; do
	mkdir -p $d
done

# Add files
for f in $FILES; do
	cp /$f $f
done

# And devices..
if test -d dev; then
	cp /dev/MAKEDEV dev
	cd dev && ./MAKEDEV std && rm -f MAKEDEV
fi


cd $curdir

exit 0