[OE-core] [PATCH 1/2] rootfs-postcommands.bbclass: fix zap_empty_root_password

Robert Yang liezhi.yang at windriver.com
Wed Nov 23 07:49:25 UTC 2016


[YOCTO #10710]

The previous logic works when root passwd is blank, but it doesn't work
when there is a root passws, for example:
1) Set a root passwd in base-passwd
2) IMAGE_FEATURES += "debug-tweaks"
Start the target, it still requires passwd to login.

Empty passwd if debug-tweaks is in IMAGE_FEATURES, else do nothing can
fix problem.

Signed-off-by: Robert Yang <liezhi.yang at windriver.com>
---
 meta/classes/rootfs-postcommands.bbclass | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/meta/classes/rootfs-postcommands.bbclass b/meta/classes/rootfs-postcommands.bbclass
index 0c7ceea..353dc4f 100644
--- a/meta/classes/rootfs-postcommands.bbclass
+++ b/meta/classes/rootfs-postcommands.bbclass
@@ -1,6 +1,6 @@
 
 # Zap the root password if debug-tweaks feature is not enabled
-ROOTFS_POSTPROCESS_COMMAND += '${@bb.utils.contains_any("IMAGE_FEATURES", [ 'debug-tweaks', 'empty-root-password' ], "", "zap_empty_root_password ; ",d)}'
+ROOTFS_POSTPROCESS_COMMAND += '${@bb.utils.contains_any("IMAGE_FEATURES", [ 'debug-tweaks', 'empty-root-password' ], "empty_root_password ; ", "",d)}'
 
 # Allow dropbear/openssh to accept logins from accounts with an empty password string if debug-tweaks is enabled
 ROOTFS_POSTPROCESS_COMMAND += '${@bb.utils.contains_any("IMAGE_FEATURES", [ 'debug-tweaks', 'allow-empty-password' ], "ssh_allow_empty_password; ", "",d)}'
@@ -105,12 +105,12 @@ read_only_rootfs_hook () {
 #
 # This function is intended to disallow empty root password if 'debug-tweaks' is not in IMAGE_FEATURES.
 #
-zap_empty_root_password () {
+empty_root_password () {
 	if [ -e ${IMAGE_ROOTFS}/etc/shadow ]; then
-		sed -i 's%^root::%root:*:%' ${IMAGE_ROOTFS}/etc/shadow
+		sed -i 's%^root:[^:]*:%root::%' ${IMAGE_ROOTFS}/etc/shadow
         fi
 	if [ -e ${IMAGE_ROOTFS}/etc/passwd ]; then
-		sed -i 's%^root::%root:*:%' ${IMAGE_ROOTFS}/etc/passwd
+		sed -i 's%^root:[^:]*:%root::%' ${IMAGE_ROOTFS}/etc/passwd
 	fi
 } 
 
-- 
2.10.2




More information about the Openembedded-core mailing list