Re: Add user to group that's created in other recipe


Martin Jansa
 



On Thu, Dec 1, 2022 at 12:05 AM Richard Purdie <richard.purdie@...> wrote:
On Wed, 2022-11-30 at 06:55 -0800, Sven via lists.yoctoproject.org
wrote:
> I have intermittent problems with a recipe that creates a user that
> is member of groups that are created by a different recipe. This is
> the recipe that creates the groups:
>
> # recipe-a.bb
> inherit useradd
> USERADD_PACKAGES = "${PN}"
> GROUPADD_PARAM:${PN} = "--system gpio;--system i2c"
>
> This is the recipe that creates the user:
>
> # recipe-b.bb
> inherit useradd
> USERADD_PACKAGES = "${PN}"
> GROUPADD_PARAM:${PN} = "--system mygroup"
> GROUPS = "dialout,mygroup,gpio,i2c"
> USERADD_PARAM:${PN} = "--system --no-create-home --shell /bin/false -
> -no-user-group --groups ${GROUPS} myuser"
> DEPENDS = "recipe-a"
>
> I guess it's also worth pointing out, that I use useradd-static:
> USERADDEXTENSION = "useradd-staticids"
> USERADD_ERROR_DYNAMIC = "error"
> USERADD_UID_TABLES = "files/passwd"
> USERADD_GID_TABLES = "files/group"
>
> Every now and then I get and error in recipe_b's do_package_setscene
> task where useradd complains that one of the groups provided by
> recipe_a does not exist. This appears to be a race condition since
> most of the times, this works OK. I was under the impression that
> specifying DEPENDS="recipe-a" in recipe_b.bb would be enough to
> declare this dependency. What am I doing wrong?

Just to confirm, this is with master?

I think there are some open bugs for useradd issues like this. It is
supposed to work but sounds like there are races. If there isn't a bug
open for it, there probably should be.

Join yocto@lists.yoctoproject.org to automatically receive all group messages.