Skip to contentSkip to conversation

static IDs bugs and usability

PATCH New Patrick Ohly 1 participant 2 messages Jul 28, 2016

lore
Share & tools
lore
#0 lore raw

cover static IDs bugs and usability

In Ostro OS we just started to use useradd-staticids.bbclass. Dynamic IDs are an error (USERADD_ERROR_DYNAMIC = "error") by default because warnings probably wouldn't be noticed. I was a bit reluctant to make this change because Ostro OS is supposed to be customizable, and that becomes harder when developers also have to define IDs.

But we didn't have a choice because after updating to recent OE-core, our dynamically assigned IDs started to change randomly between builds, which (as we learned only because of that change) broke the swupd update mechanism. Personally I suspect that Python3's randomization feature is responsible for not getting deterministic results anymore, but I haven't investigated further.

useradd-staticids.bbclass has a bug which impacts developers when they edit the table files to fix a warning or error raised by the class:
the cached version of the affected recipe continues to be used and thus editing the files has no effect. Patch fixing that follows.

There's also a caveat associated with how USERADD_ERROR_DYNAMIC = "error" is implemented: it marks recipes as "skipped" with an error messages from useradd-staticids.bbclass. This is not particularly developer-friendly.

For example, when the skipped recipe is deep down in the dependency chain, then building will fail with rather difficult to understand "nothing provides..." messages. It does mention eventually that a recipe was skipped with the right error, so the information is at least there.

However, it's also possible that a recipe exists in two versions, and only the one normally picked as default gets skipped. In that case, the remaining version will get build, i.e. useradd-staticids.bbclass has the very undesirable effect of silently building something else than expected instead of aborting the build because of the error.

I've not seen that in practice, though, so I don't know how big of a problem it is.

The following changes since commit b32d430c3c7dccf3a8d06ab492d648893a05950f:

dpkg: use snapshot.debian.org for SRC_URI (2016-07-26 08:56:08 +0100)

are available in the git repository at:

git://github.com/pohly/openembedded-core static-ids
https://github.com/pohly/openembedded-core/tree/static-ids

Patrick Ohly (1):
useradd-staticids.bbclass: trigger reparsing when table files change

 meta/classes/useradd-staticids.bbclass | 13 +++++++++++++
 1 file changed, 13 insertions(+)
Signature · 1 line
2.1.4
#1 lore raw

PATCH 1/1 useradd-staticids.bbclass: trigger reparsing when table files change

This addresses (among others) the following problem:
- USERADD_ERROR_DYNAMIC=error causes a recipe to get skipped because a static ID entry is missing
- the entry gets added to the file
- using the recipe still fails with the same error as before because the recipe gets loaded from the cache instead of re-parsing it with the new table content

---
 meta/classes/useradd-staticids.bbclass | 13 +++++++++++++
 1 file changed, 13 insertions(+)
meta/classes/useradd-staticids.bbclass +13 -0
index 149245b..46d4a4b 100644
@@ -285,6 +285,19 @@ def update_useradd_static_config(d):
 
         return ";".join(newparams).strip()
 
+    # The parsing of the current recipe depends on the content of
+    # the files listed in USERADD_UID/GID_TABLES. We need to tell bitbake
+    # about that explicitly to trigger re-parsing and thus re-execution of
+    # this code when the files change.
+    bbpath = d.getVar('BBPATH', True)
+    for varname, default in (('USERADD_UID_TABLES', 'files/passwd'),
+                             ('USERADD_GID_TABLES', 'files/group')):
+        tables = d.getVar(varname, True)
+        if not tables:
+            tables = default
+        for conf_file in tables.split():
+            bb.parse.mark_dependency(d, bb.utils.which(bbpath, conf_file))
+
     # Load and process the users and groups, rewriting the adduser/addgroup params
     useradd_packages = d.getVar('USERADD_PACKAGES', True)
 
Signature · 1 line
2.1.4