diff options
-rw-r--r-- | meta/classes/extrausers.bbclass | 4 | ||||
-rw-r--r-- | meta/classes/useradd-staticids.bbclass | 37 |
2 files changed, 35 insertions, 6 deletions
diff --git a/meta/classes/extrausers.bbclass b/meta/classes/extrausers.bbclass index 402fc7d808..7709407b69 100644 --- a/meta/classes/extrausers.bbclass +++ b/meta/classes/extrausers.bbclass | |||
@@ -63,3 +63,7 @@ set_user_group () { | |||
63 | remaining=`echo $remaining | cut -d ';' -f2-` | 63 | remaining=`echo $remaining | cut -d ';' -f2-` |
64 | done | 64 | done |
65 | } | 65 | } |
66 | |||
67 | USERADDEXTENSION ?= "" | ||
68 | |||
69 | inherit ${USERADDEXTENSION} | ||
diff --git a/meta/classes/useradd-staticids.bbclass b/meta/classes/useradd-staticids.bbclass index 94bcbaa3d7..f7f6057ac3 100644 --- a/meta/classes/useradd-staticids.bbclass +++ b/meta/classes/useradd-staticids.bbclass | |||
@@ -58,7 +58,7 @@ def update_useradd_static_config(d): | |||
58 | bb.warn("%s - %s: %sname %s does not have a static ID defined." % (d.getVar('PN'), pkg, type, id)) | 58 | bb.warn("%s - %s: %sname %s does not have a static ID defined." % (d.getVar('PN'), pkg, type, id)) |
59 | 59 | ||
60 | # We parse and rewrite the useradd components | 60 | # We parse and rewrite the useradd components |
61 | def rewrite_useradd(params): | 61 | def rewrite_useradd(params, is_pkg): |
62 | # The following comes from --help on useradd from shadow | 62 | # The following comes from --help on useradd from shadow |
63 | parser = myArgumentParser(prog='useradd') | 63 | parser = myArgumentParser(prog='useradd') |
64 | parser.add_argument("-b", "--base-dir", metavar="BASE_DIR", help="base directory for the home directory of the new account") | 64 | parser.add_argument("-b", "--base-dir", metavar="BASE_DIR", help="base directory for the home directory of the new account") |
@@ -162,7 +162,7 @@ def update_useradd_static_config(d): | |||
162 | 162 | ||
163 | uaargs.gid = uaargs.groupid | 163 | uaargs.gid = uaargs.groupid |
164 | uaargs.user_group = None | 164 | uaargs.user_group = None |
165 | if newgroup: | 165 | if newgroup and is_pkg: |
166 | groupadd = d.getVar("GROUPADD_PARAM_%s" % pkg) | 166 | groupadd = d.getVar("GROUPADD_PARAM_%s" % pkg) |
167 | if groupadd: | 167 | if groupadd: |
168 | d.setVar("GROUPADD_PARAM_%s" % pkg, "%s; %s" % (groupadd, newgroup)) | 168 | d.setVar("GROUPADD_PARAM_%s" % pkg, "%s; %s" % (groupadd, newgroup)) |
@@ -206,7 +206,7 @@ def update_useradd_static_config(d): | |||
206 | return ";".join(newparams).strip() | 206 | return ";".join(newparams).strip() |
207 | 207 | ||
208 | # We parse and rewrite the groupadd components | 208 | # We parse and rewrite the groupadd components |
209 | def rewrite_groupadd(params): | 209 | def rewrite_groupadd(params, is_pkg): |
210 | # The following comes from --help on groupadd from shadow | 210 | # The following comes from --help on groupadd from shadow |
211 | parser = myArgumentParser(prog='groupadd') | 211 | parser = myArgumentParser(prog='groupadd') |
212 | parser.add_argument("-f", "--force", help="exit successfully if the group already exists, and cancel -g if the GID is already used", action="store_true") | 212 | parser.add_argument("-f", "--force", help="exit successfully if the group already exists, and cancel -g if the GID is already used", action="store_true") |
@@ -298,7 +298,7 @@ def update_useradd_static_config(d): | |||
298 | bb.parse.mark_dependency(d, bb.utils.which(bbpath, conf_file)) | 298 | bb.parse.mark_dependency(d, bb.utils.which(bbpath, conf_file)) |
299 | 299 | ||
300 | # Load and process the users and groups, rewriting the adduser/addgroup params | 300 | # Load and process the users and groups, rewriting the adduser/addgroup params |
301 | useradd_packages = d.getVar('USERADD_PACKAGES') | 301 | useradd_packages = d.getVar('USERADD_PACKAGES') or "" |
302 | 302 | ||
303 | for pkg in useradd_packages.split(): | 303 | for pkg in useradd_packages.split(): |
304 | # Groupmems doesn't have anything we might want to change, so simply validating | 304 | # Groupmems doesn't have anything we might want to change, so simply validating |
@@ -306,15 +306,40 @@ def update_useradd_static_config(d): | |||
306 | useradd_param = d.getVar('USERADD_PARAM_%s' % pkg) | 306 | useradd_param = d.getVar('USERADD_PARAM_%s' % pkg) |
307 | if useradd_param: | 307 | if useradd_param: |
308 | #bb.warn("Before: 'USERADD_PARAM_%s' - '%s'" % (pkg, useradd_param)) | 308 | #bb.warn("Before: 'USERADD_PARAM_%s' - '%s'" % (pkg, useradd_param)) |
309 | d.setVar('USERADD_PARAM_%s' % pkg, rewrite_useradd(useradd_param)) | 309 | d.setVar('USERADD_PARAM_%s' % pkg, rewrite_useradd(useradd_param, True)) |
310 | #bb.warn("After: 'USERADD_PARAM_%s' - '%s'" % (pkg, d.getVar('USERADD_PARAM_%s' % pkg))) | 310 | #bb.warn("After: 'USERADD_PARAM_%s' - '%s'" % (pkg, d.getVar('USERADD_PARAM_%s' % pkg))) |
311 | 311 | ||
312 | groupadd_param = d.getVar('GROUPADD_PARAM_%s' % pkg) | 312 | groupadd_param = d.getVar('GROUPADD_PARAM_%s' % pkg) |
313 | if groupadd_param: | 313 | if groupadd_param: |
314 | #bb.warn("Before: 'GROUPADD_PARAM_%s' - '%s'" % (pkg, groupadd_param)) | 314 | #bb.warn("Before: 'GROUPADD_PARAM_%s' - '%s'" % (pkg, groupadd_param)) |
315 | d.setVar('GROUPADD_PARAM_%s' % pkg, rewrite_groupadd(groupadd_param)) | 315 | d.setVar('GROUPADD_PARAM_%s' % pkg, rewrite_groupadd(groupadd_param, True)) |
316 | #bb.warn("After: 'GROUPADD_PARAM_%s' - '%s'" % (pkg, d.getVar('GROUPADD_PARAM_%s' % pkg))) | 316 | #bb.warn("After: 'GROUPADD_PARAM_%s' - '%s'" % (pkg, d.getVar('GROUPADD_PARAM_%s' % pkg))) |
317 | 317 | ||
318 | # Load and process extra users and groups, rewriting only adduser/addgroup params | ||
319 | pkg = d.getVar('PN') | ||
320 | extrausers = d.getVar('EXTRA_USERS_PARAMS') or "" | ||
321 | |||
322 | #bb.warn("Before: 'EXTRA_USERS_PARAMS' - '%s'" % (d.getVar('EXTRA_USERS_PARAMS'))) | ||
323 | new_extrausers = [] | ||
324 | for cmd in re.split('''[ \t]*;[ \t]*(?=(?:[^'"]|'[^']*'|"[^"]*")*$)''', extrausers): | ||
325 | cmd = cmd.strip() | ||
326 | if not cmd: | ||
327 | continue | ||
328 | |||
329 | if re.match('''useradd (.*)''', cmd): | ||
330 | useradd_param = re.match('''useradd (.*)''', cmd).group(1) | ||
331 | useradd_param = rewrite_useradd(useradd_param, False) | ||
332 | cmd = 'useradd %s' % useradd_param | ||
333 | elif re.match('''groupadd (.*)''', cmd): | ||
334 | groupadd_param = re.match('''groupadd (.*)''', cmd).group(1) | ||
335 | groupadd_param = rewrite_groupadd(groupadd_param, False) | ||
336 | cmd = 'groupadd %s' % groupadd_param | ||
337 | |||
338 | new_extrausers.append(cmd) | ||
339 | |||
340 | new_extrausers.append('') | ||
341 | d.setVar('EXTRA_USERS_PARAMS', ';'.join(new_extrausers)) | ||
342 | #bb.warn("After: 'EXTRA_USERS_PARAMS' - '%s'" % (d.getVar('EXTRA_USERS_PARAMS'))) | ||
318 | 343 | ||
319 | 344 | ||
320 | python __anonymous() { | 345 | python __anonymous() { |