aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSerge E. Hallyn <serge.hallyn@canonical.com>2011-10-24 14:47:58 +0200
committerDaniel Lezcano <daniel.lezcano@free.fr>2011-10-24 14:47:58 +0200
commit8565ea1c6f8285ca14fc3025791cd6b6576e4639 (patch)
tree8ac2561239349140671b337a1d859bfa34dfd605 /templates
parentDon't list containers w/ active console sessions multiple times (diff)
downloadlxc-8565ea1c6f8285ca14fc3025791cd6b6576e4639.tar.gz
lxc-8565ea1c6f8285ca14fc3025791cd6b6576e4639.tar.bz2
lxc-8565ea1c6f8285ca14fc3025791cd6b6576e4639.zip
lxc-ubuntu: stop early if a bad user is specified in -b option
Otherwise we end up with a bad container fstab and a container that won't boot. See https://bugs.launchpad.net/ubuntu/+source/lxc/+bug/879052 Signed-off-by: Serge Hallyn <serge.hallyn@canonical.com> Signed-off-by: Daniel Lezcano <dlezcano@fr.ibm.com>
Diffstat (limited to 'templates')
-rw-r--r--templates/lxc-ubuntu.in18
1 files changed, 13 insertions, 5 deletions
diff --git a/templates/lxc-ubuntu.in b/templates/lxc-ubuntu.in
index 95b218a..0a8bbff 100644
--- a/templates/lxc-ubuntu.in
+++ b/templates/lxc-ubuntu.in
@@ -334,20 +334,21 @@ do_bindhome()
rootfs=$1
user=$2
- # 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
-
# 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
fi
shad=`getent shadow $user`
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
}
clean()
@@ -440,6 +441,13 @@ do
esac
done
+pwd=`getent passwd $bindhome`
+if [ $? -ne 0 ]; then
+ echo "Error: no password entry found for $bindhome"
+ exit 1
+fi
+
+
if [ "$arch" == "i686" ]; then
arch=i386
fi