Search code examples
linuxembeddedembedded-linuxyocto

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.


Solution

  • 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.