diff mbox series

[v2,6/6] rootfs-postcommands.bbclass: add a note to the login banner when root-with-empty-password logins are enabled

Message ID 20251030092248.723968-6-alex.kanavin@gmail.com
State New
Headers show
Series [v2,1/6] bbconfigbuild/configfragments.py: run discover_fragments() only once when enabling them | expand

Commit Message

Alexander Kanavin Oct. 30, 2025, 9:22 a.m. UTC
From: Alexander Kanavin <alex@linutronix.de>

When enabled, users will see:

===
Poky (Yocto Project Reference Distro) 5.2.99+snapshot-1dac0d15f2d979128cb449b59bf5fd69b4ba5084 qemux86-64 ttyS0

Type 'root' to login with superuser privileges (no password will be asked).

qemux86-64 login:
===

Signed-off-by: Alexander Kanavin <alex@linutronix.de>
---
 meta/classes-recipe/rootfs-postcommands.bbclass | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)
diff mbox series

Patch

diff --git a/meta/classes-recipe/rootfs-postcommands.bbclass b/meta/classes-recipe/rootfs-postcommands.bbclass
index 8b5822a0b5c..d3a569ba3ed 100644
--- a/meta/classes-recipe/rootfs-postcommands.bbclass
+++ b/meta/classes-recipe/rootfs-postcommands.bbclass
@@ -5,7 +5,7 @@ 
 #
 
 # Zap the root password if empty-root-password feature is not enabled
-ROOTFS_POSTPROCESS_COMMAND += '${@bb.utils.contains("IMAGE_FEATURES", "empty-root-password", "", "zap_empty_root_password ",d)}'
+ROOTFS_POSTPROCESS_COMMAND += '${@bb.utils.contains("IMAGE_FEATURES", "empty-root-password", "add_empty_root_password_note", "zap_empty_root_password ",d)}'
 
 # Allow dropbear/openssh to accept logins from accounts with an empty password string if allow-empty-password is enabled
 ROOTFS_POSTPROCESS_COMMAND += '${@bb.utils.contains("IMAGE_FEATURES", "allow-empty-password", "ssh_allow_empty_password ", "",d)}'
@@ -255,6 +255,13 @@  zap_empty_root_password () {
 	fi
 }
 
+#
+# This function adds a note to the login banner that the system is configured for root logins without password
+#
+add_empty_root_password_note () {
+	echo "Type 'root' to login with superuser privileges (no password will be asked).\n" >> ${IMAGE_ROOTFS}/etc/issue
+}
+
 #
 # allow dropbear/openssh to accept logins from accounts with an empty password string
 #