From 54dd5c56fc76390bcc02b4d91eec2d8c45b7ae77 Mon Sep 17 00:00:00 2001 From: Johannes Schneider Date: Tue, 2 Aug 2022 11:40:19 +0200 Subject: classes: rootfs-postcommands: autologin root on serial-getty when empty-root-password AND serial-autologin-root are part of the IMAGE_FEATURES, save some of the developers time by not having to type the (then still sole) 'root' username on the serial console after each and every reboot this is done by inserting '--autologin root' into the command line of the responsible 'getty' service (From OE-Core rev: 01b3cb46405f814e27cab5290118211786cd63a0) Signed-off-by: Johannes Schneider Signed-off-by: Luca Ceresoli Signed-off-by: Richard Purdie --- meta/classes-recipe/rootfs-postcommands.bbclass | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) (limited to 'meta/classes-recipe/rootfs-postcommands.bbclass') diff --git a/meta/classes-recipe/rootfs-postcommands.bbclass b/meta/classes-recipe/rootfs-postcommands.bbclass index d40adf5f0e..bf1e992bb2 100644 --- a/meta/classes-recipe/rootfs-postcommands.bbclass +++ b/meta/classes-recipe/rootfs-postcommands.bbclass @@ -13,6 +13,9 @@ ROOTFS_POSTPROCESS_COMMAND += '${@bb.utils.contains_any("IMAGE_FEATURES", [ 'deb # Allow dropbear/openssh to accept root logins if debug-tweaks or allow-root-login is enabled ROOTFS_POSTPROCESS_COMMAND += '${@bb.utils.contains_any("IMAGE_FEATURES", [ 'debug-tweaks', 'allow-root-login' ], "ssh_allow_root_login; ", "",d)}' +# Autologin the root user on the serial console, if empty-root-password and serial-autologin-root are active +ROOTFS_POSTPROCESS_COMMAND += '${@bb.utils.contains("IMAGE_FEATURES", [ 'empty-root-password', 'serial-autologin-root' ], "serial_autologin_root; ", "",d)}' + # Enable postinst logging if debug-tweaks or post-install-logging is enabled ROOTFS_POSTPROCESS_COMMAND += '${@bb.utils.contains_any("IMAGE_FEATURES", [ 'debug-tweaks', 'post-install-logging' ], "postinst_enable_logging; ", "",d)}' @@ -201,6 +204,23 @@ ssh_allow_root_login () { fi } +# +# Autologin the 'root' user on the serial terminal, +# if empty-root-password' AND 'serial-autologin-root are enabled +# +serial_autologin_root () { + if ${@bb.utils.contains("DISTRO_FEATURES", "sysvinit", "true", "false", d)}; then + # add autologin option to util-linux getty only + sed -i 's/options="/&--autologin root /' \ + "${IMAGE_ROOTFS}${base_bindir}/start_getty" + elif ${@bb.utils.contains("DISTRO_FEATURES", "systemd", "true", "false", d)}; then + if [ -e ${IMAGE_ROOTFS}${systemd_system_unitdir}/serial-getty@.service ]; then + sed -i '/^\s*ExecStart\b/ s/getty /&--autologin root /' \ + "${IMAGE_ROOTFS}${systemd_system_unitdir}/serial-getty@.service" + fi + fi +} + python sort_passwd () { import rootfspostcommands rootfspostcommands.sort_passwd(d.expand('${IMAGE_ROOTFS}${sysconfdir}')) -- cgit v1.2.3-54-g00ecf