[1] | 1 | #! /bin/sh
|
---|
| 2 |
|
---|
| 3 | # NOTE: tested on Debian Linux
|
---|
| 4 | #
|
---|
| 5 | # NO WARRANTY - may or may not work on your system
|
---|
| 6 | #
|
---|
| 7 |
|
---|
| 8 | # Copyright Rainer Wichmann (2003)
|
---|
| 9 | #
|
---|
| 10 | # License Information:
|
---|
| 11 | # This program is free software; you can redistribute it and/or modify
|
---|
| 12 | # it under the terms of the GNU General Public License as published by
|
---|
| 13 | # the Free Software Foundation; either version 2 of the License, or
|
---|
| 14 | # (at your option) any later version.
|
---|
| 15 | #
|
---|
| 16 | # This program is distributed in the hope that it will be useful,
|
---|
| 17 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
|
---|
| 18 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
---|
| 19 | # GNU General Public License for more details.
|
---|
| 20 | #
|
---|
| 21 | # You should have received a copy of the GNU General Public License
|
---|
| 22 | # along with this program; if not, write to the Free Software
|
---|
| 23 | # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
---|
| 24 | #
|
---|
| 25 |
|
---|
| 26 |
|
---|
| 27 | CHROOT=$1
|
---|
| 28 |
|
---|
| 29 | SYSTEM=`uname -s`
|
---|
| 30 |
|
---|
| 31 | if test "x$SYSTEM" = xLinux; then
|
---|
| 32 | :
|
---|
| 33 | else
|
---|
| 34 | echo "This script will fail on systems other than Linux,"
|
---|
| 35 | echo "mainly because of the mknod commands to create devices"
|
---|
| 36 | echo "in the chroot jail."
|
---|
| 37 | exit 1
|
---|
| 38 | fi
|
---|
| 39 |
|
---|
| 40 | if test "x$CHROOT" = x; then
|
---|
| 41 | echo "Usage: chroot.sh chroot_dir"
|
---|
| 42 | echo "Purpose: prepare a chroot jail for yule"
|
---|
| 43 | echo
|
---|
| 44 | echo "NOTE: tested on Debian Linux"
|
---|
| 45 | echo "NO WARRANTY - may or may not work on your system"
|
---|
| 46 | exit 1
|
---|
| 47 | fi
|
---|
| 48 |
|
---|
| 49 | #
|
---|
| 50 | # Link configuration file
|
---|
| 51 | #
|
---|
| 52 | echo " Link configuration file:"
|
---|
| 53 | echo " ln -s ${CHROOT}/etc/yulerc /etc/yulerc"
|
---|
| 54 |
|
---|
| 55 | ln -s -f ${CHROOT}/etc/yulerc /etc/yulerc
|
---|
| 56 | echo
|
---|
| 57 |
|
---|
| 58 |
|
---|
| 59 | #
|
---|
| 60 | # Create passwd file
|
---|
| 61 | #
|
---|
| 62 | echo " Create passwd file"
|
---|
| 63 | echo " grep root /etc/passwd > ${CHROOT}/etc/passwd"
|
---|
| 64 | echo " grep daemon /etc/passwd >> ${CHROOT}/etc/passwd"
|
---|
| 65 | echo " grep yule /etc/passwd >> ${CHROOT}/etc/passwd"
|
---|
| 66 |
|
---|
| 67 | grep root /etc/passwd > ${CHROOT}/etc/passwd
|
---|
| 68 | grep daemon /etc/passwd >> ${CHROOT}/etc/passwd
|
---|
| 69 | grep yule /etc/passwd >> ${CHROOT}/etc/passwd
|
---|
| 70 | echo
|
---|
| 71 |
|
---|
| 72 |
|
---|
| 73 | #
|
---|
| 74 | # Create group file
|
---|
| 75 | #
|
---|
| 76 | echo " Create group file"
|
---|
| 77 | echo " grep root /etc/group > ${CHROOT}/etc/group"
|
---|
| 78 | echo " grep daemon /etc/group >> ${CHROOT}/etc/group"
|
---|
| 79 | echo " grep yule /etc/group >> ${CHROOT}/etc/group"
|
---|
| 80 |
|
---|
| 81 | grep root /etc/group > ${CHROOT}/etc/group
|
---|
| 82 | grep daemon /etc/group >> ${CHROOT}/etc/group
|
---|
| 83 | grep yule /etc/group >> ${CHROOT}/etc/group
|
---|
| 84 | echo
|
---|
| 85 |
|
---|
| 86 | #
|
---|
| 87 | # Create devices
|
---|
| 88 | #
|
---|
| 89 | echo " Create devices"
|
---|
| 90 | echo " mkdir ${CHROOT}/dev"
|
---|
| 91 | echo " mknod -m 444 ${CHROOT}/dev/urandom c 1 9"
|
---|
| 92 | echo " mknod -m 666 ${CHROOT}/dev/random c 1 8"
|
---|
| 93 | echo " mknod -m 666 ${CHROOT}/dev/null c 1 3"
|
---|
| 94 | echo " mknod -m 666 ${CHROOT}/dev/null c 1 5"
|
---|
| 95 |
|
---|
| 96 | mkdir ${CHROOT}/dev
|
---|
| 97 | mknod -m 444 ${CHROOT}/dev/urandom c 1 9
|
---|
| 98 | mknod -m 666 ${CHROOT}/dev/random c 1 8
|
---|
| 99 | mknod -m 666 ${CHROOT}/dev/null c 1 3
|
---|
| 100 | mknod -m 666 ${CHROOT}/dev/zero c 1 5
|
---|
| 101 | echo
|
---|
| 102 |
|
---|
| 103 | #
|
---|
| 104 | # DNS
|
---|
| 105 | #
|
---|
| 106 | echo " Copy files for DNS"
|
---|
| 107 | echo " cp -p /etc/nsswitch.conf ${CHROOT}/etc/"
|
---|
| 108 | echo " cp -p /etc/hosts ${CHROOT}/etc/"
|
---|
| 109 | echo " cp -p /etc/host.conf ${CHROOT}/etc/"
|
---|
| 110 | echo " cp -p /etc/resolv.conf ${CHROOT}/etc/"
|
---|
| 111 | echo " cp -p /etc/services ${CHROOT}/etc/"
|
---|
| 112 | echo " cp -p /etc/protocols ${CHROOT}/etc/"
|
---|
| 113 |
|
---|
| 114 | cp -p /etc/nsswitch.conf ${CHROOT}/etc/
|
---|
| 115 | cp -p /etc/hosts ${CHROOT}/etc/
|
---|
| 116 | cp -p /etc/host.conf ${CHROOT}/etc/
|
---|
| 117 | cp -p /etc/resolv.conf ${CHROOT}/etc/
|
---|
| 118 | cp -p /etc/services ${CHROOT}/etc/
|
---|
| 119 | cp -p /etc/protocols ${CHROOT}/etc/
|
---|
| 120 |
|
---|
| 121 | echo "----------------------------------------------------"
|
---|
| 122 | echo
|
---|
| 123 | echo " You may want to review ${CHROOT}/etc/passwd"
|
---|
| 124 | echo " to replace passwords with a *, and to fix the"
|
---|
| 125 | echo " path to the home directory of the yule user."
|
---|
| 126 | echo
|
---|
| 127 | echo " If using a signed configuration file, you need"
|
---|
| 128 | echo " a working copy of GnuPG inside the chroot jail."
|
---|
| 129 | echo
|
---|
| 130 | echo "----------------------------------------------------"
|
---|
| 131 | |
---|