[yocto] Setting root password

Andy Pont andy.pont at sdcsystems.com
Thu Sep 24 06:59:21 PDT 2015


Hi Daniel,

> I didn't know about this EXTRA_USERS_PARAMS. What I do is adding this function to
> my image. 
> # This function sets the password for root based on ROOT_PASSWD variable
> set_root_password () {
>         local p=$(openssl passwd -1 -salt "My salt" "${ROOT_PASSWD}")
>        sed -e "s/root:[^:]*:/root:${p}:/" -i ${IMAGE_ROOTFS}/etc/shadow
> }
> And append it to ROOTFS_POSTPROCESS_COMMAND:
> ROOTFS_POSTPROCESS_COMMAND += "set_root_password; "
> I did all this in a class file which I import on all my images, 

As your method works and the EXTRA_USERS_PARAMS appears not to be doing could you send me your class file to save me having to reinvent the wheel?

> About your problem, can you get the "usermod" error from log.do_rootfs 

The end of the log.do_roots file just contains the following:

NOTE: Executing set_user_group ...
DEBUG: Executing shell function set_user_group
NOTE: Performing usermod with [-R XXXXX/build/tmp/work/intel_core2_32-poky-linux/core-image-minimal-initramfs/1.0-r0/rootfs -P Hkw6rBJlcfhvM root] and 1 times of retry
Server refused shutdown.  Remaining client fds: 2
Client pids: 3878 16245
Server will shut down after all clients exit.
WARNING: usermod command did not succeed. Retrying...
ERROR: Tried running usermod command 1 times without success, giving up
WARNING: XXXXX/build/tmp/work/intel_core2_32-poky-linux/core-image-minimal-initramfs/1.0-r0/temp/run.set_user_group.3878:1 exit 1 from
  exit 1
DEBUG: Python function do_rootfs finished

Thanks,

Andy.




More information about the yocto mailing list