From 7aba3280c5363c29a644db9191b03a2c4ffb4658 Mon Sep 17 00:00:00 2001 From: Henning Heinold Date: Fri, 12 Sep 2014 19:13:44 +0200 Subject: [PATCH] recipes: add functions for generating a rootpasswd The rootpassword can be set via the enviroment variable ROOT_PASS either in the local.conf or on the cmdline before bitbake. Fixes: partly SYS#518 --- recipes-apps/images/image-passwd.inc | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 recipes-apps/images/image-passwd.inc 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 +}