]> git.ipfire.org Git - thirdparty/lxc.git/commitdiff
lxc-ubuntu: stop early if a bad user is specified in -b option
authorSerge E. Hallyn <serge.hallyn@canonical.com>
Mon, 24 Oct 2011 12:47:58 +0000 (14:47 +0200)
committerDaniel Lezcano <daniel.lezcano@free.fr>
Mon, 24 Oct 2011 12:47:58 +0000 (14:47 +0200)
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>
templates/lxc-ubuntu.in

index 95b218a0b9ad79f604af79c2ad6b86b2b89732f1..0a8bbff15e587cf587cb6e1c59d7107e2185f734 100644 (file)
@@ -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