summaryrefslogtreecommitdiffstats
path: root/meta/classes/useradd-staticids.bbclass
diff options
context:
space:
mode:
Diffstat (limited to 'meta/classes/useradd-staticids.bbclass')
-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]