meta-digi-dey: use 'extrausers' class to set root password
This simplifies the code and as an extra allows to override the default root password from the project's local.conf (setting MD5_ROOT_PASSWD variable) https://jira.digi.com/browse/DEL-1558 Signed-off-by: Javier Viguera <javier.viguera@digi.com>
This commit is contained in:
parent
ef92164fb2
commit
7f3e1a4d1a
|
|
@ -7,26 +7,17 @@
|
||||||
#
|
#
|
||||||
inherit image-buildinfo
|
inherit image-buildinfo
|
||||||
|
|
||||||
## DEY rootfs final tuning
|
#
|
||||||
dey_rootfs_tuning() {
|
# Set root password using 'extrausers' class if 'debug-tweaks' is NOT enabled
|
||||||
#######################################################################
|
#
|
||||||
## Set root password to 'root' if 'debug-tweaks' is NOT enabled.
|
# To get the encrypted password (with escaped '$' char: '\$') run following
|
||||||
## command: echo -n 'root' | mkpasswd -5 -s
|
# command in your development computer:
|
||||||
#######################################################################
|
#
|
||||||
MD5_ROOT_PASSWD='$1$SML0de4S$lOWs3t82QAH0oEf8NyNKA0'
|
# echo -n 'root' | mkpasswd -5 -s | sed -e 's,\$,\\$,g'
|
||||||
if echo "${IMAGE_FEATURES}" | grep -qs debug-tweaks; then
|
#
|
||||||
: # No-op
|
inherit ${@bb.utils.contains("IMAGE_FEATURES", "debug-tweaks", "", "extrausers",d)}
|
||||||
else
|
|
||||||
# Shadow passwords ENABLED
|
MD5_ROOT_PASSWD ?= "\$1\$SML0de4S\$lOWs3t82QAH0oEf8NyNKA0"
|
||||||
if [ -f "${IMAGE_ROOTFS}/etc/shadow" ]; then
|
EXTRA_USERS_PARAMS += "\
|
||||||
sed 's%^root:[^:]*:%root:x:%' <${IMAGE_ROOTFS}/etc/passwd >${IMAGE_ROOTFS}/etc/passwd.new
|
usermod -p '${MD5_ROOT_PASSWD}' root; \
|
||||||
sed "s%^root:[^:]*:%root:${MD5_ROOT_PASSWD}:%" <${IMAGE_ROOTFS}/etc/shadow >${IMAGE_ROOTFS}/etc/shadow.new
|
"
|
||||||
mv ${IMAGE_ROOTFS}/etc/passwd.new ${IMAGE_ROOTFS}/etc/passwd
|
|
||||||
mv ${IMAGE_ROOTFS}/etc/shadow.new ${IMAGE_ROOTFS}/etc/shadow
|
|
||||||
# Shadow passwords DISABLED
|
|
||||||
else
|
|
||||||
sed "s%^root:[^:]*:%root:${MD5_ROOT_PASSWD}:%" <${IMAGE_ROOTFS}/etc/passwd >${IMAGE_ROOTFS}/etc/passwd.new
|
|
||||||
mv ${IMAGE_ROOTFS}/etc/passwd.new ${IMAGE_ROOTFS}/etc/passwd
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
|
||||||
|
|
@ -41,5 +41,3 @@ IMAGE_ROOTFS_SIZE = "8192"
|
||||||
|
|
||||||
# Do not install udev-cache
|
# Do not install udev-cache
|
||||||
BAD_RECOMMENDATIONS += "udev-cache"
|
BAD_RECOMMENDATIONS += "udev-cache"
|
||||||
|
|
||||||
ROOTFS_POSTPROCESS_COMMAND += "dey_rootfs_tuning;"
|
|
||||||
|
|
|
||||||
|
|
@ -31,4 +31,3 @@ IMAGE_FSTYPES_remove = "ext4"
|
||||||
IMAGE_FSTYPES_append = " ext2"
|
IMAGE_FSTYPES_append = " ext2"
|
||||||
|
|
||||||
BAD_RECOMMENDATIONS += "busybox-syslog"
|
BAD_RECOMMENDATIONS += "busybox-syslog"
|
||||||
ROOTFS_POSTPROCESS_COMMAND += "dey_rootfs_tuning;"
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue