Skip to contentSkip to conversation

issue adding the user with the yocto kirkstone

DISCUSSION Mahendra Sondagar 2 participants 4 messages Apr 25, 2024 – Apr 26, 2024

lore
Share & tools
lore
#0 lore raw

Hi.. There

I'm dealing with the yocto kirkstone with the Ubuntu 20.04 LTS host

At present, i have created my custom image by adding the layer meta-custom

Initially, the basic image building were successful and I'm able to boot the custom image

However, my intention is to add the root password and user with the image. That's how i have added the EXTRA_USER_PARAMS variable

Unfortunately, This time the image won't be successfully building

This is what I'm getting as and error logs during the building of the image

DEBUG: Executing shell function empty_var_volatile DEBUG: Shell function empty_var_volatile finished NOTE: Executing set_user_group ... DEBUG: Executing shell function set_user_group NOTE: custom-image: Performing usermod with [-R /home/mahendra/Documents/MyWorkSpace/my-git/Yocto-stm32mp1/build-mp1/tmp/work/stm32mp1-poky-linux-gnueabi/custom-image/1.0-r0/rootfs -P mahi root] usermod: prefix must be an absolute path ERROR: custom-image: usermod command did not succeed. WARNING: exit code 1 from a shell command. DEBUG: Python function do_rootfs finished

Here I have attached the custom-image.bb file

SUMMARY = "Minimal custom image for STM32MP1-DK1 board" AUTHOR= "Mahendra Sondagar | [email protected]" IMAGE_INSTALL = "packagegroup-core-boot ${CORE_IMAGE_EXTRA_INSTALL}" IMAGE_LINGUAS = " " LICENSE = "MIT" inherit core-image inherit extrausers # Set rootfs to 200 MiB by default IMAGE_OVERHEAD_FACTOR ?= "1.2" IMAGE_ROOTFS_SIZE ?= "204800" EXTRA_USERS_PARAMS = " \ usermod -P mahi root; \ "

Can anyone help me here to fix the issue ?

Thanks

Mahendra

#1 lore raw

Hi, Mahendra

Try using useradd instead of usermod for creating your user with the EXTRA_USER_PARAMS feature. Something like this:

EXTRA_USERS_PARAMS : append = "\
useradd -m -s /bin /bash -P 'mahi' root; \
"

#2 lore raw

hi.. @Daniel

Many Thanks for the support

This resolve the issue

EXTRA_USERS_PARAMS += " useradd -m -s /bin/bash -P 'mahi' root;"

however,  when i build the image and try to login with the board then I can't

it's always returning as an incorrect password!

here is the logs .....

stm32mp1 login: root
Password:
Login incorrect

What's wrong with it ?

Thanks

#3 lore raw

You might want to check the "useradd/usermod" options with the "useradd/usermod --help" command. If you want to add a password the flag would be "-p", and this argument expects the password to be encrypted. You can generate this encrypted password with the command: " openssl passwd -1 <password_to_hash_encrypt> ", for example.

Now, I've just noticed that we are referring to the 'root' user, which already exists! In this case, you just need to change its password, and you can use the 'usermod' command with the '-p' flag. Here are the two scenarios:

# Case for adding a new user with password
EXTRA_USERS_PARAMS : append = "\

useradd -m -s /bin /bash -p '<encrypted password>' <new_user>; \
"

# Case for adding a password to an existent user like root EXTRA_USERS_PARAMS : append = "\
usermod -p '<encrypted password>' root; \
"

Note. Remember to escape characters from the encrypted password. For example, if there are any dollars in your string, escape them with the backslash. For instance:

- '$7abc.$8'
+ '\$7abc.\$8'

—Daniel