trippelganger
trippelganger

Reputation: 169

ERROR: useradd: useradd command did not succeed in Yocto build

I am trying to create a user and add it to the dialout group.

I have made a recipe that inherits useradd and adds the users my system needs.

Here is the relevant part of my recipe:

inherit useradd                                                                                     

USERADD_PACKAGES = "${PN}"                                                                          

USERADD_PARAM_${PN} = "-d /home/myuser -r -m -s /bin/bash myuser -g 
mygroup -G dialout;"                                                                               

GROUPADD_PARAM_${PN} = "-g 870 mygroup;"

The build gets to the rootfs_build step before getting an error. The log shows:

NOTE: useradd: Performing useradd with [--root 
/mnt/hdd1/yocto/build/tmp/work/intel_corei7_64-poky- 
linux/core-image-sato/1.0-r0/rootfs -d /home/myuser -r -m -s /bin/bash 
myuser -g mygroup -G dialout]                                                                                         
ERROR: useradd: useradd command did not succeed

Without the -G dialout option it works flawlessly. Any idea on how to solve this? I have also tried inheriting extrausers and doing usermod -aG dialout myuser.

Upvotes: 3

Views: 8823

Answers (3)

Tibor Takács
Tibor Takács

Reputation: 4828

I encountered the same issue. The solution was to use : instead of _ when ${PN} was appended:

inherit useradd                                                                                     

USERADD_PACKAGES = "${PN}"  
                                                                        
USERADD_PARAM:${PN} = "-d /home/myuser -r -m -s /bin/bash myuser -g mygroup -G dialout;"                                                                               

GROUPADD_PARAM:${PN} = "-g 870 mygroup;"

I believe this is due to the new override syntax. In other cases, bitbake complains (I use "honister"), for example:

do_install_append() {
    ...
}

results this error message: Variable do_install_append contains an operation using the old override syntax. Please convert this layer/metadata before attempting to use with a newer bitbake.

This can be resolved by using do_install:append().

Here is the full reference of the override syntax: https://docs.yoctoproject.org/bitbake/bitbake-user-manual/bitbake-user-manual-metadata.html#conditional-syntax-overrides

Upvotes: 3

trippelganger
trippelganger

Reputation: 169

What solved it in the end was to split up each useradd in its own recipe. I have no idea why it didn't work to have them in the same recipe, as that is based on this example in meta-skeleton.

So instead of having one users.bb with several users, I now have user1.bb, user2.bb etc., and it is working like a charm.

Upvotes: 1

Erik Botö
Erik Botö

Reputation: 1126

I suspect this is due to the fact that the dialout group does not exist, at least not at the time when myuser is being added.

If you skip the -G dialout part and build an image, do you have a group called dialout in /etc/group? If not, you can create the dialout group in the same way you create mygroup. If it already exists I suspect you will need to make sure the package adding the dialout group is installed before your package using something like RDEPENDS_${PN} += "<package that provides dialout group>.

Upvotes: 3

Related Questions