Commit 9db1aba4 by Serge Hallyn Committed by Daniel Lezcano

lxc-ubuntu.in: fix up the logic adding group for bound users

1. 'getent group $user' assumes user's group is named $user. 2. if 'getent group' returns error, just ignore the group in container 3. (misc) while it happens to all work out fine anyway, don't do getent passwd $bindhome if $bindhome isn't defined. (it will successfully return all password entries) Signed-off-by: 's avatarSerge Hallyn <serge.hallyn@ubuntu.com> Signed-off-by: 's avatarDaniel Lezcano <dlezcano@fr.ibm.com>
parent 0c547523
...@@ -546,10 +546,9 @@ do_bindhome() ...@@ -546,10 +546,9 @@ do_bindhome()
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 # Make sure the group exists in container
chroot $rootfs getent group $user || { \ grp=`echo $pwd | cut -d: -f 4` # group number for $user
grp=`getent group $user` grpe=`getent group $grp` || return 0 # if host doesn't define grp, ignore in container
echo "$grp" >> $rootfs/etc/group chroot $rootfs getent group "$grpe" || echo "$grpe" >> $rootfs/etc/group
}
} }
usage() usage()
...@@ -630,10 +629,12 @@ if [ $debug -eq 1 ]; then ...@@ -630,10 +629,12 @@ if [ $debug -eq 1 ]; then
set -x set -x
fi fi
pwd=`getent passwd $bindhome` if [ -n "$bindhome" ]; then
if [ $? -ne 0 ]; then pwd=`getent passwd $bindhome`
echo "Error: no password entry found for $bindhome" if [ $? -ne 0 ]; then
exit 1 echo "Error: no password entry found for $bindhome"
exit 1
fi
fi fi
......
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