summaryrefslogtreecommitdiffstats
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-12-04 17:23:56 +0000
commit23ee931b9d51d9aa7584461a24638ac6599afdd2 (patch)
treebdbe5e87dcf24ea0ff6925e3b23e05388ca9fee2 /meta/classes
parente4f256000f9c5b67e910244ff1175d31ce948cbf (diff)
downloadpoky-23ee931b9d51d9aa7584461a24638ac6599afdd2.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. (From OE-Core rev: 29c12b147ef85db4ebb0f86a911db5f90ae11c0a) Signed-off-by: Patrick Ohly <patrick.ohly@intel.com> Signed-off-by: Ross Burton <ross.burton@intel.com> Signed-off-by: Armin Kuster <akuster@mvista.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
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):
38 38
39 return id_table 39 return id_table
40 40
41 def handle_missing_id(id, type, pkg): 41 def handle_missing_id(id, type, pkg, files, var, value):
42 # For backwards compatibility we accept "1" in addition to "error" 42 # For backwards compatibility we accept "1" in addition to "error"
43 error_dynamic = d.getVar('USERADD_ERROR_DYNAMIC') 43 error_dynamic = d.getVar('USERADD_ERROR_DYNAMIC')
44 msg = "%s - %s: %sname %s does not have a static ID defined." % (d.getVar('PN'), pkg, type, id) 44 msg = "%s - %s: %sname %s does not have a static ID defined." % (d.getVar('PN'), pkg, type, id)
45 if files:
46 msg += " Add %s to one of these files: %s" % (id, files)
47 else:
48 msg += " %s file(s) not found in BBPATH: %s" % (var, value)
45 if error_dynamic == 'error' or error_dynamic == '1': 49 if error_dynamic == 'error' or error_dynamic == '1':
46 raise NotImplementedError(msg) 50 raise NotImplementedError(msg)
47 elif error_dynamic == 'warn': 51 elif error_dynamic == 'warn':
@@ -49,23 +53,24 @@ def update_useradd_static_config(d):
49 elif error_dynamic == 'skip': 53 elif error_dynamic == 'skip':
50 raise bb.parse.SkipRecipe(msg) 54 raise bb.parse.SkipRecipe(msg)
51 55
56 # Return a list of configuration files based on either the default
57 # files/group or the contents of USERADD_GID_TABLES, resp.
58 # files/passwd for USERADD_UID_TABLES.
59 # Paths are resolved via BBPATH.
60 def get_table_list(d, var, default):
61 files = []
62 bbpath = d.getVar('BBPATH', True)
63 tables = d.getVar(var, True)
64 if not tables:
65 tables = default
66 for conf_file in tables.split():
67 files.append(bb.utils.which(bbpath, conf_file))
68 return (' '.join(files), var, default)
69
52 # We parse and rewrite the useradd components 70 # We parse and rewrite the useradd components
53 def rewrite_useradd(params, is_pkg): 71 def rewrite_useradd(params, is_pkg):
54 parser = oe.useradd.build_useradd_parser() 72 parser = oe.useradd.build_useradd_parser()
55 73
56 # Return a list of configuration files based on either the default
57 # files/passwd or the contents of USERADD_UID_TABLES
58 # paths are resolved via BBPATH
59 def get_passwd_list(d):
60 str = ""
61 bbpath = d.getVar('BBPATH')
62 passwd_tables = d.getVar('USERADD_UID_TABLES')
63 if not passwd_tables:
64 passwd_tables = 'files/passwd'
65 for conf_file in passwd_tables.split():
66 str += " %s" % bb.utils.which(bbpath, conf_file)
67 return str
68
69 newparams = [] 74 newparams = []
70 users = None 75 users = None
71 for param in oe.useradd.split_commands(params): 76 for param in oe.useradd.split_commands(params):
@@ -86,10 +91,12 @@ def update_useradd_static_config(d):
86 # all new users get the default ('*' which prevents login) until the user is 91 # all new users get the default ('*' which prevents login) until the user is
87 # specifically configured by the system admin. 92 # specifically configured by the system admin.
88 if not users: 93 if not users:
89 users = merge_files(get_passwd_list(d), 7) 94 files, table_var, table_value = get_table_list(d, 'USERADD_UID_TABLES', 'files/passwd')
95 users = merge_files(files, 7)
90 96
97 type = 'system user' if uaargs.system else 'normal user'
91 if uaargs.LOGIN not in users: 98 if uaargs.LOGIN not in users:
92 handle_missing_id(uaargs.LOGIN, 'user', pkg) 99 handle_missing_id(uaargs.LOGIN, type, pkg, files, table_var, table_value)
93 newparams.append(param) 100 newparams.append(param)
94 continue 101 continue
95 102
@@ -147,7 +154,7 @@ def update_useradd_static_config(d):
147 154
148 # Should be an error if a specific option is set... 155 # Should be an error if a specific option is set...
149 if not uaargs.uid or not uaargs.uid.isdigit() or not uaargs.gid: 156 if not uaargs.uid or not uaargs.uid.isdigit() or not uaargs.gid:
150 handle_missing_id(uaargs.LOGIN, 'user', pkg) 157 handle_missing_id(uaargs.LOGIN, type, pkg, files, table_var, table_value)
151 158
152 # Reconstruct the args... 159 # Reconstruct the args...
153 newparam = ['', ' --defaults'][uaargs.defaults] 160 newparam = ['', ' --defaults'][uaargs.defaults]
@@ -184,19 +191,6 @@ def update_useradd_static_config(d):
184 def rewrite_groupadd(params, is_pkg): 191 def rewrite_groupadd(params, is_pkg):
185 parser = oe.useradd.build_groupadd_parser() 192 parser = oe.useradd.build_groupadd_parser()
186 193
187 # Return a list of configuration files based on either the default
188 # files/group or the contents of USERADD_GID_TABLES
189 # paths are resolved via BBPATH
190 def get_group_list(d):
191 str = ""
192 bbpath = d.getVar('BBPATH')
193 group_tables = d.getVar('USERADD_GID_TABLES')
194 if not group_tables:
195 group_tables = 'files/group'
196 for conf_file in group_tables.split():
197 str += " %s" % bb.utils.which(bbpath, conf_file)
198 return str
199
200 newparams = [] 194 newparams = []
201 groups = None 195 groups = None
202 for param in oe.useradd.split_commands(params): 196 for param in oe.useradd.split_commands(params):
@@ -216,10 +210,12 @@ def update_useradd_static_config(d):
216 # Note: similar to the passwd file, the 'password' filed is ignored 210 # Note: similar to the passwd file, the 'password' filed is ignored
217 # Note: group_members is ignored, group members must be configured with the GROUPMEMS_PARAM 211 # Note: group_members is ignored, group members must be configured with the GROUPMEMS_PARAM
218 if not groups: 212 if not groups:
219 groups = merge_files(get_group_list(d), 4) 213 files, table_var, table_value = get_table_list(d, 'USERADD_GID_TABLES', 'files/group')
214 groups = merge_files(files, 4)
220 215
216 type = 'system group' if gaargs.system else 'normal group'
221 if gaargs.GROUP not in groups: 217 if gaargs.GROUP not in groups:
222 handle_missing_id(gaargs.GROUP, 'group', pkg) 218 handle_missing_id(gaargs.GROUP, type, pkg, files, table_var, table_value)
223 newparams.append(param) 219 newparams.append(param)
224 continue 220 continue
225 221
@@ -231,7 +227,7 @@ def update_useradd_static_config(d):
231 gaargs.gid = field[2] 227 gaargs.gid = field[2]
232 228
233 if not gaargs.gid or not gaargs.gid.isdigit(): 229 if not gaargs.gid or not gaargs.gid.isdigit():
234 handle_missing_id(gaargs.GROUP, 'group', pkg) 230 handle_missing_id(gaargs.GROUP, type, pkg, files, table_var, table_value)
235 231
236 # Reconstruct the args... 232 # Reconstruct the args...
237 newparam = ['', ' --force'][gaargs.force] 233 newparam = ['', ' --force'][gaargs.force]