Adding to torizon minimal with new user

I’m trying to add mosquitto to the torizon-minimal-dev image. mosquitto adds a user and a group and, from this reply, I then need to add to the static user and group list. What would be the recommended way to do this? I can modify directly the torizon-static-passwd/torizon-static-group files, but this doesn’t seem to be maintainable in a team environment. Is there a way to somehow just append to the file from my own layer? Should I just make a copy of the torizon versions of those files and modify them in my own layer?

Greetings @mckay

Is there a way to somehow just append to the file from my own layer? Should I just make a copy of the torizon versions of those files and modify them in my own layer?

I don’t think you can append files like this in Yocto since it’s not a recipe or something similar. As you said you probably just have to copy this in your own meta-layer. Then as long as your layer has a higher priority than meta-toradex-torizon your version of these files should be used in the build.

By the way I see you’re trying to build torizon-minimal-dev. If you don’t mind me asking what is your goal here? Trying to debug something?

Best Regards,
Jeremias

I have, in the past, for similar things, used a patch file with a custom strip-level to patch the file after it has been copied to the workdir. As @jeremias.tx mentioned, it might not work in this case since this is a DISTRO-level setting but maybe it gives you (or someone reading this thread) an idea of an alternate mechanism.

Drew

I took a quick look at the openembedded sources and it does not appear there is an easy way to “append” to this file. It really is just a single file that is defined in the USERADD_UID_TABLES variable. Without a feature change inside openembedded I think the best choice is to just create the modified version in your layer, making sure to keep it in sync with the one from the Torizon layers.

Drew

By the way I see you’re trying to build torizon-minimal-dev. If you don’t mind me asking what is your goal here? Trying to debug something?

Correct. We will be debugging our applications on the hardware so we used the torizon-minimal-dev as our baseline, mainly to get gdbserver support.

Correct. We will be debugging our applications on the hardware so we used the torizon-minimal-dev as our baseline, mainly to get gdbserver support.

That makes sense. Just wanted to make sure you understood what the *-dev image was for.

Best Regards,
Jeremias

@drew.tx we are facing a similar issue here.

We want to add a new user that doesn’t have sudo access to run all our daemons.

For us is kind of “no-go” to maintain the groups and passwd files in line with yours at each release.

Therefore I’m asking: isn’t there a way to “append” stuff to the /etc/passwd and /etc/groups recipe which runs after the recipe that dumps the USERADD_UID_TABLES file content ?

Every suggestion or help is highly appreciated :slight_smile:

Hi @Giona

The only other possibility that immediately comes to mind is to use a postprocessing command to add your custom users. The downside of that is you cannot use the Yocto user management bits to assign ownership of files to your users.

That said, we don’t expect the groups and passwd files to change much, if at all. In my post above I just wanted to mention it as a possibility and something that users will need to consider.

Drew