aboutsummaryrefslogtreecommitdiffstats
path: root/meta/classes
diff options
context:
space:
mode:
authorPatrick Ohly <patrick.ohly@intel.com>2017-10-19 09:13:26 +0200
committerRichard Purdie <richard.purdie@linuxfoundation.org>2017-11-08 19:54:22 +0000
commit883bfc2bbb4d2120dbad6b0f2056503b012b1a2b (patch)
tree84ad0c630f0c3cf96c2e8f732cd0dc4fbf2b3cfd /meta/classes
parent9113928cea88c2187e8640ac489671cb81f58103 (diff)
downloadopenembedded-core-contrib-883bfc2bbb4d2120dbad6b0f2056503b012b1a2b.tar.gz
useradd-staticids: explain how to fix the the problem
When a distro uses useradd-staticids.bbclass and some developer unfamiliar with the static ID mechanism tries to add a recipe which needs new IDs, the resulting error or warning is typically not something that the developer will understand. Even experienced developers do not get enough information. They first must find out whether the missing ID is for a system user or group, then locate the file(s) in which the ID could be added. Both of this is now part of the message: ERROR: .../meta/recipes-extended/cronie/cronie_1.5.1.bb: cronie - cronie: system groupname crontab does not have a static ID defined. Add crontab to one of these files: /.../conf/distro/include/my-distro-group The case that no file was found is also handled: ERROR: .../meta/recipes-extended/cronie/cronie_1.5.1.bb: cronie - cronie: system groupname crontab does not have a static ID defined. USERADD_GID_TABLES file(s) not found in BBPATH: files/group It would be nice if the error message could also list the range in which a new ID needs to be allocated, but /etc/login.defs isn't available at the time of creating the message, so that part is still something that a developer needs to know. Signed-off-by: Patrick Ohly <patrick.ohly@intel.com> Signed-off-by: Ross Burton <ross.burton@intel.com>
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]