summaryrefslogtreecommitdiffstats
path: root/meta/classes
diff options
context:
space:
mode:
Diffstat (limited to 'meta/classes')
-rw-r--r--meta/classes/useradd-staticids.bbclass62
1 files changed, 29 insertions, 33 deletions
diff --git a/meta/classes/useradd-staticids.bbclass b/meta/classes/useradd-staticids.bbclass
index 3d0bc09148..589a99ff45 100644
--- a/meta/classes/useradd-staticids.bbclass
+++ b/meta/classes/useradd-staticids.bbclass
@@ -38,10 +38,14 @@ def update_useradd_static_config(d):
return id_table
- def handle_missing_id(id, type, pkg):
+ 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)
+ if files:
+ msg += " Add %s to one of these files: %s" % (id, files)
+ else:
+ msg += " %s file(s) not found in BBPATH: %s" % (var, value)
if error_dynamic == 'error' or error_dynamic == '1':
raise NotImplementedError(msg)
elif error_dynamic == 'warn':
@@ -49,23 +53,24 @@ def update_useradd_static_config(d):
elif error_dynamic == 'skip':
raise bb.parse.SkipRecipe(msg)
+ # Return a list of configuration files based on either the default
+ # files/group or the contents of USERADD_GID_TABLES, resp.
+ # files/passwd for USERADD_UID_TABLES.
+ # Paths are resolved via BBPATH.
+ def get_table_list(d, var, default):
+ files = []
+ bbpath = d.getVar('BBPATH', True)
+ tables = d.getVar(var, True)
+ if not tables:
+ tables = default
+ for conf_file in tables.split():
+ files.append(bb.utils.which(bbpath, conf_file))
+ return (' '.join(files), var, default)
+
# We parse and rewrite the useradd components
def rewrite_useradd(params, is_pkg):
parser = oe.useradd.build_useradd_parser()
- # Return a list of configuration files based on either the default
- # files/passwd or the contents of USERADD_UID_TABLES
- # paths are resolved via BBPATH
- def get_passwd_list(d):
- str = ""
- bbpath = d.getVar('BBPATH')
- passwd_tables = d.getVar('USERADD_UID_TABLES')
- if not passwd_tables:
- passwd_tables = 'files/passwd'
- for conf_file in passwd_tables.split():
- str += " %s" % bb.utils.which(bbpath, conf_file)
- return str
-
newparams = []
users = None
for param in oe.useradd.split_commands(params):
@@ -86,10 +91,12 @@ def update_useradd_static_config(d):
# all new users get the default ('*' which prevents login) until the user is
# specifically configured by the system admin.
if not users:
- users = merge_files(get_passwd_list(d), 7)
+ files, table_var, table_value = get_table_list(d, 'USERADD_UID_TABLES', 'files/passwd')
+ users = merge_files(files, 7)
+ type = 'system user' if uaargs.system else 'normal user'
if uaargs.LOGIN not in users:
- handle_missing_id(uaargs.LOGIN, 'user', pkg)
+ handle_missing_id(uaargs.LOGIN, type, pkg, files, table_var, table_value)
newparams.append(param)
continue
@@ -147,7 +154,7 @@ def update_useradd_static_config(d):
# Should be an error if a specific option is set...
if not uaargs.uid or not uaargs.uid.isdigit() or not uaargs.gid:
- handle_missing_id(uaargs.LOGIN, 'user', pkg)
+ handle_missing_id(uaargs.LOGIN, type, pkg, files, table_var, table_value)
# Reconstruct the args...
newparam = ['', ' --defaults'][uaargs.defaults]
@@ -184,19 +191,6 @@ def update_useradd_static_config(d):
def rewrite_groupadd(params, is_pkg):
parser = oe.useradd.build_groupadd_parser()
- # Return a list of configuration files based on either the default
- # files/group or the contents of USERADD_GID_TABLES
- # paths are resolved via BBPATH
- def get_group_list(d):
- str = ""
- bbpath = d.getVar('BBPATH')
- group_tables = d.getVar('USERADD_GID_TABLES')
- if not group_tables:
- group_tables = 'files/group'
- for conf_file in group_tables.split():
- str += " %s" % bb.utils.which(bbpath, conf_file)
- return str
-
newparams = []
groups = None
for param in oe.useradd.split_commands(params):
@@ -216,10 +210,12 @@ def update_useradd_static_config(d):
# Note: similar to the passwd file, the 'password' filed is ignored
# Note: group_members is ignored, group members must be configured with the GROUPMEMS_PARAM
if not groups:
- groups = merge_files(get_group_list(d), 4)
+ files, table_var, table_value = get_table_list(d, 'USERADD_GID_TABLES', 'files/group')
+ groups = merge_files(files, 4)
+ type = 'system group' if gaargs.system else 'normal group'
if gaargs.GROUP not in groups:
- handle_missing_id(gaargs.GROUP, 'group', pkg)
+ handle_missing_id(gaargs.GROUP, type, pkg, files, table_var, table_value)
newparams.append(param)
continue
@@ -231,7 +227,7 @@ def update_useradd_static_config(d):
gaargs.gid = field[2]
if not gaargs.gid or not gaargs.gid.isdigit():
- handle_missing_id(gaargs.GROUP, 'group', pkg)
+ handle_missing_id(gaargs.GROUP, type, pkg, files, table_var, table_value)
# Reconstruct the args...
newparam = ['', ' --force'][gaargs.force]