summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPeter Kjellerstedt <peter.kjellerstedt@axis.com>2018-10-15 22:25:44 +0200
committerRichard Purdie <richard.purdie@linuxfoundation.org>2018-10-16 20:35:43 +0100
commit0cdcce13bc0e70f67e8c10a711bf47d3c8803afc (patch)
treec990277dad81d97fe0fb17ce7fd49753038d391b
parente349b239c8833bcdad9b1ff1a0702ace2db71959 (diff)
downloadpoky-0cdcce13bc0e70f67e8c10a711bf47d3c8803afc.tar.gz
useradd_base.bbclass: Make perform_groupmems handle overlapping usernames
If the name of the last user being part of the group had a name that was a prefix of the user being added, then perform_groupmems() would treat it as if the user already existed in the list of users and not add it. Reported-by: Peter Henricsson <peter.henricsson@axis.com> (From OE-Core rev: 3bab0416f20366e75444be9b65fb1369643f103a) Signed-off-by: Peter Kjellerstedt <peter.kjellerstedt@axis.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
-rw-r--r--meta/classes/useradd_base.bbclass4
1 files changed, 2 insertions, 2 deletions
diff --git a/meta/classes/useradd_base.bbclass b/meta/classes/useradd_base.bbclass
index 551c82c322..0d0bdb80f5 100644
--- a/meta/classes/useradd_base.bbclass
+++ b/meta/classes/useradd_base.bbclass
@@ -51,10 +51,10 @@ perform_groupmems () {
51 local groupname=`echo "$opts" | awk '{ for (i = 1; i < NF; i++) if ($i == "-g" || $i == "--group") print $(i+1) }'` 51 local groupname=`echo "$opts" | awk '{ for (i = 1; i < NF; i++) if ($i == "-g" || $i == "--group") print $(i+1) }'`
52 local username=`echo "$opts" | awk '{ for (i = 1; i < NF; i++) if ($i == "-a" || $i == "--add") print $(i+1) }'` 52 local username=`echo "$opts" | awk '{ for (i = 1; i < NF; i++) if ($i == "-a" || $i == "--add") print $(i+1) }'`
53 bbnote "${PN}: Running groupmems command with group $groupname and user $username" 53 bbnote "${PN}: Running groupmems command with group $groupname and user $username"
54 local mem_exists="`grep "^$groupname:[^:]*:[^:]*:\([^,]*,\)*$username\(,[^,]*\)*" $rootdir/etc/group || true`" 54 local mem_exists="`grep "^$groupname:[^:]*:[^:]*:\([^,]*,\)*$username\(,[^,]*\)*$" $rootdir/etc/group || true`"
55 if test "x$mem_exists" = "x"; then 55 if test "x$mem_exists" = "x"; then
56 eval flock -x $rootdir${sysconfdir} -c \"$PSEUDO groupmems \$opts\" || true 56 eval flock -x $rootdir${sysconfdir} -c \"$PSEUDO groupmems \$opts\" || true
57 mem_exists="`grep "^$groupname:[^:]*:[^:]*:\([^,]*,\)*$username\(,[^,]*\)*" $rootdir/etc/group || true`" 57 mem_exists="`grep "^$groupname:[^:]*:[^:]*:\([^,]*,\)*$username\(,[^,]*\)*$" $rootdir/etc/group || true`"
58 if test "x$mem_exists" = "x"; then 58 if test "x$mem_exists" = "x"; then
59 bbfatal "${PN}: groupmems command did not succeed." 59 bbfatal "${PN}: groupmems command did not succeed."
60 fi 60 fi