Search code examples
yocto

What is the exact difference between extrauser and useradd


In one recipe i can see the following but it is not creating any extra user or group, that i confirmed while inspecting rpm file.

inherit extrausers
EXTRA_USERS_PARAMS = "\
        useradd -p '' example; \
        groupadd example; \
        "

So I added the following in the recipe which created a user and group for me.

inherit useradd
USERADD_PACKAGES = "${PN}"
GROUPADD_PARAM_${PN} = "--system example"
USERADD_PARAM_${PN} = "--system -M -d /var/lib/example -s /bin/false -g example example"

What is the exact difference between useradd and extrausers in yocto. Why extrausers cannot able to create user and group.


Solution

  • extrausers add user/group at image level and cannot be tied to a specific recipe, and that's the role of useradd class, it can be used on a recipe.

    Read the note here:

    Note

    The user and group operations added using the extrausers class are not tied to a specific recipe outside of the recipe for the image. Thus, the operations can be performed across the image as a whole. Use the useradd class to add user and group configuration to a specific recipe.

    And here is the note for useradd:

    The useradd* classes support the addition of users or groups for usage by the package on the target. For example, if you have packages that contain system services that should be run under their own user or group, you can use these classes to enable creation of the user or group.