source: trunk/debathena/third/schroot/etc/setup.d/00check @ 24170

Revision 24170, 4.5 KB checked in by broder, 14 years ago (diff)
Fix /etc/setup.d/00check to permit union chroots on the root filesystem. It's only unsafe for the chroot directory to be the root directory if we're not doing a union filesystem on top of it. Note that to make this useful, you'll need to make the overlay a separate filesystem (e.g., by mounting a tmpfs on /var/lib/schroot/union/overlay) for aufs to permit the mount. Patch by Geoffrey Thomas.
  • Property svn:executable set to *
Line 
1#!/bin/sh
2# Copyright © 2005-2009  Roger Leigh <rleigh@debian.org>
3#
4# schroot is free software: you can redistribute it and/or modify it
5# under the terms of the GNU General Public License as published by
6# the Free Software Foundation, either version 3 of the License, or
7# (at your option) any later version.
8#
9# schroot is distributed in the hope that it will be useful, but
10# WITHOUT ANY WARRANTY; without even the implied warranty of
11# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
12# General Public License for more details.
13#
14# You should have received a copy of the GNU General Public License
15# along with this program.  If not, see
16# <http://www.gnu.org/licenses/>.
17#
18#####################################################################
19
20set -e
21
22# Plain chroots should not be able to use scripts, but check anyway to
23# be safe.
24if [ $CHROOT_TYPE = "plain" ]; then
25    exit 1
26fi
27
28if [ -f "$CHROOT_SCRIPT_CONFIG" ]; then
29    . "$CHROOT_SCRIPT_CONFIG"
30elif [ "$2" = "ok" ]; then
31    echo "script-config file '$CHROOT_SCRIPT_CONFIG' does not exist"
32    exit 1
33fi
34
35# Skip if run at inappropriate point.
36if [ $1 = "setup-start" ] || [ $1 = "setup-recover" ] && [ "$(basename "$0")" = "99check" ]; then
37    exit 0;
38elif [ $1 = "setup-stop" ] && [ "$(basename "$0")" = "00check" ]; then
39    exit 0;
40fi
41
42if [ "$AUTH_VERBOSITY" = "verbose" ]; then
43    echo "AUTH_USER=$AUTH_USER"
44    echo "AUTH_RUSER=$AUTH_RUSER"
45    echo "AUTH_RGROUP=$AUTH_RGROUP"
46    echo "AUTH_UID=$AUTH_UID"
47    echo "AUTH_GID=$AUTH_GID"
48    echo "AUTH_RUID=$AUTH_RUID"
49    echo "AUTH_RGID=$AUTH_RGID"
50    echo "AUTH_HOME=$AUTH_HOME"
51    echo "AUTH_SHELL=$AUTH_SHELL"
52    echo "AUTH_VERBOSITY=$AUTH_VERBOSITY"
53    echo "MOUNT_DIR=$MOUNT_DIR"
54    echo "LIBEXEC_DIR=$LIBEXEC_DIR"
55    echo "PID=$PID"
56    echo "SESSION_ID=$SESSION_ID"
57    echo "CHROOT_TYPE=$CHROOT_TYPE"
58    echo "CHROOT_NAME=$CHROOT_NAME"
59    echo "CHROOT_DESCRIPTION=$CHROOT_DESCRIPTION"
60    echo "CHROOT_SCRIPT_CONFIG=$CHROOT_SCRIPT_CONFIG"
61    echo "CHROOT_MOUNT_LOCATION=$CHROOT_MOUNT_LOCATION"
62    echo "CHROOT_LOCATION=$CHROOT_LOCATION"
63    echo "CHROOT_PATH=$CHROOT_PATH"
64    if [ -n "$CHROOT_UNION_TYPE" ] && [ "$CHROOT_UNION_TYPE" != "none" ]; then
65        echo "CHROOT_UNION_TYPE=$CHROOT_UNION_TYPE"
66        echo "CHROOT_UNION_OVERLAY_DIRECTORY=$CHROOT_UNION_OVERLAY_DIRECTORY"
67        echo "CHROOT_UNION_UNDERLAY_DIRECTORY=$CHROOT_UNION_UNDERLAY_DIRECTORY"
68    fi
69    if [ "$CHROOT_TYPE" = "directory" ]; then
70        echo "CHROOT_DIRECTORY=$CHROOT_DIRECTORY"
71    elif [ "$CHROOT_TYPE" = "file" ]; then
72        echo "CHROOT_FILE=$CHROOT_FILE"
73        echo "CHROOT_FILE_REPACK=$CHROOT_FILE_REPACK"
74        echo "CHROOT_FILE_UNPACK_DIR=$CHROOT_FILE_UNPACK_DIR"
75    elif [ "$CHROOT_TYPE" = "block-device" ] || [ "$CHROOT_TYPE" = "lvm-snapshot" ]; then
76        echo "CHROOT_DEVICE=$CHROOT_DEVICE"
77        echo "CHROOT_MOUNT_OPTIONS=$CHROOT_MOUNT_OPTIONS"
78        if [ "$CHROOT_TYPE" = "lvm-snapshot" ]; then
79            echo "CHROOT_LVM_SNAPSHOT_NAME=$CHROOT_LVM_SNAPSHOT_NAME"
80            echo "CHROOT_LVM_SNAPSHOT_DEVICE=$CHROOT_LVM_SNAPSHOT_DEVICE"
81            echo "CHROOT_LVM_SNAPSHOT_OPTIONS=$CHROOT_LVM_SNAPSHOT_OPTIONS"
82        fi
83    fi
84    echo "CHROOT_SESSION_CREATE=$CHROOT_SESSION_CREATE"
85    echo "CHROOT_SESSION_CLONE=$CHROOT_SESSION_CLONE"
86    echo "CHROOT_SESSION_PURGE=$CHROOT_SESSION_PURGE"
87    echo "FSTAB=$FSTAB"
88    echo "NSSDATABASES=$NSSDATABASES"
89fi
90
91case "$CHROOT_TYPE" in
92    directory)
93        if [ ! -d "$CHROOT_DIRECTORY" ]; then
94            echo "Directory '$CHROOT_DIRECTORY' does not exist"
95            exit 1
96        fi
97        if [ "$CHROOT_UNION_TYPE" != "none" ]; then
98            if [ ! -d "$CHROOT_UNION_OVERLAY_DIRECTORY" ] \
99                && [ $1 = "setup-recover" ];
100            then
101                echo "Directory '$CHROOT_UNION_OVERLAY_DIRECTORY' does not exist"
102                exit 1
103            fi
104            if [ ! -d "$CHROOT_UNION_UNDERLAY_DIRECTORY" ] \
105                    && [ $1 = "setup-recunder" ];
106                then
107                echo "Directory '$CHROOT_UNION_UNDERLAY_DIRECTORY' does not exist"
108                exit 1
109            fi
110        fi
111        ;;
112    file | loopback)
113        if [ ! -f "$CHROOT_FILE" ]; then
114            echo "File '$CHROOT_FILE' does not exist"
115            exit 1
116        fi
117        ;;
118    block-device | lvm-snapshot)
119        if [ ! -b "$CHROOT_DEVICE" ]; then
120            echo "Device '$CHROOT_DEVICE' does not exist"
121            exit 1
122        fi
123        ;;
124    *)
125        echo "Unknown chroot type $CHROOT_TYPE"
126        exit 1
127        ;;
128esac
129
130# A basic safety check, so that the root filesystem doesn't get
131# toasted by accident.
132if [ -z "$CHROOT_PATH" ] \
133    || [ "$CHROOT_PATH" = "/" ] \
134    || ( [ -z "$CHROOT_UNION_TYPE" ] \
135         && [ "$CHROOT_DIRECTORY" = "/" ] ) \
136    || [ "$CHROOT_UNION_OVERLAY_DIRECTORY" = "/" ]
137then
138    echo "Invalid chroot mount path or directory"
139    exit 1
140fi
Note: See TracBrowser for help on using the repository browser.