summaryrefslogtreecommitdiffstats
path: root/meta
diff options
context:
space:
mode:
authorPeter Kjellerstedt <peter.kjellerstedt@axis.com>2016-06-17 16:59:01 +0200
committerRichard Purdie <richard.purdie@linuxfoundation.org>2016-06-29 19:36:02 +0100
commita4d74c100d8dfbbc8d682e223c91573a2acca8e3 (patch)
tree71c44d8485793eaa6186e30d69d7342a7fb0efaa /meta
parentb8e749ddd666f01c839bf938ac8ab076fa596cf0 (diff)
downloadpoky-a4d74c100d8dfbbc8d682e223c91573a2acca8e3.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) (From OE-Core rev: b64316f34a45dcf7a31e0486e51799fcd6b0ed2d) Signed-off-by: Peter Kjellerstedt <peter.kjellerstedt@axis.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org> (cherry picked from commit c99750d17e7eaeaa16e5a8510d64e89cef856411) Signed-off-by: Armin Kuster <akuster@mvista.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'meta')
-rw-r--r--meta/classes/useradd-staticids.bbclass19
1 files changed, 13 insertions, 6 deletions
diff --git a/meta/classes/useradd-staticids.bbclass b/meta/classes/useradd-staticids.bbclass
index a9b506d05d..50a7481a60 100644
--- a/meta/classes/useradd-staticids.bbclass
+++ b/meta/classes/useradd-staticids.bbclass
@@ -46,6 +46,11 @@ def update_useradd_static_config(d):
46 46
47 return id_table 47 return id_table
48 48
49 def handle_missing_id(id, type, pkg):
50 if d.getVar('USERADD_ERROR_DYNAMIC', True) == '1':
51 #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))
52 raise bb.build.FuncFailed("%s - %s: %sname %s does not have a static ID defined." % (d.getVar('PN', True), pkg, type, id))
53
49 # We parse and rewrite the useradd components 54 # We parse and rewrite the useradd components
50 def rewrite_useradd(params): 55 def rewrite_useradd(params):
51 # The following comes from --help on useradd from shadow 56 # The following comes from --help on useradd from shadow
@@ -112,6 +117,8 @@ def update_useradd_static_config(d):
112 users = merge_files(get_passwd_list(d), 7) 117 users = merge_files(get_passwd_list(d), 7)
113 118
114 if uaargs.LOGIN not in users: 119 if uaargs.LOGIN not in users:
120 if not uaargs.uid or not uaargs.uid.isdigit() or not uaargs.gid:
121 handle_missing_id(uaargs.LOGIN, 'user', pkg)
115 continue 122 continue
116 123
117 field = users[uaargs.LOGIN] 124 field = users[uaargs.LOGIN]
@@ -161,9 +168,8 @@ def update_useradd_static_config(d):
161 uaargs.shell = field[6] or uaargs.shell 168 uaargs.shell = field[6] or uaargs.shell
162 169
163 # Should be an error if a specific option is set... 170 # Should be an error if a specific option is set...
164 if d.getVar('USERADD_ERROR_DYNAMIC', True) == '1' and not ((uaargs.uid and uaargs.uid.isdigit()) and uaargs.gid): 171 if not uaargs.uid or not uaargs.uid.isdigit() or not uaargs.gid:
165 #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)) 172 handle_missing_id(uaargs.LOGIN, 'user', pkg)
166 raise bb.build.FuncFailed("%s - %s: Username %s does not have a static uid defined." % (d.getVar('PN', True), pkg, uaargs.LOGIN))
167 173
168 # Reconstruct the args... 174 # Reconstruct the args...
169 newparam = ['', ' --defaults'][uaargs.defaults] 175 newparam = ['', ' --defaults'][uaargs.defaults]
@@ -244,6 +250,8 @@ def update_useradd_static_config(d):
244 groups = merge_files(get_group_list(d), 4) 250 groups = merge_files(get_group_list(d), 4)
245 251
246 if gaargs.GROUP not in groups: 252 if gaargs.GROUP not in groups:
253 if not gaargs.gid or not gaargs.gid.isdigit():
254 handle_missing_id(gaargs.GROUP, 'group', pkg)
247 continue 255 continue
248 256
249 field = groups[gaargs.GROUP] 257 field = groups[gaargs.GROUP]
@@ -253,9 +261,8 @@ def update_useradd_static_config(d):
253 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])) 261 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]))
254 gaargs.gid = field[2] 262 gaargs.gid = field[2]
255 263
256 if d.getVar('USERADD_ERROR_DYNAMIC', True) == '1' and not (gaargs.gid and gaargs.gid.isdigit()): 264 if not gaargs.gid or not gaargs.gid.isdigit():
257 #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)) 265 handle_missing_id(gaargs.GROUP, 'group', pkg)
258 raise bb.build.FuncFailed("%s - %s: Groupname %s does not have a static gid defined." % (d.getVar('PN', True), pkg, gaargs.GROUP))
259 266
260 # Reconstruct the args... 267 # Reconstruct the args...
261 newparam = ['', ' --force'][gaargs.force] 268 newparam = ['', ' --force'][gaargs.force]