diff options
Diffstat (limited to 'meta/classes/useradd-staticids.bbclass')
-rw-r--r-- | meta/classes/useradd-staticids.bbclass | 48 |
1 files changed, 25 insertions, 23 deletions
diff --git a/meta/classes/useradd-staticids.bbclass b/meta/classes/useradd-staticids.bbclass index 589a99ff45..1dbcba2bf1 100644 --- a/meta/classes/useradd-staticids.bbclass +++ b/meta/classes/useradd-staticids.bbclass @@ -1,3 +1,9 @@ +# +# Copyright OpenEmbedded Contributors +# +# SPDX-License-Identifier: MIT +# + # In order to support a deterministic set of 'dynamic' users/groups, # we need a function to reformat the params based on a static file def update_useradd_static_config(d): @@ -41,7 +47,7 @@ def update_useradd_static_config(d): def handle_missing_id(id, type, pkg, files, var, value): # For backwards compatibility we accept "1" in addition to "error" error_dynamic = d.getVar('USERADD_ERROR_DYNAMIC') - msg = "%s - %s: %sname %s does not have a static ID defined." % (d.getVar('PN'), pkg, type, id) + msg = 'Recipe %s, package %s: %sname "%s" does not have a static ID defined.' % (d.getVar('PN'), pkg, type, id) if files: msg += " Add %s to one of these files: %s" % (id, files) else: @@ -59,8 +65,8 @@ def update_useradd_static_config(d): # Paths are resolved via BBPATH. def get_table_list(d, var, default): files = [] - bbpath = d.getVar('BBPATH', True) - tables = d.getVar(var, True) + bbpath = d.getVar('BBPATH') + tables = d.getVar(var) if not tables: tables = default for conf_file in tables.split(): @@ -76,8 +82,8 @@ def update_useradd_static_config(d): for param in oe.useradd.split_commands(params): try: uaargs = parser.parse_args(oe.useradd.split_args(param)) - except: - bb.fatal("%s: Unable to parse arguments for USERADD_PARAM_%s: '%s'" % (d.getVar('PN'), pkg, param)) + except Exception as e: + bb.fatal("%s: Unable to parse arguments for USERADD_PARAM:%s '%s': %s" % (d.getVar('PN'), pkg, param, e)) # Read all passwd files specified in USERADD_UID_TABLES or files/passwd # Use the standard passwd layout: @@ -140,13 +146,13 @@ def update_useradd_static_config(d): uaargs.gid = uaargs.groupid uaargs.user_group = None if newgroup and is_pkg: - groupadd = d.getVar("GROUPADD_PARAM_%s" % pkg) + groupadd = d.getVar("GROUPADD_PARAM:%s" % pkg) if groupadd: # Only add the group if not already specified if not uaargs.groupname in groupadd: - d.setVar("GROUPADD_PARAM_%s" % pkg, "%s; %s" % (groupadd, newgroup)) + d.setVar("GROUPADD_PARAM:%s" % pkg, "%s; %s" % (groupadd, newgroup)) else: - d.setVar("GROUPADD_PARAM_%s" % pkg, newgroup) + d.setVar("GROUPADD_PARAM:%s" % pkg, newgroup) uaargs.comment = "'%s'" % field[4] if field[4] else uaargs.comment uaargs.home_dir = field[5] or uaargs.home_dir @@ -174,8 +180,6 @@ def update_useradd_static_config(d): newparam += ['', ' --non-unique'][uaargs.non_unique] if uaargs.password != None: newparam += ['', ' --password %s' % uaargs.password][uaargs.password != None] - elif uaargs.clear_password: - newparam += ['', ' --clear-password %s' % uaargs.clear_password][uaargs.clear_password != None] newparam += ['', ' --root %s' % uaargs.root][uaargs.root != None] newparam += ['', ' --system'][uaargs.system] newparam += ['', ' --shell %s' % uaargs.shell][uaargs.shell != None] @@ -197,8 +201,8 @@ def update_useradd_static_config(d): try: # If we're processing multiple lines, we could have left over values here... gaargs = parser.parse_args(oe.useradd.split_args(param)) - except: - bb.fatal("%s: Unable to parse arguments for GROUPADD_PARAM_%s: '%s'" % (d.getVar('PN'), pkg, param)) + except Exception as e: + bb.fatal("%s: Unable to parse arguments for GROUPADD_PARAM:%s '%s': %s" % (d.getVar('PN'), pkg, param, e)) # Read all group files specified in USERADD_GID_TABLES or files/group # Use the standard group layout: @@ -236,8 +240,6 @@ def update_useradd_static_config(d): newparam += ['', ' --non-unique'][gaargs.non_unique] if gaargs.password != None: newparam += ['', ' --password %s' % gaargs.password][gaargs.password != None] - elif gaargs.clear_password: - newparam += ['', ' --clear-password %s' % gaargs.clear_password][gaargs.clear_password != None] newparam += ['', ' --root %s' % gaargs.root][gaargs.root != None] newparam += ['', ' --system'][gaargs.system] newparam += ' %s' % gaargs.GROUP @@ -265,17 +267,17 @@ def update_useradd_static_config(d): for pkg in useradd_packages.split(): # Groupmems doesn't have anything we might want to change, so simply validating # is a bit of a waste -- only process useradd/groupadd - useradd_param = d.getVar('USERADD_PARAM_%s' % pkg) + useradd_param = d.getVar('USERADD_PARAM:%s' % pkg) if useradd_param: - #bb.warn("Before: 'USERADD_PARAM_%s' - '%s'" % (pkg, useradd_param)) - d.setVar('USERADD_PARAM_%s' % pkg, rewrite_useradd(useradd_param, True)) - #bb.warn("After: 'USERADD_PARAM_%s' - '%s'" % (pkg, d.getVar('USERADD_PARAM_%s' % pkg))) + #bb.warn("Before: 'USERADD_PARAM:%s' - '%s'" % (pkg, useradd_param)) + d.setVar('USERADD_PARAM:%s' % pkg, rewrite_useradd(useradd_param, True)) + #bb.warn("After: 'USERADD_PARAM:%s' - '%s'" % (pkg, d.getVar('USERADD_PARAM:%s' % pkg))) - groupadd_param = d.getVar('GROUPADD_PARAM_%s' % pkg) + groupadd_param = d.getVar('GROUPADD_PARAM:%s' % pkg) if groupadd_param: - #bb.warn("Before: 'GROUPADD_PARAM_%s' - '%s'" % (pkg, groupadd_param)) - d.setVar('GROUPADD_PARAM_%s' % pkg, rewrite_groupadd(groupadd_param, True)) - #bb.warn("After: 'GROUPADD_PARAM_%s' - '%s'" % (pkg, d.getVar('GROUPADD_PARAM_%s' % pkg))) + #bb.warn("Before: 'GROUPADD_PARAM:%s' - '%s'" % (pkg, groupadd_param)) + d.setVar('GROUPADD_PARAM:%s' % pkg, rewrite_groupadd(groupadd_param, True)) + #bb.warn("After: 'GROUPADD_PARAM:%s' - '%s'" % (pkg, d.getVar('GROUPADD_PARAM:%s' % pkg))) # Load and process extra users and groups, rewriting only adduser/addgroup params pkg = d.getVar('PN') @@ -307,5 +309,5 @@ python __anonymous() { update_useradd_static_config(d) except NotImplementedError as f: bb.debug(1, "Skipping recipe %s: %s" % (d.getVar('PN'), f)) - raise bb.parse.SkipPackage(f) + raise bb.parse.SkipRecipe(f) } |