summaryrefslogtreecommitdiffstats
path: root/meta/classes
diff options
context:
space:
mode:
authorPeter Kjellerstedt <peter.kjellerstedt@axis.com>2015-12-19 00:53:50 +0100
committerRichard Purdie <richard.purdie@linuxfoundation.org>2016-01-18 11:47:06 +0000
commit4cbdb1577e34079550ace3d7dd8695a1934afbe1 (patch)
tree7937ca54449c1d3936bacd4552466144c0aa0196 /meta/classes
parentb18e40ce2f5859865d26a4010d78e65f6f2972fc (diff)
downloadpoky-4cbdb1577e34079550ace3d7dd8695a1934afbe1.tar.gz
useradd-staticids.bbclass: Simplify the logic for when to add groups
The original code was near impossible to follow, and missed a couple of cases. For example, if one added the following line to the passwd file specified in USERADD_UID_TABLES: foobar:x:12345:nogroup::/:/bin/sh and then specified the user as: USERADD_PARAM_${PN} = "--system foobar" one would then assume that the foobar user would be created with the primary group set to nogroup. However, it was not (the primary group would be foobar), and the only way to get it correct was to explicitly add --gid nogroup to the USERADD_PARAM_${PN}. (From OE-Core rev: e98e98ce65cf9ffdef29462310a622ffddd1412b) Signed-off-by: Peter Kjellerstedt <peter.kjellerstedt@axis.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'meta/classes')
-rw-r--r--meta/classes/useradd-staticids.bbclass36
1 files changed, 16 insertions, 20 deletions
diff --git a/meta/classes/useradd-staticids.bbclass b/meta/classes/useradd-staticids.bbclass
index 0e855e91c7..df4902ee9a 100644
--- a/meta/classes/useradd-staticids.bbclass
+++ b/meta/classes/useradd-staticids.bbclass
@@ -110,30 +110,26 @@ def update_useradd_static_config(d):
110 uaargs.groupname = uaargs.LOGIN if user_group else uaargs.gid 110 uaargs.groupname = uaargs.LOGIN if user_group else uaargs.gid
111 uaargs.groupid = field[3] or uaargs.gid or uaargs.groupname 111 uaargs.groupid = field[3] or uaargs.gid or uaargs.groupname
112 112
113 if not uaargs.gid or uaargs.gid != uaargs.groupid: 113 if uaargs.groupid and uaargs.gid != uaargs.groupid:
114 if (uaargs.groupid and uaargs.groupid.isdigit()) and (uaargs.groupname and uaargs.groupname.isdigit()) and (uaargs.groupid != uaargs.groupname): 114 newgroup = None
115 if not uaargs.groupid.isdigit():
116 # We don't have a group number, so we have to add a name
117 bb.debug(1, "Adding group %s!" % uaargs.groupid)
118 newgroup = "%s %s" % (' --system' if uaargs.system else '', uaargs.groupid)
119 elif uaargs.groupname and not uaargs.groupname.isdigit():
120 # We have a group name and a group number to assign it to
121 bb.debug(1, "Adding group %s (gid %s)!" % (uaargs.groupname, uaargs.groupid))
122 newgroup = "-g %s %s" % (uaargs.groupid, uaargs.groupname)
123 else:
115 # We want to add a group, but we don't know it's name... so we can't add the group... 124 # We want to add a group, but we don't know it's name... so we can't add the group...
116 # We have to assume the group has previously been added or we'll fail on the adduser... 125 # We have to assume the group has previously been added or we'll fail on the adduser...
117 # Note: specifying the actual gid is very rare in OE, usually the group name is specified. 126 # Note: specifying the actual gid is very rare in OE, usually the group name is specified.
118 bb.warn("%s: Changing gid for login %s from (%s) to (%s), verify configuration files!" % (d.getVar('PN', True), uaargs.LOGIN, uaargs.groupname, uaargs.gid)) 127 bb.warn("%s: Changing gid for login %s to %s, verify configuration files!" % (d.getVar('PN', True), uaargs.LOGIN, uaargs.groupid))
119 elif (uaargs.groupid and not uaargs.groupid.isdigit()) and uaargs.groupid == uaargs.groupname: 128
120 # We don't have a number, so we have to add a name 129 uaargs.gid = uaargs.groupid
121 bb.debug(1, "Adding group %s!" % (uaargs.groupname)) 130 uaargs.user_group = None
122 uaargs.gid = uaargs.groupid 131 if newgroup:
123 uaargs.user_group = None
124 groupadd = d.getVar("GROUPADD_PARAM_%s" % pkg, True)
125 newgroup = "%s %s" % (' --system' if uaargs.system else '', uaargs.groupname)
126 if groupadd:
127 d.setVar("GROUPADD_PARAM_%s" % pkg, "%s ; %s" % (groupadd, newgroup))
128 else:
129 d.setVar("GROUPADD_PARAM_%s" % pkg, newgroup)
130 elif uaargs.groupname and (uaargs.groupid and uaargs.groupid.isdigit()):
131 # We have a group name and a group number to assign it to
132 bb.debug(1, "Adding group %s gid (%s)!" % (uaargs.groupname, uaargs.groupid))
133 uaargs.gid = uaargs.groupid
134 uaargs.user_group = None
135 groupadd = d.getVar("GROUPADD_PARAM_%s" % pkg, True) 132 groupadd = d.getVar("GROUPADD_PARAM_%s" % pkg, True)
136 newgroup = "-g %s %s" % (uaargs.gid, uaargs.groupname)
137 if groupadd: 133 if groupadd:
138 d.setVar("GROUPADD_PARAM_%s" % pkg, "%s ; %s" % (groupadd, newgroup)) 134 d.setVar("GROUPADD_PARAM_%s" % pkg, "%s ; %s" % (groupadd, newgroup))
139 else: 135 else: