[yocto] Setting root password

Daniel. danielhilst at gmail.com
Thu Sep 24 06:45:04 PDT 2015


Hey Andy,

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, but since
you point me EXTRA_USERS_PARAMS I think I'll do that in your (the right)
way. About your problem, can you get the "usermod" error from log.do_rootfs
in your image WORKDIR/temp folder?

Cheers
- dhs

PS: Not all shells recognize the "local" keyword. Remove it if you have
problems.

2015-09-24 10:24 GMT-03:00 Andy Pont <andy.pont at sdcsystems.com>:

> Hello,
>
> Looking around the web and reading the assorted documents it seems to be
> that the defined way to set the root password is to remove "debug-tweaks"
> from EXTRA_IMAGE_FEATURES and to add the following lines to local.conf:
>
> require conf/distro/include/security_flags.inc
> INHERIT += "extrausers"
> EXTRA_USERS_PARAMS = "usermod -P <encrypted_password> root;"
>
> When I try to build core-image-minimal then the build fails with the
> following:
>
> | 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
> | ERROR: Function failed: set_user_group (log file is located at
>
> XXXXX/build/tmp/work/intel_core2_32-poky-linux/core-image-minimal-initramfs/
> 1.0-r0/temp/log.do_rootfs.3878)
>
> Any ideas on how to make this work?
>
> Thanks,
>
> Andy.
>
> --
> _______________________________________________
> yocto mailing list
> yocto at yoctoproject.org
> https://lists.yoctoproject.org/listinfo/yocto
>



-- 
*"Do or do not. There is no try"*
  *Yoda Master*
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.yoctoproject.org/pipermail/yocto/attachments/20150924/f78534fe/attachment.html>


More information about the yocto mailing list