useradd.bbclass: fix parse error when only USERADD_DEPENDS is set
cover useradd.bbclass: fix parse error when only USERADD_DEPENDS is set
When a recipe inherits useradd and only sets USERADD_DEPENDS (to depend on users/groups created by another recipe) without creating any users/groups itself, the parse-time sanity check in update_useradd_after_parse() unconditionally throws a fatal error about missing USERADD_PACKAGES.
This series fixes the issue by skipping the USERADD_PACKAGES validation when USERADD_DEPENDS is set, and adds a selftest recipe to exercise this code path.
Fixes [YOCTO #15863]
Zk47T (2):
useradd.bbclass: allow inheriting with only USERADD_DEPENDS set
meta-selftest: add usegroup-deponly recipe to test USERADD_DEPENDS
only
.../selftest-users/usegroup-deponly.bb | 25 +++++++++++++++++++ meta/classes/useradd.bbclass | 5 ++++ 2 files changed, 30 insertions(+) create mode 100644 meta-selftest/recipes-test/selftest-users/usegroup-deponly.bb
Signature · 1 line
2.34.1
PATCH 1/2 useradd.bbclass: allow inheriting with only USERADD_DEPENDS set
When a recipe inherits useradd and only sets USERADD_DEPENDS (to depend on users/groups created by another recipe), without creating any users/groups itself, the parse-time sanity check incorrectly throws a fatal error about missing USERADD_PACKAGES.
Skip the USERADD_PACKAGES/USERADD_PARAM validation when USERADD_DEPENDS is set but USERADD_PACKAGES is not, since the recipe only needs build dependency tracking, not user/group creation.
Fixes [YOCTO #15863]
--- meta/classes/useradd.bbclass | 5 +++++ 1 file changed, 5 insertions(+)
meta/classes/useradd.bbclass +5 -0
@@ -212,6 +212,11 @@ def update_useradd_after_parse(d): useradd_packages = d.getVar('USERADD_PACKAGES') if not useradd_packages: + # It's valid to inherit useradd and only set USERADD_DEPENDS to + # depend on users/groups created by another recipe, without + # creating any users/groups in this recipe. + if d.getVar('USERADD_DEPENDS'): + return bb.fatal("%s inherits useradd but doesn't set USERADD_PACKAGES" % d.getVar('FILE', False)) for pkg in useradd_packages.split():
Signature · 1 line
2.34.1
PATCH 2/2 meta-selftest: add usegroup-deponly recipe to test USERADD_DEPENDS only
In reply to Zk47TAdd a test recipe that inherits useradd and only sets USERADD_DEPENDS without USERADD_PACKAGES to validate the fix for [YOCTO #15863].
The root bug is that useradd.bbclass unconditionally requires USERADD_PACKAGES to be set, even when a recipe only needs to depend on users/groups created by another recipe via USERADD_DEPENDS. This recipe depends on creategroup1 for user gt1 and group grouptest, but does not create any users/groups itself, exercising the code path fixed in the previous commit.
--- .../selftest-users/usegroup-deponly.bb | 25 +++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 meta-selftest/recipes-test/selftest-users/usegroup-deponly.bb
meta-selftest/recipes-test/selftest-users/usegroup-deponly.bb new file +25 -0
@@ -0,0 +1,25 @@ +SUMMARY = "Test recipe that only uses USERADD_DEPENDS without USERADD_PARAM" +LIC_FILES_CHKSUM = "file://${COMMON_LICENSE_DIR}/MIT;md5=0835ade698e0bcf8506ecda2f7b4f302" + +LICENSE = "MIT" + +# This recipe depends on the user/group created by creategroup1 +# but does NOT create users or groups itself. +USERADD_DEPENDS = "creategroup1" + +S = "${WORKDIR}/sources" +UNPACKDIR = "${S}" + +EXCLUDE_FROM_WORLD = "1" + +inherit useradd allarch + +TESTDIR = "${D}${sysconfdir}/deponly" + +do_install() { + install -d ${TESTDIR} + touch ${TESTDIR}/file + chown gt1:grouptest ${TESTDIR}/file +} + +FILES:${PN} = "${sysconfdir}/deponly/*"
Signature · 1 line
2.34.1
Re: [OE-core] [PATCH 2/2] meta-selftest: add usegroup-deponly recipe to test USERADD_DEPENDS only
Quoted 10 lines · On 8 Apr 2026, at 16:00, Zk47T via lists.openembedded.org…
Add a test recipe that inherits useradd and only sets
USERADD_DEPENDSwithoutUSERADD_PACKAGESto validate the fix for [YOCTO #15863].The root bug is that useradd.bbclass unconditionally requires
USERADD_PACKAGESto be set, even when a recipe only needs to depend on users/groups created by another recipe viaUSERADD_DEPENDS. This recipe depends on creategroup1 for user gt1 and group grouptest, but does not create any users/groups itself, exercising the code path fixed in the previous commit.
This recipe to exercise the paths is great, but there is no test case for it. Can you add something to oe-selftest to verify this builds?
Thanks,
Ross