diff --git a/recipes-apps/images/image-passwd.inc b/recipes-apps/images/image-passwd.inc new file mode 100644 index 0000000..6839d19 --- /dev/null +++ b/recipes-apps/images/image-passwd.inc @@ -0,0 +1,16 @@ +DEPENDS += "openssl-native" + +rootpasswd = "${@d.getVar('ROOT_PASS', True) or ""}" + +ROOTFS_POSTPROCESS_COMMAND += "set_root_passwd;" + +set_root_passwd() { + if [ -n "${rootpasswd}" ]; then + HASHED_PASS=`openssl passwd -1 ${rootpasswd}` + if [ -n "${HASHED_PASS}" ]; then + sed -e "s%^root:[^:]*:%root:${HASHED_PASS}:%" \ + -i ${IMAGE_ROOTFS}/etc/shadow + echo "Generated new root-passwd" + fi + fi +}