[buildd-tools-devel] Bug#840883: possible fix

Martín Ferrari tincho at tincho.org
Sat Nov 12 18:16:50 UTC 2016


Hey,

I have a related issue that has been getting more and more annoying. In
this case, I want the schroot to use the host's gpg-agent, and this is
not working because schroot does not bind-mount /run/user/* directories.
Specifying /run/user in fstab does not work because each user directory
is a different tmpfs with specific options that don't get copied.

My solution to this, that might be useful to other people, is to add a
new setup script that takes care of it, and is controlled by the custom
local.mount.run-user variable.

The script is attached.

-- 
Martín Ferrari (Tincho)
-------------- next part --------------
#!/bin/sh
# Copyright © 2005-2009  Roger Leigh <rleigh at debian.org>
# Copyright © 2009       Jan-Marek Glogowski <glogow at fbihome.de>
#
# 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 3 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, see
# <http://www.gnu.org/licenses/>.
#
#####################################################################

set -e

. "$SETUP_DATA_DIR/common-data"
. "$SETUP_DATA_DIR/common-functions"
. "$SETUP_DATA_DIR/common-config"

# Mount a filesystem
# $1: mount options
# $2: mount device
# $3: mount location
do_mount()
{
    info "Mounting $2 on $3"

    if [ -h "$3" ]; then
        fatal "$3 is a symbolic link, not usable as a mountpoint"
    fi
    if [ ! -d "$3" ]; then
        mkdir -p "$3"
    fi
    if [ ! -d "$3" ]; then
        fatal "$3 does not exist, and could not be created"
    fi

    info "$MOUNT_VERBOSE $1 $2 $3"
    mount $MOUNT_VERBOSE $1 "$2" "$3"

    # Work around systemd insanity.
    #
    # Mark this mountpoint as private; some systems have / as a shared mountpoint.
    # As an example, assume /home/m/ch is the chroot directory.
    # schroot will mount -o bind /home/m/ch to /var/lib/schroot/mount/ch-123
    # Afterwards, it will bind-mount /dev to /var/lib/schroot/mount/ch-123.
    # With shared mountpoints, that mount will also show up in the original
    # /home/m/ch. This is a problem once schroot mounted /home: the following
    # mount of /tmp will show up in /var/lib/schroot/mount/ch-123/tmp,
    # /home/m/ch/tmp and /home/m/ch/home/m/ch/tmp (!), which leads to failure
    # on unmounting.
    if [ "$(uname -s)" = "Linux" ]; then
      mount --make-private "$3"
    fi
}

# Mount filesystems from fstab for all chroot types
if [ $STAGE = "setup-start" ] || [ $STAGE = "setup-recover" ]; then

    if [ "$LOCAL_MOUNT_RUN_USER" = "true" ]; then
        for user in /run/user/*; do
            [ -d "$user" ] || continue
	    do_mount "-o bind" "$user" "$CHROOT_PATH""$user"
	done
    fi

fi


More information about the Buildd-tools-devel mailing list