Reputation: 501
I tried to set my a password for the root by several approches. Nothing worked for me so far. I added to the local.conf:
INHERIT += "extrausers"
EXTRA_USER_PARAMS = "usermod -P 'mypasswd' root;"
I also tried encrypting the password using "openssl passwd -6 -salt 12345 mypasswd":
INHERIT += "extrausers"
EXTRA_USER_PARAMS = "usermod -p '\$6\$12345\$CdkMCUqHIe6eWfFhMIppyUE/S.iLGe.PACPivJhw05ideCyogNpnVNDIBSQXhSruJxfZCasTi6YvFOrPgFvM7/' root;"
I tried both variants with and without EXTRA_IMAGE_FEATURES ?= "debug-tweaks". I also tried to set the password in sources/meta-qoriq/recipes-kernel/linux/linux-qoriq.inc which gets included in the kernel recipe "sources/meta-qoriq/recipes-kernel/linux/linux-qoriq_5.15.bb" like this "require linux-qoriq.inc". With EXTRA_IMAGE_FEATURES ?= "debug-tweaks" set, no password was set and without it the password was wrong. I also tried to edit the /ect/shadow file manually using the ROOTFS_POSTPROCESS_COMMAND. Therefore I added this lines in the sources/meta-qoriq/recipes-kernel/linux/linux-qoriq.inc file as it seems not to be possible to add a bash function to the local.conf file.
set_pw () {
encrypted=$(openssl passwd -6 -salt 12345 mypasswd)
sed -i "s/^root::/root:$encrypted:/" ${IMAGE_ROOTFS}/etc/shadow
}
ROOTFS_POSTPROCESS_COMMAND += "set_pw;"
This also did not work. My board is a freescale LS1046ARDB. That's why im using the linux qoriq distribution from freescale.
EDIT:
Adding:
inherit fsl-utils
ROOTFS_POSTPROCESS_COMMAND += "set_pw;
to the .bb file of the image I'm building (sources/meta-qoriq/recipes-fsl/images/fsl-image-networking.bb) and adding the set_pw function to the sources/meta-qoriq/classes/fsl-utils.bbclass file worked for me. It was not possible to add the bash function to the fsl-image-networking.bb file directly. But I'm still wondering why the
INHERIT += "extrausers"
EXTRA_USER_PARAMS = "usermod -P 'mypasswd' root;"
is not working. That's how it worked in some other posts like this one How to set root password on Yocto / Poky image?. Has the syntax of doing this changed in kirkstone?
Upvotes: 3
Views: 3034
Reputation: 91
To answer:
But I'm still wondering why the
INHERIT += "extrausers"
EXTRA_USER_PARAMS = "usermod -P 'mypasswd' root;"
is not working. That's how it worked in some other posts like this one How to set root password on Yocto / Poky image?. Has the syntax of doing this changed in kirkstone?
As Tomas mentions, you need to use EXTRA_USERS_PARAMS.
I have used plain text passwords in the past on Yocto Sumo which worked. Now that I have moved to Kirkstone I've noticed it doesn't because usermod has been changed to no longer accept plaintext password. You must pass it an encrypted password:
-p, --password PASSWORD
The encrypted password, as returned by crypt(3).
Also note that -p is used instead of -P.
Yocto manual provides a good example of setting up a root password + new user. Example of using extrausers in Kirkstone
Upvotes: 1
Reputation: 1929
Probably a typo on the variable name? The correct is EXTRA_USERS_PARAMS
(note the plural of users), see the official documentation.
BTW, the best practices are discussed here: How to securely update configuration for root password in yocto?
Upvotes: 3