From: Serge Hallyn Date: Tue, 31 Jul 2012 14:01:28 +0000 (+0200) Subject: ubuntu template: install bound user's shell X-Git-Tag: lxc-0.8.0~44 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=39aa5856f03898a84684c074ffb35bd0fa538b23;p=thirdparty%2Flxc.git ubuntu template: install bound user's shell If a host user is bound into the container (-b), make sure that his shell is installed in the container. Signed-off-by: Serge Hallyn Signed-off-by: Daniel Lezcano --- diff --git a/templates/lxc-ubuntu.in b/templates/lxc-ubuntu.in index f3fb8dcc4..f31bc789c 100644 --- a/templates/lxc-ubuntu.in +++ b/templates/lxc-ubuntu.in @@ -506,20 +506,31 @@ do_bindhome() user=$2 # copy /etc/passwd, /etc/shadow, and /etc/group entries into container - pwd=`getent passwd $user` - if [ $? -ne 0 ]; then - echo 'Warning: failed to copy password entry for $user' - return - else - echo $pwd >> $rootfs/etc/passwd + pwd=`getent passwd $user` || { echo "Failed to copy password entry for $user"; false; } + echo $pwd >> $rootfs/etc/passwd + + # make sure user's shell exists in the container + shell=`echo $pwd | cut -d: -f 7` + if [ ! -x $rootfs/$shell ]; then + echo "shell $shell for user $user was not found in the container." + pkg=`dpkg -S $(readlink -m $shell) | cut -d ':' -f1` + echo "Installing $pkg" + chroot $rootfs apt-get --force-yes -y install $pkg fi + shad=`getent shadow $user` - echo $shad >> $rootfs/etc/shadow + echo "$shad" >> $rootfs/etc/shadow # bind-mount the user's path into the container's /home h=`getent passwd $user | cut -d: -f 6` mkdir -p $rootfs/$h echo "$h $rootfs/$h none bind 0 0" >> $path/fstab + + # Make sure the group exists in container + chroot $rootfs getent group $user || { \ + grp=`getent group $user` + echo "$grp" >> $rootfs/etc/group + } } usage()