diff options
author | Peter Kjellerstedt <peter.kjellerstedt@axis.com> | 2016-06-17 16:59:01 +0200 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2016-06-17 17:14:55 +0100 |
commit | c99750d17e7eaeaa16e5a8510d64e89cef856411 (patch) | |
tree | bc30a2b02bb44dc225bfe850c9b8115d4e5feca0 | |
parent | 4ed711a2b330094b71844ec48833ba21501ee80e (diff) | |
download | poky-c99750d17e7eaeaa16e5a8510d64e89cef856411.tar.gz |
useradd-staticids.bbclass: Restore failure on missing UIDs/GIDs
A regression was introduced with commit 3149319a whereby setting
USERADD_ERROR_DYNAMIC no longer resulted in an error for users and
groups that were missing numeric UIDs and GIDs but were not mentioned
at all in any passwd or groups file.
[YOCTO #9777]
(From OE-Core rev: adc0f830a695c417b4d282fa580c5231e1f0afbe)
Signed-off-by: Peter Kjellerstedt <peter.kjellerstedt@axis.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
-rw-r--r-- | meta/classes/useradd-staticids.bbclass | 19 |
1 files changed, 13 insertions, 6 deletions
diff --git a/meta/classes/useradd-staticids.bbclass b/meta/classes/useradd-staticids.bbclass index d963f283b7..90835cfac2 100644 --- a/meta/classes/useradd-staticids.bbclass +++ b/meta/classes/useradd-staticids.bbclass | |||
@@ -50,6 +50,11 @@ def update_useradd_static_config(d): | |||
50 | 50 | ||
51 | return id_table | 51 | return id_table |
52 | 52 | ||
53 | def handle_missing_id(id, type, pkg): | ||
54 | if d.getVar('USERADD_ERROR_DYNAMIC', True) == '1': | ||
55 | #bb.error("Skipping recipe %s, package %s which adds %sname %s does not have a static ID defined." % (d.getVar('PN', True), pkg, type, id)) | ||
56 | raise bb.build.FuncFailed("%s - %s: %sname %s does not have a static ID defined." % (d.getVar('PN', True), pkg, type, id)) | ||
57 | |||
53 | # We parse and rewrite the useradd components | 58 | # We parse and rewrite the useradd components |
54 | def rewrite_useradd(params): | 59 | def rewrite_useradd(params): |
55 | # The following comes from --help on useradd from shadow | 60 | # The following comes from --help on useradd from shadow |
@@ -116,6 +121,8 @@ def update_useradd_static_config(d): | |||
116 | users = merge_files(get_passwd_list(d), 7) | 121 | users = merge_files(get_passwd_list(d), 7) |
117 | 122 | ||
118 | if uaargs.LOGIN not in users: | 123 | if uaargs.LOGIN not in users: |
124 | if not uaargs.uid or not uaargs.uid.isdigit() or not uaargs.gid: | ||
125 | handle_missing_id(uaargs.LOGIN, 'user', pkg) | ||
119 | continue | 126 | continue |
120 | 127 | ||
121 | field = users[uaargs.LOGIN] | 128 | field = users[uaargs.LOGIN] |
@@ -165,9 +172,8 @@ def update_useradd_static_config(d): | |||
165 | uaargs.shell = field[6] or uaargs.shell | 172 | uaargs.shell = field[6] or uaargs.shell |
166 | 173 | ||
167 | # Should be an error if a specific option is set... | 174 | # Should be an error if a specific option is set... |
168 | if d.getVar('USERADD_ERROR_DYNAMIC', True) == '1' and not ((uaargs.uid and uaargs.uid.isdigit()) and uaargs.gid): | 175 | if not uaargs.uid or not uaargs.uid.isdigit() or not uaargs.gid: |
169 | #bb.error("Skipping recipe %s, package %s which adds username %s does not have a static uid defined." % (d.getVar('PN', True), pkg, uaargs.LOGIN)) | 176 | handle_missing_id(uaargs.LOGIN, 'user', pkg) |
170 | raise bb.build.FuncFailed("%s - %s: Username %s does not have a static uid defined." % (d.getVar('PN', True), pkg, uaargs.LOGIN)) | ||
171 | 177 | ||
172 | # Reconstruct the args... | 178 | # Reconstruct the args... |
173 | newparam = ['', ' --defaults'][uaargs.defaults] | 179 | newparam = ['', ' --defaults'][uaargs.defaults] |
@@ -248,6 +254,8 @@ def update_useradd_static_config(d): | |||
248 | groups = merge_files(get_group_list(d), 4) | 254 | groups = merge_files(get_group_list(d), 4) |
249 | 255 | ||
250 | if gaargs.GROUP not in groups: | 256 | if gaargs.GROUP not in groups: |
257 | if not gaargs.gid or not gaargs.gid.isdigit(): | ||
258 | handle_missing_id(gaargs.GROUP, 'group', pkg) | ||
251 | continue | 259 | continue |
252 | 260 | ||
253 | field = groups[gaargs.GROUP] | 261 | field = groups[gaargs.GROUP] |
@@ -257,9 +265,8 @@ def update_useradd_static_config(d): | |||
257 | bb.warn("%s: Changing groupname %s's gid from (%s) to (%s), verify configuration files!" % (d.getVar('PN', True), gaargs.GROUP, gaargs.gid, field[2])) | 265 | bb.warn("%s: Changing groupname %s's gid from (%s) to (%s), verify configuration files!" % (d.getVar('PN', True), gaargs.GROUP, gaargs.gid, field[2])) |
258 | gaargs.gid = field[2] | 266 | gaargs.gid = field[2] |
259 | 267 | ||
260 | if d.getVar('USERADD_ERROR_DYNAMIC', True) == '1' and not (gaargs.gid and gaargs.gid.isdigit()): | 268 | if not gaargs.gid or not gaargs.gid.isdigit(): |
261 | #bb.error("Skipping recipe %s, package %s which adds groupname %s does not have a static gid defined." % (d.getVar('PN', True), pkg, gaargs.GROUP)) | 269 | handle_missing_id(gaargs.GROUP, 'group', pkg) |
262 | raise bb.build.FuncFailed("%s - %s: Groupname %s does not have a static gid defined." % (d.getVar('PN', True), pkg, gaargs.GROUP)) | ||
263 | 270 | ||
264 | # Reconstruct the args... | 271 | # Reconstruct the args... |
265 | newparam = ['', ' --force'][gaargs.force] | 272 | newparam = ['', ' --force'][gaargs.force] |