Commit 39aa5856 by Serge Hallyn Committed by Daniel Lezcano

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: 's avatarSerge Hallyn <serge.hallyn@ubuntu.com> Signed-off-by: 's avatarDaniel Lezcano <dlezcano@fr.ibm.com>
parent 7b605a1d
...@@ -506,20 +506,31 @@ do_bindhome() ...@@ -506,20 +506,31 @@ do_bindhome()
user=$2 user=$2
# copy /etc/passwd, /etc/shadow, and /etc/group entries into container # copy /etc/passwd, /etc/shadow, and /etc/group entries into container
pwd=`getent passwd $user` pwd=`getent passwd $user` || { echo "Failed to copy password entry for $user"; false; }
if [ $? -ne 0 ]; then
echo 'Warning: failed to copy password entry for $user'
return
else
echo $pwd >> $rootfs/etc/passwd 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 fi
shad=`getent shadow $user` 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 # bind-mount the user's path into the container's /home
h=`getent passwd $user | cut -d: -f 6` h=`getent passwd $user | cut -d: -f 6`
mkdir -p $rootfs/$h mkdir -p $rootfs/$h
echo "$h $rootfs/$h none bind 0 0" >> $path/fstab 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() usage()
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment