[buildd-tools-devel] Bug#567932: Bug#567932: schroot: chroot failed, cleaned up my host /etc

Hamish Moffatt hamish at debian.org
Wed Feb 17 22:41:17 UTC 2010


Hi Roger,

Here are the only files which were modified. I have since put in the
versions from 1.4.0-1 and customized those and schroot is working fine.

Hamish
-------------- next part --------------
# schroot chroot definitions.
# See schroot.conf(5) for complete documentation of the file format.
#
# Please take note that you should not add untrusted users to
# root-groups, because they will essentially have full root access
# to your system.  They will only have root access inside the chroot,
# but that's enough to cause malicious damage.
#
# The following lines are examples only.  Uncomment and alter them to
# customise schroot for your needs, or create a new entry from scratch.
#
#
[sid]
description=Debian sid (unstable) 32-bit
location=/var/chroot/i386-sid
priority=3
users=hamish
root-groups=root
run-setup-scripts=true
run-exec-scripts=true
aliases=unstable,default
type=directory
personality=linux32

[etch]
description=Debian etch (4.0) 64-bit
location=/var/chroot/amd64-etch
priority=3
users=hamish
root-groups=root
run-setup-scripts=true
type=directory

[gutsy]
description=Ubuntu Gutsy 64-bit
location=/var/chroot/amd64-gutsy
priority=3
users=hamish
root-groups=root
run-setup-scripts=true
type=directory

[gutsy32]
description=Ubuntu Gutsy 32-bit
location=/var/chroot/i386-gutsy
priority=3
users=hamish
root-groups=root
run-setup-scripts=true
type=directory
personality=linux32

[etch32]
description=Debian etch (4.0) 32-bit
location=/var/chroot/i386-etch
priority=3
users=hamish
root-groups=root
run-setup-scripts=true
type=directory
personality=linux32

[feisty]
description=Ubuntu Feisty (7.04) 32-bit
location=/var/chroot/i386-feisty
priority=3
users=hamish
root-groups=root
run-setup-scripts=true
type=directory
personality=linux32

#
#[sid-snap]
#type=lvm-snapshot
#description=Debian sid snapshot
##location=/srv/chroot/sid
#priority=3
#groups=sbuild,root
#root-users=rleigh
#root-groups=root,sbuild
#source-root-users=rleigh
#device=/dev/hda_vg/sid_chroot
#mount-options=-o atime,sync,user_xattr
#lvm-snapshot-options=--size 2G
#run-setup-scripts=true
#run-exec-scripts=true
#
#[etch]
#description=Debian etch (testing) 32-bit
#location=/srv/chroot/etch
#priority=3
#groups=sbuild-security
#aliases=testing
#run-setup-scripts=false
#run-exec-scripts=false
#personality=linux32
#
#[sarge]
#description=Debian sarge (stable)
#location=/srv/chroot/sarge
#priority=2
#groups=sbuild
#aliases=stable
#
#[sarge-file]
#description=Debian sarge (stable)
#file=/srv/chroot/sarge.tar.gz
#priority=2
#groups=sbuild
#
#[sarge-secure]
#description=Debian sarge (stable)
#location=/srv/chroot/sarge
#priority=2
#groups=sbuild-security
#aliases=stable-security
#
#[experimental]
#type=block-device
#description=Debian experimental (unstable)
#priority=4
#groups=sbuild,root
#root-groups=root,sbuild
#aliases=unstable,default
#device=/dev/hda_vg/experimental_chroot
#mount-options=-o atime,sync,user_xattr
#location=/experimental
#run-setup-scripts=true
#run-exec-scripts=true
-------------- next part --------------
#!/bin/sh
# Copyright ? 2005-2007  Roger Leigh <rleigh at debian.org>
#
# schroot is free software; you can redistribute it and/or modify it
# under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# schroot is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
# General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston,
# MA  02111-1307  USA

set -e

if [ -f "$CHROOT_SCRIPT_CONFIG" ]; then
  . "$CHROOT_SCRIPT_CONFIG"
fi

# Mount a filesystem
# $1: mount options
# $2: mount device
# $3: mount location
do_mount()
{
    if [ "$AUTH_VERBOSITY" = "verbose" ]; then
	echo "Mounting $2 on $3"
    fi

    if [ ! -d "$3" ]; then
	mkdir -p "$3"
    fi
    if [ ! -d "$3" ]; then
	echo "$3 does not exist, and could not be created"
	exit 1
    fi

    mount $VERBOSE $1 "$2" "$3"
}

# Unmount all filesystem under specified location
# $1: mount base location
do_umount_all()
{
    mounts="$("$LIBEXEC_DIR/schroot-listmounts" -m "$1")"
    if [ "x$mounts" != 'x' ]; then
        echo "$mounts" |
        while read mountloc; do
	    if [ "$AUTH_VERBOSITY" = "verbose" ]; then
                echo "Unmounting $mountloc"
	    fi
	    umount "$mountloc" || exit 1
        done || exit 1
    fi
}

if [ "$AUTH_VERBOSITY" = "verbose" ]; then
  VERBOSE="-v"
#  FSCK_VERBOSE="-V"
fi

if [ "$CHROOT_TYPE" = "plain" ] || [ "$CHROOT_TYPE" = "directory" ] || [ "$CHROOT_TYPE" = "file" ] || [ "$CHROOT_TYPE" = "block-device" ] || [ "$CHROOT_TYPE" = "lvm-snapshot" ]; then

    if [ "$CHROOT_TYPE" = "plain" ]; then
	CHROOT_MOUNT_OPTIONS="--rbind"
	CHROOT_MOUNT_DEVICE="$CHROOT_LOCATION"
    elif [ "$CHROOT_TYPE" = "directory" ]; then
	CHROOT_MOUNT_OPTIONS="--bind"
	CHROOT_MOUNT_DEVICE="$CHROOT_LOCATION"
    elif [ "$CHROOT_TYPE" = "lvm-snapshot" ]; then
	CHROOT_MOUNT_OPTIONS=""
	CHROOT_MOUNT_DEVICE="$CHROOT_LVM_SNAPSHOT_DEVICE"
    fi

    if [ $1 = "setup-start" ] || [ $1 = "setup-recover" ]; then

        # fsck doesn't like being run non-interactively
	#/sbin/fsck $FSCK_VERBOSE -n "$CHROOT_MOUNT_DEVICE"

        if [ ! -d "$CHROOT_MOUNT_LOCATION" ]; then
	    mkdir -p "$CHROOT_MOUNT_LOCATION"
        fi
	if [ ! -d "$CHROOT_MOUNT_LOCATION" ]; then
	    echo "$CHROOT_MOUNT_LOCATION does not exist, and could not be created"
	    exit 1
	fi

        # If recovering, we want to remount all filesystems to ensure
        # a sane state.
	if [ $1 = "setup-recover" ]; then
	    do_umount_all "$CHROOT_MOUNT_LOCATION"
	fi

	if [ "$CHROOT_TYPE" != "file" ]; then
	    do_mount "$CHROOT_MOUNT_OPTIONS" "$CHROOT_MOUNT_DEVICE" "$CHROOT_MOUNT_LOCATION"
	fi

	if [ "$CHROOT_TYPE" != "plain" ]; then
	    do_mount "-t proc"    "proc"     "${CHROOT_PATH}/proc"
	    #do_mount "-o rw,bind" "/dev/pts" "${CHROOT_PATH}/dev/pts"
	    do_mount "-o rw,bind" "/dev" "${CHROOT_PATH}/dev"
	    do_mount "-t tmpfs"   "tmpfs"    "${CHROOT_PATH}/dev/shm"
	    do_mount "-o rw,bind" "/home"    "${CHROOT_PATH}/home"
	    do_mount "-o rw,bind" "/tmp"     "${CHROOT_PATH}/tmp"
	    do_mount "-o rw,rbind" "/srv"     "${CHROOT_PATH}/srv"
	fi

    elif [ $1 = "setup-stop" ]; then

	do_umount_all "$CHROOT_MOUNT_LOCATION"

	if [ "$CHROOT_TYPE" != "file" ]; then
	    if echo "$CHROOT_MOUNT_LOCATION" | grep -q "^$MOUNT_DIR/"; then
		if [ -d "$CHROOT_MOUNT_LOCATION" ]; then
		    rmdir "$CHROOT_MOUNT_LOCATION"
		fi
	    fi
	fi

    fi

fi



More information about the Buildd-tools-devel mailing list