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
This commit is contained in:
Henning Heinold 2014-09-12 19:13:44 +02:00 committed by Henning
parent 0172c5958a
commit 7aba3280c5
1 changed files with 16 additions and 0 deletions

View File

@ -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
}